Overview
By the end of this article you should be able to answer the following questions:
Announcement
You can find all my latest posts on medium.It is usually one of the following:
$ tar h
# or
$ tar -h
# or
$ tar help
# or
$ tar –help
$ man tar
$ info tar
# or
$ pinfo tar
/etc/selinux/config
?$ whatis config
/etc/passwd
config file?$ whatis passwd
# you should discover the man page is accessible like this:
$ man 5 passwd
$ mandb
$ man -k compress
$ man -K compress # note this time it is a capital k.
$ yelp
$ firefox file:///usr/share/doc
Any of the following:
$ locate {command}
$ whereis {command}
$ which {command}
$ type {command}
$ updatedb
While most people rely on google when they get stuck, there are actually a number of useful help resources available from the command line.
You can also access help info from both the desktop gui (via the desktop user guide), but we’ll just focus on finding help at the command line.
Viewing usage info
The man pages are quite long a detailed, which can be time consuming to read through, if you want a quick guide on how to use a command. That’s why a lot of commands have a shorter (usage) guide that gives a much briefer overview of all a given command’s options. The usage guide is accessible in one of several ways depending on the command.
For example, to access the “ls” command’s help info we use the “–help” switch
$ ls --help | head Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
If --help
doesn’t give the usage info, then try -h
, help
, -help
, or just h
.
Some commands don’t provide usage info, in which case you have to view their man pages instead.
The man command
The RHEL OS comes with a Reference Manual. You can access various pages and sections of this manual using the
“man” command is short for “Reference (man)ual”.
The man command displays pages from the official reference manual for a command. For example:
$ man ls
You can even use the man command to view the help for in the man command itself:
$ man man
It can be a bit overwhelming to take in the content from man pages, but it gets easier once you take the time to understand man pages in greater detail.
The info command
The info command is just another source of help information:
$ info ls
In most cases the info command gives the same content as the man command. However occasionally it does contains additional info. So it is probably best to only use ‘info’ after going through the man pages.
While in info mode, press the “h” key to list the various navigation options.
This command is particularly useful for really long man pages, e.g.:
$ info bash
The pinfo command
The pinfo command display the man pages in a more user friendly format. It essentially breaks down a man pages into sections which you can navigate to using your arrow keys. Whereas the man command displays everything in a single output. Whether you use pinfo or man is down to personal preference.
$ info bash
The whatis command
The whatis command gives a one line description of a command:
whatis ls
whatis essentially works by looking up a given command’s man page, and displays the header line from that man page. The whatis command is useful if you just want a quick reminder of a command without bringing up the whole man page.
However the whatis command is more useful for finding help info for various config file. For example if you want to find more info about the file /etc/selinux/config
then do::
$ whatis config Config (3pm) - access Perl configuration information config (5ssl) - OpenSSL CONF library configuration files selinux_config (5) - The SELinux sub-system configuration file.
Once you have located a man page, you can then view it using the man command, by specifying it’s location:
$ man 5 selinux_config
Searching the man pages
Before you search through the man pages, you should first run:
$ mandb
This will create/update an internal db using info from all the man pages.
Sometimes you want to perform a task but dont know the name of the command to use. In those situations you will want to do a keyword search against the entire reference manual and then outputs a list of all man pages where a match has been found. for example, lets say you want to compress a file, but don’t know what command you should use, in that case can do a keyword search on the word “compress”, is the man command’s k option:
$ man -k compress bunzip2 (1) - a block-sorting file compressor, v1.0.6 bzcat (1) - decompresses files to stdout bzcmp (1) - compare bzip2 compressed files bzdiff (1) - compare bzip2 compressed files bzgrep (1) - search possibly bzip2 compressed files for a regular expression bzip2 (1) - a block-sorting file compressor, v1.0.6 bzless (1) - file perusal filter for crt viewing of bzip2 compressed text . . . . ...etc
Note if you want to do a deeper search then use capital K instead:
$ man -k compress
As you can see it search’s all “whatis” entries for search matches.
Some software packages don’t come with man pages. Instead, the man pages have to be installed separately (not sure how to identify these packages, might be possible using yum or rpm)
Accessing help from the desktop GUI
While it is possible to access a vast collection help resources straight from the command line, it can also be worthwhile accessing help from the desktop. This is especially true for help material that are in the form of images and diagrams.
There are a number of ways to access help:
The first way is:
Which takes you to:
You can also launch this utility by simply running the yelp command:
$ yelp
Viewing help info in usr/share/doc
Another place that contains help material /usr/share/doc
, which is best viewed via firefox. You can launch firefox via the command line.
$ firefox file:///usr/share/doc
Which results in:
Tracking down a command
type {command} # tells you if command is builtin or not, if not then shows the path. which {command} # shows command's file location (even for builtin ones). # this command is specifically suited for finding binaries. whereis {command} # shows command's file location (even for builtin ones). locate {command} # shows command's file location
Note: you need to run the “updatedb” to run the “locate” command. This is the equivelent to the “mandb” is to the man command’s -k option.
The “type” and “which” commands
Before we start, let’s first lookup the whatis info for the “type” and “which” commands:
$ whatis type type (1) - bash built-in commands, see bash(1) type (1p) - write a description of command type $ whatis which which (1) - shows the full path of (shell) commands.
The “type” command tells you whether a command is builtin, or not, if not then it shows the path. E.g.
$ type cd cd is a shell builtin
You can find a list of all builtin commands listed in the type command’s man page:
$ man 1 type
However even built-in files are represented in linux as a file, hence in this situation you need to use the “which” command to locate the binary (aka executable) file for the “cd” command:
$ which cd /usr/bin/cd
Both “type” and “which” can be used to locate non-builtin commands:
$ type tar tar is /usr/bin/tar $ which tar /usr/bin/tar
Locating documentation with rpm
You can also view what documentations have been installed using the rpm command.
$ rpm -qd tree /usr/share/doc/tree-1.6.0/LICENSE /usr/share/doc/tree-1.6.0/README /usr/share/man/man1/tree.1.gz
More about this when we come to talk about rpm.