7 linux commands that will help you learn other linux commands

One of the daunting task that most Linux beginners face is the sheer number of several different commands and utilities that are available. Some of these commands might seem to do the exact same things. Each of these commands have numerous command line options on top of it. Yes. having choices comes at a price.

It is quite impractical to learn each and every command and its various options that are available. This means you will constantly be looking up different commands and its options, especially if you work with the command line.

Here are some commands that will let you look up different commands and its usage or description easily from the command line. We will use some of the most commonly used commands, aliases and shell built-ins as arguments (or examples) to see how it all works.

The commands we will use is rm, which, bash, awk, find, firefox and . (the dot operator). You should already be familiar with most of them.

type

The type command lets you know what type of command it is. It prints out a small description that tells you where the command is located and what type it is: an executable, shell script, etc etc.

This is especially useful, if you find that the command you are executing is behaving differently than you expected it to. Maybe it is picking out of somewhere else or is aliased? Let's see what it prints out for some the common linux commands. You can specify multiple commands as arguments to the type command.

bash$ type ll rm bash awk find . firefox

ll is aliased to `ls -l'
rm is aliased to `rm -vi'
bash is /bin/bash
awk is /usr/bin/awk
find is /usr/bin/find
. is a shell builtin
firefox is /opt/bin/firefox

which

The which is another useful utility that prints out the full path to the shell commands. This is much useful when you want make sure that the command that is executed is from the correct path in the current bash environment.

bash$ which ll rm bash awk find . firefox
which: no ll in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3)
/bin/rm
/bin/bash
/usr/bin/awk
/usr/bin/find
which: no . in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3)
/opt/bin/firefox

As you can see the ll is not found as it is a bash alias, and the dot operator is a bash built-in which is not identified either.

whatis

If you are reluctant to read long manual pages for the command, then whatis is the command for you. whatis will print out one-line manual page descriptions. It is a very good resource to use as a quick and easy reference.

bash$ whatis ll rm type bash awk find . firefox
rm (1p) - remove directory entries
rm (1) - remove files or directories
type (1p) - write a description of command type
builtins (1) - bash built-in commands, see bash(1)
bash (1) - GNU Bourne-Again SHell
awk (1p) - pattern scanning and processing language
awk (1) - pattern scanning and processing language
find (1p) - find files
find (1) - search for files in a directory hierarchy
ll: nothing appropriate.
firefox: nothing appropriate.

apropos

This is not a command that is commonly used anymore. It was quite popular in the Unix world, but not so much in Linux. It is often a wrapper around the man command (which is detailed later), and is a quick way to search through manual reference pages.

The output of the command is quite similar to the whatis command detailed before.

man

The man is probably the most popular and well known command of all the help commands. It shows you the manual pages for different commands. It is basically an interface for the on-line reference manual.

bash$ man rm
man-rm-command.png

The manual pages displayed are quite detailed and usually documents all the various options available. If anything, this is probably the one command you should know.

info

The info command is very similar to the man command detailed in the previous section. Sometimes the commands are documented in what is called info pages (or info format), and are usually not as detailed as the manual page.

The info command can be used to find some documentation if you cannot find any manual pages.

bash$ info rm

help

I have found the help command to be quite useful when trying to find information about the bash built-ins. The help command by itself shows you the list of bash built-ins.

You can use help command to find the syntax and how to use that while loop or if condition in your bash shell scripts.

bash$ help while
help-command-while-bash.png

All of these commands are very easy to remember and use. They do not have much in terms of options and can quickly give either an overview of the command or a very detailed explanation of the commands and options.