Skip to main content

Manual pages

Manual pages are a set of pages explaining every command available on your system, including what they do, how you run them, and what command-line arguments they accept.

To invoke the manual pages, run the following command:

man <command to look up>
user@bash: man ls
Name
    ls - list directory contents

Synopsis
    ls [option] ... [file] ...

Description
    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 ..
...

Let's break down the example above:

  • Line 3 contains an actual command followed by a simple one-line description of its function.
  • Line 6 is what's called the synopsis. This is a quick overview of how the command should be run. Square brackets ([ ]) indicate that something is optional. The option on the line refers to the command-line options listed below the description.
  • Line 9 gives you a more detailed description of the command.
  • Line 11 onwards, below the description, is always a list of all command-line options available for the command.

To exit a manual page, press q.

Searching Manual pages

On Manual pages, you can do a keyword search. This can be helpful if you are unsure what command you may want to use, but you know what you want to achieve.

To do the search, run the command:

man -k <search term>

To search within a manual page, follow the steps:

  1. Whilst you are on the particular manual page you would like to search, press the forward slash (/) followed by the term you would like to search for.

  2. Hit Enter. If the term appears multiple times, you can cycle through them by pressing the n button.

More on running commands

A lot of being proficient at Linux is knowing which command-line options you should use to modify the behavior of commands to suit your needs. A lot of these have both a long hand and short hand version.

For example, above you can notice that to list all directory entries, including hidden files, you can use the -a or --all options. The long hand is a more human readable form. You can use either—they both do the same thing.

One advantage of using the long hand is that it can be easier for you to remember what your commands are doing. One advantage of using the short hand is that you can chain multiple commands together easier.

user@bash: pwd
/home/ryan
user@bash: ls -a
ls --all
ls -alh

Look up the man page for ls to find out what that last command is doing.

As you can see, the long hand command-line options begin with two dashes (--), and short hand options begin with a single dash (-). When you use a single dash, you can invoke several options by specifying the letters representing those together after the dash. There are a few instances where a particular option requires an argument to go with it, and those generally have to be added separately along with their corresponding argument.

Activities for practicing

Right, now let's put this stuff into practice. Have a go at the following:

  • Scan through a manual page for ls. Play with some of the command-line options you find there. Make sure you try a few combinations with ls using both absolute and relative paths.
  • Now try doing a few searches through the man pages. Depending on your chosen terms, you can get quite a pretty extensive listing. Look at a few of the pages to get a feel for what they are like.