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?...
I often see things like
read
man xyz
For more information read xyz's man page.
seeinfo 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?
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?
Must Read
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
manexport MANPAGER=mostTo make the change persistent add this command to your
~/.bashrcfile.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.