15 Linux Commands Every User Must Know!

Vikram M.
featurepreneur
Published in
5 min readNov 11, 2022

Every command I list here has multiple options and several uses. If I try giving even the most common examples of each command, it will easily turn into a pocketbook of more than 10,000 words.

I will not go into detail with any of these commands. I’ll list the purpose of each command with its basic syntax.

1. ls command: List the content of a folder

This is among the first few commands a new Linux user learns. This command lets you see what files and folders are in your current folder.

ls

You can use the long listing option ls -l to see details like file size, permission, modified time, etc. You can sort and control these options if you want to.

ls -l

2. cd command: Change the directory

By default, you start in your home directory. You’ll often require to change the directory and move to another one.

For example, you downloaded a deb file or script. Now you want to run it. You can do that from your present working directory by providing the full path but switching to that location makes things easier.

The cd command stands for change directory; with this, you can change your location and move to another directory.

3. cat command: Read a text file

If you quickly want to see the contents of a text file in Linux, cat is the command you use. It displays the contents on the screen.

cat filename

4. touch command: Create new files

There are multiple ways of creating new files in the Linux terminal. The cat command you saw above can also create new files.

However, I prefer the touch command for this purpose.

touch new_file_name

5. mkdir command: Make new folders

While there is no specific command for creating new files, there is a dedicated command for making new folders (or directories, as we call them in Linux).

mkdir new_dir

6. mv command: Cut-paste or rename files and folders

The mv command stands for ‘move’. When you copy a file to another location, it remains in its original place.

The mv command moves the files and folders to the other location. You can think of it as a cut-paste operation.

mv file.txt /another/location

You can use the mv command to rename the file as well.

mv file.txt new_file.txt

The same mv command also moves or renames folders without any special options.

7. rm command: Remove files and folders

To delete files in the Linux terminal, you use the rm (short for remove) command.

rm filename

There is no undo option after you delete files in the command line. This is why you should be extremely careful while deleting files. If you are afraid of deleting the wrong file, use the interactive mode with option -i, which gives you an additional prompt to confirm the action.

8. clear: Clear terminal screen

Nano feels like a complicated one, right? Let me share a simple command.

The clear command clears the terminal. That’s it.

clear

And why do you need to do that? Well, if your terminal screen is flooded with random stuff and you want to do something new. Cleaning the terminal is like cleaning the board or opening a new page in your notebook.

9. ps: Check and handle processes

The ps command is for handling the processes running on your system. Each process has an associated ID called PID, which can be used for various purposes, such as terminating a process.

m8vikram:~$ ps
PID TTY TIME CMD
15358 ? 00:00:00 bash
15404 ? 00:00:00 ps

But a system cannot run just 2–3 processes, can it? To see all the processes running by all users, use:

ps aux

This will give a massive list of processes and more details about them. If you run this command, now will be an excellent time to use the clear command.

10. top: System monitor

While the ps command gives you all the running processes, the top command gives you a real-time view of the processes and the system resource consumption.

top

Consider it like the terminal variant of the task manager in Linux. You’ll see a lot of interesting details with the top command.

11. lsblk: List disks and partitions

The lsblk command lists all the block devices on your system. In really simple (and not entirely technically accurate) terms, it displays the disks and partitions.

root@m8v:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 79.9M 1 loop /snap/lxd/22923
loop1 7:1 0 103M 1 loop /snap/lxd/23541
loop2 7:2 0 63.2M 1 loop /snap/core20/1623
loop3 7:3 0 48M 1 loop /snap/snapd/17336
loop4 7:4 0 48M 1 loop /snap/snapd/17029
loop6 7:6 0 63.2M 1 loop /snap/core20/1634
vda 252:0 0 25G 0 disk
├─vda1 252:1 0 24.9G 0 part /
├─vda14 252:14 0 4M 0 part
└─vda15 252:15 0 106M 0 part /boot/efi
vdb 252:16 0 466K 1 disk
root@m8v:~#

12 .find: Search for files

Even as a desktop user, you’ll encounter cases where you may have to search for files in the Linux command line.

The find command is an extensive and versatile command for this purpose. It has more than fifty options, and you will probably never need all of them.

Here’s an example of the find command that will give you all the files that end with the .txt extension in the current directory.

find . -type f -name "*.txt"

13. grep: Search in file content

The find command search for files based on their name and type. If you want to search based on the content of the files, you use the grep command.

So, instead of looking for all files ending with .txt, you look for all files containing the text ‘foss’ with grep.

grep -ri search_term

14. kill: Terminate processes

sudo kill -9 process_ID_or_Name

As you can see in the above command, you need to know the process ID (PID) or the name to terminate it. You can use the ps or the top command to get the PID or exact process name.

ps aux | grep -i “hello world”

15. history: Look back into what commands you ran in the past

So, you used a specific Linux command a few days ago. Now you need to run it again, but you cannot recall it correctly.

You can press the up and down arrow keys.

That’s a familiar scenario for many Linux users; this is where the history command helps.

In Ubuntu, your shell keeps a history of the commands you run. Enter history in the terminal, and you should see a history of commands you ran in the past.

There is another way to access the command history and search it. Press Ctrl+R and then enter the search term.

--

--