Essential Linux Commands Every User Needs to Know

Amit Kumar
5 min readFeb 3, 2024

You know how you use your Linux system for cool stuff? Well, guess what? There are some special commands that you can use to make it cooler! It’s like having a secret code to tell your computer what to do. No worries, it’s not hard at all! In this guide, you’ll learn some simple commands that every Linux user should know.

  1. ls command: It allows you to list the content of directory you want, including files and other directories.
ls --color=auto

2. alias command: It lets you define temporary aliases in their shell session. For example to set ls to have color without typing the — color flag every time, you would use:

alias ls="ls --color=auto"

3. unalias command: It is used to remove an alias from the already defined aliases. For example to remove the ls alias, you can use:

unalias ls

4. pwd command: It stands for “print working directory” and it outputs the absolute path of the directory in which you are currently in.

pwd

5. cd command: It stands for “change directory” and it is used to switch to a different directory. For example, if you are inside Desktop directory and you are trying to access a subfolder called Images, then you can use the command:

cd Images

In order to use the absolute path of the folder, you can use:

cd /home/user/Desktop/Images

In order to move to the home folder, you can use:

cd

In order to move a level up, you can use:

cd ..

In order to move to the previous directory, you can use:

cd -

6. cp command: This command is used to copy files and folders directly in the Linux terminal. To use the cp command, you can use:

cp file_to_copy.txt new_file.txt

You can copy entire directory using the command:

cp -r dir_to_copy/ new_copy_dir/

7. rm command: It is used to remove files and directories.

To delete a file, you’d type:

rm file_name.txt

You have to use the recursive (-r) flag, in order to delete an empty directory.

rm -r dir_to_remove/

If you want to remove a directory with content inside of it, you need to use the force and recursive flags (-rf).

rm -rf dir_to_remove/

8. mv command: You can use the mv command to move files or directories through the file system.

mv source_file.txt destination_folder/

You can also use mv command to rename any file or folder.

mv old_name.txt new_name.txt

9. mkdir command: You can use mkdir command in order to create a directory. In order to create a directory named images, you can type:

mkdir images/

In order to create a subdirectory, you can use the parent (-p) flag:

mkdir -p images/sub_dir

10. man command: It is used to display the manual page of any other command. To see the manual page of the mkdir command, you can type:

man mkdir

11. touch command: It allows you to update the access and modification times of the files. In order to change the modification date of any file to the current time, you can use the -m flag:

touch -m file_name

You can also use the touch command to create new empty files:

touch new_file_name

12. chmod command: The chmod command lets you change the permissions of a file.

The basic permissions a file can have are:

a. r(read) b. w(write) c. x(execute)

In order to make a file executable, you can type:

chmod +x file_name

Similarly, you can give read and write permissions to a file.

13. exit command: It is used to end a shell session and in most cases, it automatically close the terminal you’re using.

exit

14. sudo command: This command stands for “superuser do”. It lets you act as a superuser or root user while you are running a command. It’s how Linux protects itself from the user who can accidently modify the machine’s filesystem.

It is commonly used to install software or to edit files outside the user’s home directory.

sudo apt install docker
sudo cd /root/

15. shutdown command: It is used to power off your computer immediately. The default value is one minute.

shutdown now

You can also schedule to turn off your system in a 24-hour format:

shutdown 21:15

To cancel any previous shutdown call, you can use the -c flag:

shutdown -c

16. htop command: It is used to view the interactive processes and lets you manage your machine’s resources through terminal.

htop

17. echo command: It used to display defined text in the terminal.

echo "Hello World!!"

It is also used to print environmental variables inside those messages. For example, in order to display the name of the user, you can use:

echo "Hey $USER"

18. cat command: It is used to create, view and concatenate files directly from the terminal.

In order to display the content of the file, you can use:

cat file_name

In order to create a new file, you can use:

cat > file_name

In order to copy the content of one file to another, you can use:

cat old_file > new_file

In order to concatenate the content of multiple files into one, one can use:

cat [file1 file2 file3] > new_file

19. ps command: With ps command, you can take look at the processes your current shell session is running. It prints the useful information about the programs you’re running like process id, TTY, time and command name.

ps

20. kill command: It is used to kill the processes by entering either the process id or the program’s binary name:

kill 232412
kill name_of_program

21. ping command: The ping command has many options, but in most cases, you’ll use it to request a domain or IP address:

ping google.com
ping 10.0.0.1

22. history command: It is used to display an enumerated list with commands you’ve used in the past.

history

23. passwd command: It allows you to change the password of user accounts. First, it prompts you to enter your current password, then lets you create new password and confirm.

passwd

24. whoami command: It displays the username currently in use:

whoami

25. find command: The find command searches for files in a directory hierarchy based on a regex expression. The syntax to use the find command:

find [flags] [path] -name [expression]

To search for a file named new_file.txt in the current directory, you can use:

find ./ -name "long.txt"

To search for files that ends with a .txt extension, you can use the following command:

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

26. apt, yum, pacman commands: You can access these package managers through the command line, and you can use these package managers to install, update, and remove the software on your machine.

You would use one or another depending on the distro your machine is running.

Debian-based: Linux Mint, Ubuntu

sudo apt install docker

Red Hat-based: CentOS, Fedora

sudo yum install docker

Arch-based: Arco Linux, Manjaro

sudo pacman -S docker

And there you have it! You’ve just learned some cool commands to make your computer do exactly what you want with Linux. It might seem a bit like magic, but it’s all about typing a few special words in the right order. Now, you can organize your files, create folders, and do other awesome stuff without even clicking your mouse too much.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Amit Kumar
Amit Kumar

Written by Amit Kumar

🚀 BTech student diving into code and tech wonders. Exploring the digital realm, one line at a time. Join me on this tech journey! 💻✨ #TechExplorer

No responses yet

Write a response