top 25 linux command that every developer should know

Linux is a Unix-like, open-source, and community-developed operating system for computers, servers, mainframe computers, and embedded devices. It is supported on almost every major computer platform which makes it one of the most widely supported operating systems.

Most the people think Linux is a very complicated operating system in general use or it's only for programmers because people are afraid of command line arguments (CLI).

In general using of a command-line interface is more powerful and effective. Tasks that require a multi-step process through GUI can be done in a matter of seconds by typing commands into the CLI.

Anyone is thinking about using Linux or any other Linux distribution like Ubuntu, CentOS, or Fedora. They must know some basic or command commands of Linux which help them to perform daily operations. Below are basic commands and their use :

1. pwd command

pwd command is a built-in command which prints the full path of working directory from root. PWD stands for Print Working Directory. i.e. /home/username

pwd command has 2 flags :

  1. pwd -L: Prints the symbolic path.
  2. pwd -P: Prints the actual path.

2. ls Command

The ls command is used to view the contents of a directory. By default, it will use the current working directory. You can also pass other directory path as parameters. The ls command is slimier than Dir command in Windows.

There are few variations for ls command :

  1. ls -R : It will list all files and folders.
  2. ls -a: It will list all hidden files.
  3. ls -al: It will list files directly with other information like permission, file size, and more.

3. cd Command

The cd command is used to navigate through directories and files in CLI. This command requires pass as parameter which can be full path or directory name based on your working directory.

There are some shortcuts to help you to use cd command effectively :

  1. cd .. : It will move one directory up.
  2. cd : It will take you straight to the home folder.
  3. cd- : It will take you to previous directory

4. cat command

The cat (concatenate) is one of the most conmanly used commands. It is used to list the contents of a file on the standard output. It's also used to create new file.

This command require file name with it's extension as parameter. i.e. cat file.txt.

To create a new file with cat command you can use this example: cat > file.txt.

It can also used for join two files. i.e. cat filename1 filename2>filename3

5. cp command

The cp command is used to copy files from one directory to another. For example, the command cp text.txt /home/username/myfiles will copy file to myfiles directory.

6. mv command

The mv command is used to move files from one directory to another. We can also use mv command to rename files.

The use of mv command is similar to cp command. For example mv file.txt /home/username. To use mv command to rename file, we need to pass new file name as second flag like this : mv file.txt file1.txt.

7. grep command

Find text in a file. The grep command searches through many files at a time to find a piece of text you are looking for. i.e. grep 'search_term' file.txt. It will search file and returns details about search result.

8. sudo command

Sometimes there is a need to specify rights to perform some actions like installing applications you need to System Administrator rights. When you give any commands with sudo command then it will perform that task with high priority and as super admin.

For example, you have logged in from a general user who doesn't have the right to perform application installation. But with sudo command, you can perform that task.

sudo apt-get install package_name

9. shutdown Command

As per the name shutdown, the command suggests powering off system. But with the shutdown command, you can perform a delay into shutdown or reboot the system as per your requirements.

Below are some examples of shutdown commands:

shutdown now

//Shutdown at specific time
shutdown 15:44

//cancel previous shutdown
shutdown -c

//To reboot system
sudo shutdown -r now

10 mkdir command

While working with files, sometimes we need to create directories. you can create a directory/folder using mkdir command. mkdir stands for make directory.

Here we just need to pass the directory name as a parameter like below example :

mkdir test

11. rm command

The rm command is used for removing files and directories from our system. You need to be careful while using this command because it’s very difficult to recover files deleted this way.

Below are some examples of the rm command :

rm test.txt

//remove directory
rm -r test/

//remove directory with it's content forcefully
rm -rf test/

12. man command

The man command displays manual information about another command like help with that command. To see the manual information about any command you need to pass the command name as a parameter like below:

man man
man rm

13. touch command

The touch command allows you to create a blank new file through the Linux command line. The touch command is also used for updating the timestamp information of file.

touch text.txt
touch -m text.txt

14. chmod command

The chmod command allows you to change file permissions. It has lots of sub-options available but basic permissions are read, writes and execute.

One of the most common uses of chmod is to make a file executable by the user. To do that you need to use +x flag.

chmod +x text

15. exit command

The exit command works as per the name, it will end the shell session of your terminal and automatically closes the current terminal.

16. locate command

The locate command works just like the window's search command. It will search files on system. By default it's case-sensitive but you can pass -i to make it case-insensitive. i.e. locate -i test will search file with test in it's name.

17. unzip command

This command will help you to unzip files with zip format. This package is not pre-installed so make sure you have installed it before using it.

Below is example command to unzip file :


apt, yum, pacman command

In Linux package managers are used to install or uninstall packages. So at some point of work, you need to use those package managers. Generally, package managers are based on Linux distribution.

Debian-based systems like ubuntu or Linux-mint use apt by default. Whereas in Fedora or CentOS, yum is used for installation. while in Arch-based systems like Arco linux or Manjaro use pacman as their package manager.

Below are some examples of installing gimp on different Linux distributions:

sudo apt install gimp
sudo yum install gimp
sudo pacman -S gimp

18. echo command

The echo command prints text into terminal. The primary use of echo is to print environment variables but we can use it as per our requirement like showing some information while the shell script is running.

19. kill command

Generally using system with low configuration some programs become in-responsive and can not be closed by GUI. Then we can forcefully close it's process with kill command.

In simple words kill command send specific program close request to system. Here we can use PID (process ID) or program's binary name.

20. ping command

The ping is the most popular networking terminal utility used to test network connectivity. ping has a ton of options, but in most cases, you’ll use it to request a domain or IP address.

The ping command accepts either an IP address or domain name of a particular server or website. like below example


21. diff command

As per the name suggest diff stands for the difference. The diff command is used for check the difference between two file. Here it will take two full name of file as parameter. i.e. diff text1.txt text2.txt.

The diff command will compare both files line by line and print lines that do not match.

22. chown command

In Linux, all files are owned by a specific user. The chown command enables you to change or transfer the ownership of a file to the specified username. For example, chown user_name text.txt will transfer text file ownership to a given user.

23. wget command

If you are downloading lots of content from the internet then wget command is very useful. The wget command take url as parameter and download content from that user. Generally it's used to download softwares.

24. whoami command

The whoami command displays the username currently in use.

25. useradd, userdel command

Linux is a multi-user system and sometimes more than one person is using the same system. With useradd and userdel command user access become simpler.

The useradd command is used for adding user to system. While userdel command is used for deleting an existing user from the system. The both commands useradd and userdel need user name as parameter.

Tips and tricks

  • To clear terminal use clear command.
  • TAB can be used for auto-fill data while writing.
  • To stop the currently executing script, you can use either ctrl+C or ctrl+Z. It will automatically stop command execution.
  • You can run multiple commands using a semi-colon(;).