Linux Command Line Basics
Here are the basic commands that you should become familiar with when learning about the command line in Linux. One thing to remember is that Linux is case sensitive. That means if you type in “cd Movies” and the file is called “movies” you won’t find it.
Command Line basics will help you navigate through the essential commands to get around in the Linux command line. You can read the man pages online here.
Use the “pwd” command to find out the path of the current working directory (folder) you’re in. The command will return an absolute (full) path, which is basically a path of all the directories that starts with a forward slash (/).
Use the “cd“ command to go to a directory.
- cd ~/Movies Will Bring you to the Movies file
- cd to go straight to the home folder
- cd .. Move up one directory
- cd- to move to your previous directory
Use the “ls“ command to know what files are in the directory you are in. You can use “ls -a” to show hidden files.
- ls -R will list all the files in the sub-directories as well
- ls -a will show the hidden files
- ls -al will list the files and directories with detailed information
Use the “mkdir“ command when you need to create a folder or a directory.
- mkdir Music/Newfile
Use “rmdir” to delete an empty directory.
- rmdir Oldfile
Use “rm” to delete a directory with files in it.
- rm filename
The “touch“ command is used to create a file.
- touch newfile.txt
To know more about a command and how to use it, use the “man” command. It shows the manual pages of the command. More on man files and how to read them.
Use the cp command to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to it will be copied to.
Use the “mv” command to move files through the command line. We can also use the “mv” command to rename a file.
The “locate” command is used to locate a file in a Linux system. Read Finding things in Linux.
Use the “cat” command to display the contents of a file.
- cat file.txt
Similar to the “locate” command, using “find” also searches for files and directories. The difference is, you use the “find” command to locate files within a given directory. Read Finding things in Linux.
The “sudo” command enables you to perform tasks that require administrative or root permissions. You can find out more about sudo here.
“chmod” is another Linux command, used to change the read, write, and execute permissions of files and directories. You can find more information on file permissions here.
These are just some of the commands in Linux to get you started on your journey. Play around with the commands and read the Man pages to get more information.