Linux Commands PDF
Linux Commands PDF
Linux is a family of open-source Unix operating systems based on the Linux Kernel. They include Ubuntu,
Fedora, Debian, openSUSE, and Red Hat. Using Linux to manage a Virtual Private Server (VPS) is common
practice.
When operating Linux, you need to use a shell – a program that gives you access to the operating system’s
services. Most Linux distributions use a graphical user interface (GUI), making them beginner-friendly.
However, we recommend utilizing the command-line interface (CLI) because it’s quicker and offers more
control. Tasks that require multiple steps on the GUI can be done in a matter of seconds by entering
commands into the CLI.
So if you want to use Linux, learning the common utilities or commands will go a long way. This article will
discuss the 40 basic commands to help you use your Linux distro effectively.
• What Is a Linux Command?
• The 40 Most Commonly Used Linux Commands
• Bonus Tips and Tricks
• Download a Free Linux Commands Cheat Sheet
• Linux Commands FAQ
• What Is the Basic Command of Linux?
• How Many Commands Does Linux Have?
5. cat command
Concatenate, or cat, is one of the most frequently used Linux commands. It lists, combines, and
writes file content to the standard output. To run the cat command, type cat followed by the file
name and its extension. For instance:
cat filename.txt.
Here are other ways to use the cat command:
• cat > filename.txt creates a new file.
• cat filename1.txt filename2.txt > filename3.txt merges filename1.txt and filename2.txt and
stores the output in filename3.txt.
• tac filename.txt displays content in reverse order.
6. cp command
Use the cp command to copy files or directories and their content. Take a look at the following use
cases.
To copy one file from the current directory to another, enter cp followed by the file name and the
destination directory. For example:
cp filename.txt /home/username/Documents
To copy files to a directory, enter the file names followed by the destination directory:
cp filename1.txt filename2.txt filename3.txt /home/username/Documents
To copy the content of a file to a new file in the same directory, enter cp followed by the source file
and the destination file:
cp filename1.txt filename2.txt
To copy an entire directory, pass the -R flag before typing the source directory, followed by the
destination directory:
cp -R /home/username/Documents /home/username/Documents_backup
7. mv command
The primary use of the mv command is to move and rename files and directories. Additionally, it
doesn’t produce an output upon execution.
Simply type mv followed by the filename and the destination directory. For example, you want to
move filename.txt to the /home/username/Documents directory:
mv filename.txt /home/username/Documents.
You can also use the mv command to rename a file:
mv old_filename.txt new_filename.txt
8. mkdir command
Use the mkdir command to create one or multiple directories at once and set permissions for each of
them. The user executing this command must have the privilege to make a new folder in the parent
directory, or they may receive a permission denied error.
Here’s the basic syntax:
mkdir [option] directory_name
For example, you want to create a directory called Music:
mkdir Music
To make a new directory called Songs inside Music, use this command:
mkdir Music/Songs
The mkdir command accepts many options, such as:
• -p or –parents create a directory between two existing folders. For example, mkdir -p
Music/2020/Songs will make the new “2020” directory.
• -m sets the file permissions. For instance, to create a directory with full read, write, and
execute permissions for all users, enter mkdir -m777 directory_name.
• -v prints a message for each created directory. 9. rmdir command
To permanently delete an empty directory, use the rmdir command. Remember that the user running
this command should have sudo privileges in the parent directory.
For example, you want to remove an empty subdirectory named personal1 and its main folder mydir:
rmdir -p mydir/personal1 10. rm command
The rm command is used to delete files within a directory. Make sure that the user performing this
command has write permissions.
Remember the directory’s location as this will remove the file(s) and you can’t undo it.
Here’s the general syntax:
rm filename.To remove multiple files, enter the following command:
rm filename1 filename2 filename3
Here are some acceptable options you can add:
• -i prompts system confirmation before deleting a file.
• -f allows the system to remove without a confirmation.
• -r deletes files and directories recursively.
Expert Tip
Did you know that you can edit a text file with Linux commands using SSH? Instead of editing a file locally and
uploading it via FTP, you can edit the file instantly on your account using the vim or nano command.
Learning basic Linux commands is essential to interact with your machine, primarily if you use a Virtual Private
Server (VPS). In most cases, each utility consists of three parts – a command name, a flag or option, and a parameter
or argument.
This article has discussed 40 common commands, such as apt-get to install a package, nano to manipulate a file,
htop to monitor current processes, and ls to view a directory.
We hope this article has helped you learn the basic Linux commands. If you have any questions or suggestions,
please leave them in the comments section below.