There are thousands of commands that you can learn to use on a Linux system, but most users will find themselves executing the same few commands over and over. For users looking for a way to get started, we have compiled 20 of the most important Linux commands you need to know. These commands are some of the most useful, common, and essential tools that you will need in order to administer your Linux system or perform everyday tasks.
Every Linux distro has inherent access to a terminal, though the interface may look different depending on your desktop environment or configuration. Join us in this tutorial to learn about the 20 most important Linux commands. By the end, you will know enough to begin navigating your Linux terminal.
In this tutorial you will learn:
- Top 20 most important Linux commands you need to know
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Linux commands: Top 20 most important commands you need to know
While any list of the most important commands on Linux will be somewhat subjective, we feel that commands related to file system navigation, process monitoring, networking, user management, and package installation should make the list for the top essential commands. Check the list below for our compiled list of the most important commands in these categories.
One of the most essential commands in Linux is the change directory command or
cd command. This is how you will navigate to different directories throughout your system. Using this command will change your current working directory to a different one you specify.
Navigate to any directory with the following syntax:
$ cd /path/to/directory
Or navigate to your user’s home directory:
See more: cd command in Linux with examples
The mv command in Linux is short for move. As you can probably guess or may already know, the command is used to move files and directories from one location to the other. Users that are more accustomed to a GUI might know this action better as “cutting and pasting.” The
mv command is just the command line equivalent of that action.
Move a file to a different directory:
$ mv /home/linuxconfig/Downloads/linux.iso /home/linuxconfig/Desktop
mv command can also rename files:
$ mv old-name new-name
See more: mv command in Linux with examples
ls is short for list, and is used to list the files in your present working directory or some other directory if you specify one. What makes
ls so essential is that it allows you to see what files are in a directory. You’ll be using it constantly to list directory contents.
It is common to use it with no further options in order to show what’s in your present working directory:
To get a list format, with one file per line, add the
$ ls -l
See more: ls command in Linux with examples
cat command in Linux is our primary tool for viewing the contents of text files. Whether we are talking about Linux log files or configuration files, they are all simple ASCII text files. Therefore, the skills to be able to read the content of such text files is imperative.
You will most commonly use the
cat command to read the contents of a particular file:
$ cat file.txt
See more: Cat command in Linux with examples
One of the most basic commands in Linux is the
cp or copy command. The most basic way to use this command is to copy a file or multiple files. The
cp command is one of the first commands you should learn as a newcomer to Linux, as copying files and directories is something you’ll do often.
$ cp file01 file01-copy
See more: cp command in Linux with examples
rm command is one of the most common and basic commands in Linux. Even if you have a limited amount of experience with Linux, you’ve most likely heard of it. The main purpose of this command is to remove files and directories. Using this command to remove files and directories cannot be undone.
rm to delete a file by following the command with the name of the file:
$ rm file.txt
You will need to use the
-r option when deleting a directory.
$ rm -r directory01
See more: rm command in Linux with examples
If you need to search for one or more particular files or directories, the
find command in Linux is the perfect tool for the job. The
find command can search for a file with a specific name, but you can also search for files that follow certain naming patterns. This can be broadened all the way to finding files based on file size, file extension, or a lot of other options.
Most basic syntax:
$ find . -name "example.txt"
A plethora of other options exist, in order to search for specific naming patterns. See more: find command in Linux with examples
On a Linux system, the need to search one or multiple files for a specific text string can arise quite often. On the command line, the
grep command has this function covered very well.
To search a file for a text string, use the following command syntax:
$ grep string filename
See also: How to find a string or text in a file on Linux
The nano editor is one of the most popular ways to edit files via the command line on Linux systems. There are plenty of others, like vim and emacs, but nano is praised for its ease of use.
Open a file for editing by specifying the name after the
$ nano file-name
See also: How to save and exit file using nano editor in Linux
echo command can be used to read variables and direct output. It is especially common to use
echo inside of Bash scripts.
$ echo "some text" > file.txt $ echo "Hello World" $ echo $variable
See also: Bash Scripting Tutorial for Beginners
touch command in Linux is used to alter the access and modification times for a given file or set of files. It’s also a super handy way to create an empty file very quickly, if you are running the
touch command and specify a file that doesn’t already exist.
The syntax is very simple – just specify the file name you wish to create or update the modification time for:
$ touch document.txt
See also: touch command in Linux with examples
One of the most common and fundamental commands in Linux is the
mkdir command. The most basic way to use this command is to create one or multiple directories.
Just specify one or more directories you wish to create:
$ mkdir directory01
See also: mkdir command in Linux with examples
A great way to check the current CPU usage is with the
top command. A lot of the output from this command is rather complex, but it gives very granular information about how the CPU is being utilized on a system.
See also: How to Check and Monitor CPU utilization on Linux
ps command is a default command line utility that can give us insight into the processes that are currently running on a Linux system. It can give us a lot of helpful information about these processes, including their PID (process ID), TTY, the user running a command or application, and more.
Typical syntax includes the
$ ps aux $ ps -ef
See also: How to use ps command in Linux: Beginners guide
wget command is used to retrieve content from servers via HTTP, HTTPS, and FTP. It simplifies many downloading tasks that you’d normally have to do yourself by perusing a website and manually clicking links to download. Wget is able to perform the same function from the command line and has a lot of added abilities that can save you time, such as downloading directories recursively.
The most basic command you can execute with wget is just supplying the URL of the file you wish to download.
$ wget http://example.com/linux.iso
See also: Wget file download on Linux
Nearly every Linux distribution these days uses the
sudo utility as a way to grant non-privileged users the ability to execute commands as privileged root users. Sudo allows users to run programs with the authorization privileges of another user by supplying their own password for authentication.
The syntax is to precede a command with
$ sudo whoami root
pwd command in Linux is short for present working directory. When it comes to Linux commands, this has to be one of the simplest. It’s only function is to print the present working directory of your terminal. It comes in handy when you’re not exactly sure what directory you’re in, or when you need to pass the present working directory inside of a Bash script, for example.
The syntax requires no further options:
See also: pwd command in Linux with examples
ip command is the main networking tool you will use on Linux. It can be used to view current network configuration, set a new IP address, subnet mask, and route, as well as enable or disable network interfaces, among other things.
One of the most common uses is to view your system’s current IP address:
$ ip a
passwd command sets the password for a user account. This will be essential for Linux administrators whenever they make new accounts, or for users that need to set a new password.
Set your own password:
Set the password for a different account:
$ sudo passwd user
apt / dnf / pacman
In order to install new software packages from the command line, you will need to use the system’s built in package manager. This command will vary depending on your Linux distro.
- Ubuntu and Debian based:
- Fedora and Red Hat based:
- Arch Linux and Manjaro:
To install a package:
$ sudo apt install package-name $ sudo dnf install package-name $ sudo pacman -S package-name
See also: Comparison of major Linux package management systems
In this tutorial, we learned about the 20 most important commands you need to know on a Linux system. The commands in our list are everyday commands that all users should know, and cover a wide array of tasks, such as file system navigation, process monitoring, file reading and manipulation, networking, user management, and package installation. These commands will be enough to get you started, but there are lots more to learn!