Skip to main content
RH124

Getting Help in CentOS 7 from the CLI

By July 29, 2014July 31st, 2017No Comments

centos7Getting Help in CentOS 7

If you are working for a Red Hat Linux Certification the exams are practical based so you do not need to remember options and switches in your head. As in the real world you can check from the command line the help systems. These range from the simple –help option  to most commands to the more detailed man and info pages. We will also investigate the whatis and whereis commands.

Simple Help

Getting help in CentOS 7 can be as simple as the option –help to many command. In this example we look at help from the command who:

[tux@c1 ~]$ who --help

Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]

Print information about users who are currently logged in.

  -a, --all         same as -b -d --login -p -r -t -T -u

  -b, --boot        time of last system boot

  -d, --dead        print dead processes

  -H, --heading     print line of column headings

  -l, --login       print system login processes

      --lookup      attempt to canonicalize hostnames via DNS

  -m                only hostname and user associated with stdin

  -p, --process     print active processes spawned by init

  -q, --count       all login names and number of users logged on

  -r, --runlevel    print current runlevel

  -s, --short       print only name, line, and time (default)

  -t, --time        print last system clock change

  -T, -w, --mesg    add user's message status as +, - or ?

  -u, --users       list users logged in

      --message     same as -T

      --writable    same as -T

      --help     display this help and exit

      --version  output version information and exit

If FILE is not specified, use /var/run/utmp.  /var/log/wtmp as FILE is common.

If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>

For complete documentation, run: info coreutils 'who invocation'

[tux@c1 ~]$

Many commands in Linux have this option and default to showing similar help for any invalid option. This is always a great starting point in you need to research available options.

Man Pages

Where a command is more complex the output from –help may not be helpful. Getting help in CentOS 7 may better be served with man or manual pages. For example using man ls. Will show you the manual page for ls.

[tux@c1 ~]$ man ls

The page will open in the default pager (usually less) so you can page down through the document, or use /<item to search> to search for text.

Sections

Some commands have more than one man page section and you may have to choose the correct section. For example

[tux@c1 ~]$ man crontab

Will open up help on the the crontab command. The same as:

[tux@c1 ~]$ man 1 crontab 

If you want help on the syntax of a crontab file then use:

[tux@c1 ~]$ man 5 crontab 

Command sections are:

  • 1: User commands
  • 5: File formats or configuration file help
  • 8: Admin commands

For more details see man man.

Info Pages

Even man pages can struggle to show you all the help you need. This is where the hyperlinked pages of info can help.

Using:

[tux@c1 ~]$ info ls

Will open the info pages for the command ls. Menu items are denoted with the * and you may use the ENTER key to traverse the link. Using u takes you back up.