Learning new things can be overwhelming and the Linux terminal is no exception. When it comes to mastering the command-line terminal, the key is to understand the underlying concepts rather than memorizing commands.

Most commands in Linux are well documented and to really understand them well all you need is the command terminal itself.

This guide takes a look at some of the most important Linux commands that will help you to get help on Linux Commands from the command-line and to enhance your learning on your way to mastering Linux commands.

Why Use the Command-Line?

If you are used to using Graphical User Interfaces (GUI), you might be wondering: why should I use the command-line if I can access everything in the GUI? The truth is that the command-line gives you more control and flexibility to change or manage your system.

Take for example the task of adding a new user to the system, this is the GUI interface that you are provided with.

user interface for adding a user in Linux

If you were to do the same task using the command-line, you could use the following command.

         sudo useradd muo -p Azb3tDEM,aH8
    

A very simple command that can easily be automated. Plus, you can add more options as you create the user like set the expiry date for the password, add the user group, or set the default home directory of the user, etc.

The other advantage is that you can use the same command on any Linux distro, and even other operating systems like Mac OS and Unix. Meanwhile, the GUI implementation will be different between the different Linux distros or operating systems.

1. Apropos

There are many Linux commands and you possibly can't recall all of them. If you do not know what command to use for a certain task, the apropos command is your friend.

Let's assume you want to copy a file but do not know which command to use. Simply use the apropos command followed by the task you want to complete.

To check copy commands, use

         apropos copy
    

Apropos will list several commands that match the keyword you used. The list includes a short description of what the command does. From the output below, the highlighted command is what you are looking for to copy files or directories.

The word apropos is derived from the French word "à propos" which means "about."

apropos copy command

The apropos command works by looking through the entire description sections of the man pages for the matching keyword you provide with the apropos command.

2. Man

Now that you are able to find a command to use for a specific task. You can learn more about the command and its options using the man pages.

The Manual Pager Utility displays the manual pages for the program you are looking for. Man pages are comprehensive and well organized. They are the go-to place when it comes to understanding and learning more about commands and their options or arguments.

Man pages are organized into sections.

The sections may vary depending on the author of the man pages but here are some of the most common sections that you will come across.

  • Name: The name of the command whose manual documents you are looking at.
  • Synopsis: Give a brief description of some of the options for the command in question.
  • Description: A more detailed description of the command including how it works, and what it does.
  • Options: This section describes in detail all the arguments or options you can use with the command.
  • Examples (Tips): This section shows you a few use cases and how the command can be used.

The man pages for the cp command will look as follows.

man pages of the cp command in linux

The man pages can be pretty long. To easily navigate the man pages without leaving the keyboard, you can use the f key to go forward and the b key to go backward.

You can also search for keywords within the man pages by using the /[keyword] followed by pressing the enter button.

For example, to search for the word recursive within the man pages of the cp command you can use the following.

        /recursive
    

Use the n key on your keyboard to navigate forward in the search and the Shift + n key to search backward.

3. Whatis

Another important command to learn more about a specific command is the whatis command. The command gives you a brief description of a command in one line.

For example, to find out what the rsync command is used for:

         whatis rsync
    
terminal of the whatis command on rsync

4. Info

Like the man pages, the info pages also give you a detailed description of a specific command. In some cases, the info pages contain more details than the man pages.

The info utility provides you with the ability to read the documentation in Info format.

        info info
    

Use the n key on your keyboard to navigate forward in the info pages and the p key to navigate backward.

Another unique feature of the info pages is that they contain hyperlinks to other sections for easy navigation as seen in the output below.

Info pages in the Linux terminal

5 . Which

Most Linux commands reside in the /usr/bin/ directory.

But in case you want to find out where the executable of a particular command resides, you can use the which command. The command works by searching all paths for the executable files matching the command keyword that you are looking for. For example, to find out where the SSH utility resides, you can run the following command.

        which ssh
    

6. Help

Another useful utility for getting help on the command-line is the help command. Use it to get a brief description of a specific built-in command.

Here is sample output from the Help command. Note: Only built-in commands can be used with the help command.

getting help on the exit command in the linux terminal

The help command only works with the bash shell.

The Help Argument

Most Linux commands also have the --help command argument or option. You can use it to display helpful information about how a command is used and its arguments in a simplified manner.

For example, get more help on the cp command you can use.

         cp --help
    

7. Recalling Commands

The Linux terminal allows you to list commands that you have run earlier. Use the history command to show a list of previously run commands.

        history
    

It lists all commands in chronological order from the oldest to the latest with a corresponding number.

history command in the Linux terminal

To re-run a command from the history list simply type ! followed by the number of the command. For example to re-run the command number 9 in the list.

         !9
    

Another way to recall commands is to use the Ctrl + R keyboard shortcut within the terminal window then enter the keyword you are looking for. You can then use the CTRL + R to cycle through all previously run commands containing the keyword you provided.

Learning More About Linux

The command-line is not only a great utility to get your work done but also to get help about the different commands available on Linux. Apart from the command-line terminal, you can always use online resources to learn more about Linux.