Learning Linux- Basic Commands
Beginner Guide to Learning Ubuntu
Linux is an operating system, just like Windows and macOS. It’s free and perfect for programmers. Linux shell is one of the many features that add to the operating system's worth. In this article, we’ll dive into some basic shell commands of a Linux distro, Ubuntu.
Opening Command-Line
To open the Terminal press CTRL + ALT + T or navigate to Show Application and search Terminal
Finding Current Directory
By default, when you open the terminal, you are in home directory of a user.
To find which directory you are currently in, the command pwd is used.
Listing File/Folders in a Directory
To display all the files and folders in the current directory, the command ls is used.
To display them as a list, the flag -l is added: ls -l.
To display the contents of another directory ls -l <path> is used.
Changing Directories
In order to move into a sub-directory, the command used is cd <directory name>.
To go back to the parent folder, cd .. is used. And to return to home directory cd ~ is used.
Another command to change directory is cd <path>.
Making a New Directory and File
To make a new folder, cd into the directory you want to create the new folder in, and type: mkdir <Folder Name>
Incase file name contains spaces, enclose the name in ‘ ’.
To make a new file, cd into the directory you want to create the file in, and type: touch <File Name>
Deleting a Directory and Files
To delete a file, cd into the directory you want to delete the file from and type the command: rm <File Name>.
To delete a folder you may use either of these two commands: rmdir ‘File B’ or rm -r ‘File A’.
Copying a File
To copy a file, cd into its directory and use the command cp <File Name> <New Path>.
Renaming and Moving the File
To rename a file, use command mv <Old Name> <New Name>
To move a file, use the command mv <File Name> <New Path>
Conclusion
These were some basic Linux commands. Further, clear command can be used to clean the terminal, CTRL +C to cancel the current process in the terminal, CTRL + SHIFT + C to copy from the terminal, and CTRL + SHIFT + V to paste to the terminal.
Practice these commands on your machine, and master Linux the commands for beginners.