How Can I Get Help on Terminal Commands?

I often see things like

read man xyz
For more information read xyz's man page.
see info xyz

so I wonder:

  • How can I get help on terminal commands generally?
  • What exactly are these man and info pages?
  • How can I find and view them?
6

9 Answers

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:

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.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.