In the following article we are going to explore the top 10 linux commands of all time. Linux feels so powerful because it gives you the ability to manipulate virtually everything from the command line. And command line or a terminal is way faster than doing the something from the conventional Graphical user interface (at least when you get used to it).

I have a rule of mine which I tell anyone who asks me about how I am so fast with the terminal. The rule is applicable if you’re a beginner or you’re an expert and is very simple to implement. It goes as follows:

Whatever you want to do in a unix system, try doing it first from the command line.

What it means is, suppose you want to search for a file in your home directory, instead of opening up a new Finder/Explorer window, just fire up a terminal and use that instead. At first, you won’t know what commands to use, so you’ll have to Google the most basic stuff. Spend at least one minute googling about the task you want to accomplish. Get the relevant command, spend 20 seconds reading the command and looking at the options along with the command. Once you make this a habit, you’ll be able to do any task from the terminal with a 10x speed compared to doing the same via GUI. That’s enough of free advice for a day, so let’s dive straight into it. Here’s the list of top 10 most used linux commands.

The man command

This is one of the most underrated commands out of the top 10 linux commands listed here in this article, that’s the reason we’ve given it the first place here. The man command is used to display the manual pages for other commands/programs installed in the system. The command takes the name of a manual page as an argument which is usually the name of the command itself. This command is extremely useful regardless whether you’re an expert or a beginner. You’ll have to refer to the manual pages sooner rather than later, even if it’s just to verify and check the command arguments and their respective meanings.

1. General commands
2. System calls
3. C library functions
4. Special files (usually devices, those found in /dev) and drivers
5. File formats and conventions
6. Games and screensavers
7. Miscellaneous
8. System administration commands and daemons

Examples for the man command:
# Displays the manual pages for the program ssh 
man ssh
# Displays the manual pages for grep
man grep

If the manual page is present in more than one section, you can specify the section as follows:

# Replace SECTION with section number. 
man SECTION ssh

# Looking up a manual page in section 8 for the command shutdown
man 8 shutdown

Another example, looking up printf using the whatis command, we see it has multiple related entries in different sections.

whatis printf
# Output:
# printf(1)                - formatted output
# xprintf(5)               - extensible printf (END)

# To open up the manual page in the General Commands section do:
man 1 printf

The ssh command

ssh stands for Secure Shell, this command is used to log into remote machines via the terminal / command line. ssh is a really interesting protocol, if you’re curious to know about how the login process and the handshaking actually works, read further here.

ssh command examples:

For login to a remote machine using the username, password and the IP Address of the machine. If you have not setup public key authentication, the above command will ask for a password. For security reasons the password will not be visible to you while you type. Once you’ve entered the correct password just hit the enter/return key to continue.

ssh username@ 

# If you’ve mapped your domain to an IP, use the following instead.

By default ssh tries to login using all the private keys present in memory (you can add a key to memory by using ssh-add path/to/keyfile command). But if you’re too lazy to do that, you can specify the key to be used in the ssh command itself with the help of -i option.
Please note: Public key cryptography is highly secure when compared to login with password. I would any day recommend you to turn off the password authentication the first time you log into a machine and using the key pairs to login.

ssh -i /location/to/private/keyfile username@ 

If for some reason, you’re unable to connect to a remote machine, use the debug switch to print verbose logs for the ssh handshaking procedure.

ssh -v

If you’re interested in checking out other options the ssh command provides, just fire up a terminal and check out the manual page for ssh.

The ls cd and pwd commands

These are by far the most used commands on a linux system, their simplicity makes them stand out. They’re simply used to list and navigate the contents of a directory.
ls command lists the contents of a directory. The cd command is used to change the working directory to the specified directory/path. Similarly, the pwd command just outputs the present working directory of your terminal.

Example for ls command:
# Lists all the files and directories in the current directory, including all hidden files and directories. 
ls -a

# Same as above, but output is in form of a list.
ls -al

# Sort the list with modified time.
ls -alt

