Ryans Tutorials
More great tutorials at RyansTutorials

Manual Pages!

Your reference on Linux.

Introduction

The Linux command line offers a wealth of power and opportunity. If your memory is like mine then you find it hard to remember a large number of details. Fortunately for us there is an easy to use resource that can inform us about all the great things we can do on the command line. That's what we're going to learn about in this section. I know you're keen and eager to get stuck into doing stuff, and we'll get started on that in the next section, I promise, first we need to learn how to use Manual pages however.

So what are they exactly?

The manual pages are a set of pages that explain every command available on your system including what they do, the specifics of how you run them and what command line arguments they accept. Some of them are a little hard to get your head around but they are fairly consistent in their structure so once you get the hang of it it's not too bad. You invoke the manual pages with the following command:

man <command to look up>

  1. man ls
  2. Name
  3.     ls - list directory contents
  4.  
  5. Synopsis
  6.     ls [option] ... [file] ...
  7.  
  8. Description
  9.     List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
  10.  
  11.     Mandatory arguments to long options are mandatory for short options too.
  12.  
  13.     -a, --all
  14.         do not ignore entries starting with .
  15.  
  16.     -A, --almost-all
  17.         do not list implied . and ..
  18.  
  19. ...

Let's break it down:

  • Line 3 tells us the actual command followed by a simple one line description of it's function.
  • Lines 6 is what's called the synopsis. This is really just a quick overview of how the command should be run. Square brackets ( [ ] ) indicate that something is optional. (option on this line refers to the command line options listed below the description)
  • Line 9 presents us with a more detailed description of the command.
  • Line 11 onwards Below the description will always be a list of all the command line options that are available for the command.

To exit the man pages press 'q' for quit.

Searching

It is possible to do a keyword search on the Manual pages. This can be helpful if you're not quite sure of what command you may want to use but you know what you want to achieve. To be effective with this approach, you may need a few goes. It is not uncommon to find that a particular word exists in many manual pages.

man -k <search term>

If you want to search within a manual page this is also possible. To do this, whilst you are in the particular manual page you would like to search press forward slash '/' followed by the term you would like to search for and hit 'enter' If the term appears multiple times you may cycle through them by pressing the 'n' button for next.

More on the Running of Commands

A lot of being proficient at Linux is knowing which command line options we should use to modify the behaviour of our commands to suit our needs. A lot of these have both a long hand and short hand version. eg. Above you will notice that to list all directory entries (including hidden files) we can use the option -a or --all (remember from last section what files and directories beginning with a . are?). The long hand is really just a more human readable form. You may use either, they both do the same thing. One advantage of using long hand is that it can be easier for you to remember what your commands are doing. One advantage of using shorthand is that you can chain multiple together easier.

  1. pwd
  2. /home/ryan
  3. ls -a
  4. ls --all
  5. ls -alh

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

As you can see, long hand command line options begin with two dashes ( -- ) and short hand options begin with a single dash ( - ). When we use a single dash we may invoke several options by placing all the letters representing those options together after the dash. (There are a few instance where a particular option requires an argument to go with it and those options generally have to be placed separately along with their corresponding argument. Don't worry too much about these special cases for now though. We'll point them out as we encounter them.)

Summary

man <command>
Look up the manual page for a particular command.
man -k <search term>
Do a keyword search for all manual pages containing the given search term.
/<term>
Within a manual page, perform a search for 'term'
n
After performing a search within a manual page, select the next found item.
The man pages are your friend.
Instead of trying to remember everything, instead remember you can easily look stuff up in the man pages.

Activities

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

  • Have a skim through the man page for ls. Have a play with some of the command line options you find there. Make sure you play with a few as combinations. Also make sure you play with ls with both absolute and relative paths.
  • Now try doing a few searches through the man pages. Depending on your chosen terms you may get quite a large listing. Look at a few of the pages to get a feel for what they are like.