Linux Command Help / Help Commands


In this post I’ll be talking about getting help for commands in Linux i.e the various methods of getting to know what a command does using several help commands in Linux.

So the first and most straightforward way to get help is using the “–help” option along with the command.

Usage

user@system-name:~$command-name –help

Say you need to find out what options are available for the “ls” command.

You would have to type the following in the Terminal.

Example:

user@system-name:~$ ls –help

You then get a list of all the options that can be used with the “ls” commnd like “–a” , “–l” etc along with a line explaining what each of the options are used for.

Please note that there are two hyphens(–) before the “help” option.

I strongly recommend trying out these commands in the Terminal if you are a newbie and planning to learn using the shell commands.

Next we have the “man” command. This command is used as an interface to access the reference manual of the required command. So it is a very detailed and comprehensive description of everything that the command can do.

Once the manual of a required command is opened using the “man” command, the manual spans several pages usually. So to traverse through the pages use the “Page Up” and “Page Down” keys or the “Up” and “Down” arrow keys.

To quit the manual and come back to the shell prompt hit the “Q” key on the keyboard.

Usage

user@system-name:~$man command-name

For example to know about the “ls” command

Example

user@system-name:~$man ls

 

We then have the “info” command which is very similar to the “man” command. The “info” command is supposed to contain more information than the manual pages which one gets by using the “man” command . However when there is no specific “information” page written for a command the manual page is displayed instead. So right now there will not be much difference between using the “man” and “info” commands other than for those commands for which there are separate information pages.

Usage

user@system-name:~$ info command-name

Example

user@system-name:~$ info ls

Now that we have gone through two commands which give a very detailed and comprehensive information about a required command lets look at a short and sweet command, namely the “whatis” command.

Short and sweet because it does what it says. It gives a one line description of what a command does

Usage

user@system-name:~$ whatis command-name

 

Example

user@system-name:~$ whatis ls

The output for the above command would be,

ls (1)               – list directory contents

The above four commands helped you know what a certain command could do.

Now lets look at two commands which help us locate where the binary(the executable file) for a command is located.

The first command is the “which” command.

Usage

user@system-name:~$ which command-name

 

Say you would like to know where the binary (executable file) for the command “cp” is located

Example

user@system-name:~$ which cp

The result of the above statement would simply be,

/bin/cp

The next command does a little bit more than the “which” command

It is the “whereis” command. In addition to the binary of the command it also locates the source code and the man page of the command.

Usage

user@system-name:~$ whereis command-name

Example

user@system-name:~$ whereis ls

The output would then be

cp: /bin/cp /usr/share/man/man1/cp.1.gz

Here we see that there are only two locations namely the binary location and the location of the man page.

The location of the source is not shown since the source files have not been installed.

 

So these are the various help commands that can be used in the linux shell.

 

Hope it was a good learning experience.


Leave a Reply

Your email address will not be published. Required fields are marked *