# Sort the list with time in reverse order.
ls -alrt
Examples for cd command:
# Change the working directory to the path '/etc/nginx'. 
cd /etc/nginx

# Navigate to the path in steps.
cd /etc/
cd nginx
Examples of pwd command:
# output: /etc/nginx

The su command

su stands for ‘substitute user identity’, it is used to switch users on a unix system. Suppose we have two users on a system, Nick and Jonas. You’re currently logged in as Nick so you have access to all the files for the user Nick. Suppose you want to access something in Jonas’ directory, but the user Nick does not have the permission to do so. You can switch the current user to Jonas in order to access the files in Jonas‘ directory. This command requires to be executed as a super user (as an admin in simpler terms). 

Substituting user with su example:
# Current user is nick, and when you run the following command, your user should change to jonas

# outputs-> nick

sudo su jonas


# outputs-> jonas
# Now you should be able to access everything jonas owns and has the permission to read, write and execute.

The export command

Another very important command is the export command, using this command you can read and write environment variable for your current profile. export command can be used to view or edit all the set environment variables (like for example JAVA_HOME, M2_HOME or the famous PATH variable).

# View all the set environment variables. 

# Filter the variables containing JAVA 
export | grep JAVA

# Filter the variables containing the string ‘PATH'
export | grep PATH

The export command can be used to add or edit the variables in the following manner:

# Please note, there is no space around the equal-to sign. 
# Adding a space before the single quote is wrong and will most likely throw an error.
export JAVA_HOME='/usr/local/java-current/jdk1 .8.0_75 /jre'
export M2_HOME='~/.m2/'

The reboot and shutdown commands

As the name suggests the reboot command is used to restart the operating system. A immediate termination (SIGTERM followed by SIGKILL) is sent to all the currently running processes. This command usually requires super user access to the system, so this needs to be run using sudo if you’re not currently logged in as the root user.

# restart the system. 
sudo reboot

On the other hand if you just want to shutdown the system, without rebooting, the `shutdown` command can be used instead. `shutdown` command is used to power off a system at a given time.

Examples of the shutdown command:
# shutdown the system now 
shutdown -h now

# shutdown the system in 30 minutes
shutdown -h +30

# shutdown system and display a warning message to all the logged in users. shutdown -h +10 The system will shutdown in T-10 Minutes. 

# shutdown command can also be used to reboot the system
shutdown -r -h +10 

The kill command

This is one of the best tools in the linux arsenal. If a program or a process is unresponsive and you just want to exit it? No worries, just find the Process Id (PID) of the process using ps and send a SIGKILL (9) signal to the process using the kill command. And the good part is, this is non-ignorable kill signal, that is the process can not catch or ignore the SIGKILL signal. Or maybe, you’re in a good mood and you just want to ask the process to politely kill itself, you can send a SIGTERM (15) to the process. A SIGTERM is equivalent to pressing the close button on a window of a running process (it can be ignored by a bad process).

List of signals:      
1       HUP (hang up)      
2       INT (interrupt)      
3       QUIT (quit)      
6       ABRT (abort)     
 9      KILL (non-catchable, non-ignorable kill)     
14      ALRM (alarm clock)      
15      TERM (software termination signal)

Examples of the `kill` command:
# Suppose the process Evernote is not responding and you just want to kill it. 
# First we need to find its PID, the following command is used to find the PID of the unresponsive process.
# This command outputs a list of all the running processes which contain the word ‘evernote’.
# PID of a process is usually the second column of this output.

ps -ef | grep -i "Evernote”

# Once we’ve found the PID (let’s suppose it’s 54355), kill the process using the SIGKILL signal.

kill -9 54355

# Or if the program is responding just fine, but you’re a lazy ass to do it via GUI, just send a SIGTERM.
# it’s equivalent to pressing the close button.

kill -15 54355

# You can verify that the process was actually killed by running the ps command again.

This concludes our list of top 10 linux commands. I hope the article was helpful and you’ll use the command line more often. But beware, once you start using the terminal, GUI will feel so much slower and it’ll be equally hard to go back to GUI.