How can I get help on terminal commands?

What is a man page?

A man page (short for manual page) is the traditional form of software documentation on a Unix-like OS like Ubuntu. For the vast majority of commands and programs there's a man page which lists its options and explains its usage.

How can I find and view man pages?

Offline in a terminal

Man pages are automatically installed on your system together with the commands they describe. To view and search man pages there's the command man:

man mv

displays the man page of mv while

man -k mv

searches names and short descriptions of all installed man pages for the string mv. POSIX Extended Regular Expressions are allowed and it's a search, so this will also find e.g. git-mv and semver, if you want to search exactly mv use ^mv$ instead.

See What is the difference between `man` and `man (#)`? to read about man page sections. For more information read man's man page. ;)

How can I influence how a man page is displayed?

The default program to display man pages is less. This so-called pager provides a helpful search function, just enter / followed by the search term, e.g.

/--version

and press Enter. This will mark every finding and scroll to the first one. Press N to go to the next finding and ⇧ Shift+N to go to the previous one (see How can I search within a manpage?). For a list of commands press H, to exit less press Q.

Beside less there are other pagers available: pg, most and w3m just to list three. I recommend most: It comes with a very useful coloring of key words making a man page much easier to read and navigate, see for yourself:

most screenshot displaying mv's manpage

To view a man page in a different than your default pager use the -P option, e.g.:

man -P most mv

If you want to change the default pager manpages are displayed with you have two options:

  • change the default pager solely of man

    export MANPAGER=most
    

    To make the change persistent add this command to your ~/.bashrc file.

  • change the default pager of your whole system

    sudo update-alternatives --config pager
    

Fans can even (ab)use vim as the MANPAGER, see this article written by muru.

Man pages are displayed in the font specified in your terminal emulator settings. If you work with the terminal regularly you might want to change this font; I can only recommend Hack – a typeface designed for source code, see the screenshot above for its beauty.

Offline via GUI

A nice and easy way to display man pages with a simple GUI is the preinstalled yelp program. To start a man page with yelp execute yelp man:PROGRAM or gnome-help man:PROGRAM, e.g.:

yelp man:mv

You can also view man pages with your preferred browser, see How do I make man pages open in a web browser?, e.g. for man mv in firefox:

man -Hfirefox mv

Last but not least you can convert man pages to PDF and view them with your preferred PDF viewer, see: Is there a way to print info/man pages to PDF?

Online

http://manpages.ubuntu.com

You can view the man pages of programs available via the repositories of every currently supported Ubuntu version with the shorthand URL manpg.es/PROGRAM, e.g. http://manpg.es/mv. This opens mv's man page for the latest Ubuntu release, you can choose a different release in the top bar. To search for man pages you can use e.g. http://manpages.ubuntu.com/cgi-bin/search.py?q=mv.

As explained above man can only display man pages of software installed on the system. To view man pages from http://manpages.ubuntu.com using a terminal pager there's dman available in the bikeshed package.

Other sources

When you read documentation from other online sources it's a good idea to keep an eye on the program version. Most programs have a --version option that displays the version of the program in question, e.g.

$ mv --version
mv (GNU coreutils) 8.25

There are a lot of websites which dedicated themselves to make man pages easily available, I'm just going to present the two I like the most:

  • man7.org comes with useful syntax highlighting, but it features only the last released version of the program
  • manpag.es hosts man pages of Ubuntu releases long gone EOL

Source not already linked: https://wiki.ubuntuusers.de/man/


The basics have been covered already, but one website I think is quite helpful for telling you what a command does is https://explainshell.com, which breaks down a command into its sections and shows what each bit does.

enter image description here


What is an info page?

Alongside

man program-name

there is often also

info program-name

Sometimes they are the same (duplicates), but sometimes one of these pages contains more information. For example

info ddrescue

contains more information than

man ddrescue

and

info date

contains more information than

man date

The balance between man and info depends on the policy of the people who maintain the particular program [package].

See this link for more details,

unix.stackexchange.com/questions/19451/difference-between-help-info-and-man-command