Linux knowledge is vital no matter what your chosen IT career is. We covered some of the reasons you need to learn Linux in another blog post.
There is no need to be an expert, of course. Just navigating the Linux command line and carrying out a few simple tasks will suffice. If you want to get certified, then I strongly recommend taking the Linux LPI Essentials certification.
In this post I’ll list what I consider to be the 10 must-know commands along with examples of how they are used. This is just a kicking off point of course and not designed to help you manage a Linux network or server.
ls – list the contents of a directory
To use the ls
command in Linux, open a terminal window and type ls
followed by any options or arguments you want to use. For example, to list the files and directories in the current directory, you would type ls
and press enter.
To list the files in a specific directory, you can provide the directory path as an argument to the ls
command. For example, to list the files in the /home/user/documents
directory, you would type ls /home/user/documents
and press enter.
Additional options can be added to the ls
command to modify its behavior. For example, the -l
option displays the files in a long format, including file permissions, ownership, and timestamp. To display the files in the current directory in long format, you would type ls -l
and press enter.
cd – change the current working directory
The cd
(change directory) command is used in Linux to navigate between directories in the file system.
To use the cd
command, open a terminal window and type cd
followed by the path of the directory you want to navigate to. For example, to navigate to the /home/user/documents
directory, you would type cd /home/user/documents
and press enter.
You can also use cd
command without any argument to navigate to your home directory. For example, to navigate to your home directory, you would type cd
and press enter.
If you want to navigate to the parent directory of the current directory, you can use cd ..
. For example, if you’re currently in the /home/user/documents
directory, you can navigate to the parent directory (i.e. /home/user
) by typing cd ..
and press enter.
Additionally, you can use cd -
command to navigate to the previous directory you were in.
It’s worth mentioning that you can use the TAB key to auto-complete directories and file names.
pwd – print the current working directory
The pwd
(print working directory) command is used in Linux to display the current directory path.
To use the pwd
command, open a terminal window and type pwd
and press enter. This will display the full path of the current working directory you are in. For example, if you are currently in the /home/user/documents
directory, running the pwd
command will display /home/user/documents
in the terminal.
You can use pwd
command in any directory you want, it will always show the current directory you are in. It doesn’t take any arguments or options.
You can also use it in combination with other commands, for example, when you want to know in which directory you’re currently working and use that path as an argument to another command.
mkdir – create a new directory
The mkdir
(make directory) command is used in Linux to create new directories.
To use the mkdir
command, open a terminal window and type mkdir
followed by the name of the directory you want to create. For example, to create a new directory called myfolder
, you would type mkdir myfolder
and press enter. This will create a new directory named myfolder
in the current working directory.
You can also specify a path to create a directory in a specific location. For example, to create a directory called myfolder
in the /home/user/documents
directory, you would type mkdir /home/user/documents/myfolder
and press enter.
You can also create multiple directories at once by separating their names with a space, for example mkdir folder1 folder2 folder3
will create three directories.
You can also use the -p
option to create parent directories if they do not exist, for example, mkdir -p /home/user/documents/myfolder/myfiles
will create all the parent directories if they don’t exist.
It’s worth noting that if you try to create a directory that already exists, mkdir will return an error message unless you use the -p
option, in that case it will just skip creating the existing directories.
rm – remove a file or directory
The rm
(remove) command is used in Linux to delete files and directories.
To use the rm
command, open a terminal window and type rm
followed by the name of the file or directory you want to delete. For example, to delete a file called myfile.txt
in the current working directory, you would type rm myfile.txt
and press enter.
You can also specify a path to delete a file or directory in a specific location. For example, to delete a directory called myfolder
in the /home/user/documents
directory, you would type rm -r /home/user/documents/myfolder
and press enter. The -r
option is used to remove the directory and its contents recursively.
It’s worth noting that the rm
command is a dangerous command, because once a file or directory is deleted with rm
, it cannot be recovered easily.
For this reason, it’s recommended to use the -i
option which prompts you for confirmation before deleting each file. For example, rm -i myfile.txt
will ask you to confirm before deleting the file.
Another option you can use is -f
option, it will delete the files and directories without any confirmation. It’s not recommended to use this option, as it can lead to the accidental deletion of important files.
It’s also important to note that when you delete a directory using rm -r
command, it will delete all of its content recursively, which means all the files and subdirectories inside that directory will be deleted as well.
cp – copy a file or directory
The cp
(copy) command is used in Linux to copy files and directories.
To use the cp
command, open a terminal window and type cp
followed by the source file or directory and the destination. For example, to copy a file called myfile.txt
from the current working directory to a directory called myfolder
, you would type cp myfile.txt myfolder/
and press enter.
You can also specify a path for both the source file or directory and the destination. For example, to copy a directory called myfolder
from the /home/user/documents
directory to the /home/user/backup
directory, you would type cp -r /home/user/documents/myfolder /home/user/backup/
and press enter. The -r
option is used to copy the directory and its contents recursively.
Additionally, you can use the -p
option to preserve the file attributes like ownership, permissions and timestamps. The -v
option can also be used to display verbose output while copying.
It’s worth noting that if you try to copy a file or directory to a location where a file or directory with the same name already exist, the cp
command will overwrite it without any warning unless you use the -n
option that will not overwrite existing files.
Also, if you copy a directory using cp -r
command, it will copy the directory and all of its contents recursively, it means all the files and subdirectories inside that directory will be copied as well.

mv – move or rename a file or directory
The mv
(move) command is used in Linux to move or rename files and directories.
To use the mv
command to move a file, open a terminal window, and type mv
followed by the source file and the destination. For example, to move a file called myfile.txt
from the current working directory to a directory called myfolder
, you would type mv myfile.txt myfolder/
and press enter. This will move the file myfile.txt
from the current directory to the myfolder
directory.
To use the mv
command to rename a file, open a terminal window and type mv
followed by the source file and the new name. For example, to rename a file called myfile.txt
to newfile.txt
, you would type mv myfile.txt newfile.txt
and press enter.
You can also specify a path for both the source file or directory and the destination. For example, to move a directory called myfolder
from the /home/user/documents
directory to the /home/user/backup
directory, you would type mv /home/user/documents/myfolder /home/user/backup/
and press enter.
It’s worth noting that if you try to move a file or directory to a location where a file or directory with the same name already exists, the mv
command will overwrite it without any warning unless you use the -n
option that will not overwrite existing files.
Also, when you move a directory with mv
command, the directory and all its contents are moved to the new location. The original directory and its contents no longer exist in the original location after the move.
