Introduction to man command

The man command is used to format and display the man pages. The man pages are a user manual that is by default built into most of the Linux Distributions and most other Unix-like OS. They provide extensive documentation about commands and other aspects of the system, including configuration files, system calls, library routines and the kernel.

The basic man command syntax is man [options] keyword

For Example:
$ man ls
LS(1)                     BSD General Commands Manual                    LS(1)
 
NAME
    ls -- list directory contents
 
SYNOPSIS
    ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]
 
DESCRIPTION
    For each operand that names a file of a type other than directory, ls
    displays its name as well as any requested, associated information.  For
    each operand that names a file of type directory, ls displays the names
    of files contained within that directory, as well as any requested, asso-
    ciated information.
 
    If no operands are given, the contents of the current directory are dis-
    played.  If more than one operand is given, non-directory operands are
    displayed first; directory and non-directory operands are sorted sepa-
    rately and in lexicographical order.
 
    The following options are available:
 
    -@      Display extended attribute keys and sizes in long (-l) output.
 
: 

Navigateing Man Pages

When using the man command there are few key combinations that you should be aware of.

Key Meaning
Enter Moves down one line every time when you hit Enter. So you will see the page just move down by one line when you hit Enter.
Space Move down an entire screen or a page when you hit Space
g
(lowercase)
Move to the top of the pge.
G
(uppercase)
Move to the bottom of the page.
q
(lowercase)
Quit.

Searching a command

If you have an idea of something that you want to do, but you're not exactly sure how to go about it, or which commands to use, you could start by looking in your path. Looking in those directories and see if any one of those commands may help you out. And then you can get more details on exactly how to use that command with the man command.

Get help with --help or -h

Many commands will provide hints for how to use them at the command line. Some commands will accept the

  • Add --help flat to a command to get help
  • Others will accept -h.
  • Some will refuse to give any help at all. In this case, you would use the man command.
For Example:

ls will provide some information at the command line when you specify the --help

$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs 
.....

You can use -h to get help for gzip command.

$ gzip -h
Usage: gzip [-123456789acdfhklLNnqrtVv] [-S .suffix] [&ltg;file> [&ltg;file> ...]]
-1 --fast            fastest (worst) compression
-2 .. -8             set compression level
-9 --best            best (slowest) compression
-c --stdout          write to stdout, keep original files
   --to-stdout

Searching man page

If you are not sure which command to use, you can search through the man pages with man -k SEARCH_TERM. From there you can read the man page for the command or ask for -h or --help.

For Example:

If you want to search a command for calendar:

$ man -k calendar
cal(1), ncal(1)          - displays a calendar and the date of easter
calendar(1)              - reminder service