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?
I often see things like
read
man xyz
For more information read xyz's man page.
seeinfo xyz
so I wonder:
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
:displays the man page of
mv
whilesearches 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
andsemver
, if you want to search exactlymv
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.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
andw3m
just to list three. I recommendmost
: 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.:If you want to change the default pager manpages are displayed with you have two options:
change the default pager solely of
man
To make the change persistent add this command to your
~/.bashrc
file.change the default pager of your whole system
Fans can even (ab)use
vim
as theMANPAGER
, 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 withyelp
executeyelp man:PROGRAM
orgnome-help man:PROGRAM
, e.g.: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
infirefox
: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 opensmv
'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'sdman
available in thebikeshed
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.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:
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.
What is an info page?
Alongside
there is often also
Sometimes they are the same (duplicates), but sometimes one of these pages contains more information. For example
contains more information than
and
contains more information than
The balance between
man
andinfo
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
What is the
help
command?help
displays helpful information aboutbash
built-in commands. It provides help for bash shell commands only. You can usetype
to determine whether a command is such a built-in, e.g.type echo
vs.type rm
.It is called with a pattern as an argument:
displays the help page for the
if
command. If you're just interested in the syntax of a command use the-s
option, if you wanthelp
to produce output inman
page format use-m
. To view long help texts conveniently you can pipe the output to your preferred pager (see this answer's “How can I influence” section):Comparison with
man
andinfo
You can run and compare the following commands:
Like in this example there are programs who are available both as a built-in and a usual program (see Why is there a /bin/echo and why would I want to use it?), in this case the man page usually contains a note indicating that.
See this link for more details: Difference between help, info and man command · U&L
a program's option
-h
and/or--help
Usually there is built-in help in the programs themselves available via at least one of the options
-h
,--help
or-?
:If both options
-h
and--help
exist, they are often equivalent, but sometimes you get 'more help' with--help
,-H
,--longhelp
,--help-all
or similar commands. This behaviour is documented in the program'sman
/info
page.Usually there is more information via
man
andinfo
, but sometimes there is exclusive information via-h
. Run and compare the output ofand
Some programs like
df
,tar
andrsync
use the option-h
for something else. This is described in theman
/info
page of each program.Again you can pipe the output to your preferred pager, e.g.:
What is a tutorial and how can I find a useful one
When you have some experience of linux, the man pages, info pages and help options are very useful. But in the beginning, they can be difficult to understand; you need more detailed help to get started.
You can find detailed help in tutorials,
Usually you will find tutorials via the internet, sometimes there is a useful tutorial in the man page or info page.
Try some search strings when you use your web browser's search engine, for example
Looking for specified tools
Looking for tasks (and finding tutorials for various tools)
Look briefly at a few of the links that you find, and start working with a tutorial that fits what you need.
man rsync
is detailed enough for me to use as a tutorial, but you might want more details (and look for a tutorial via the internet).info ddrescue
has a good built-in tutorial.tldroid: An Android app which gives quick info about a Linux/unix/mac command
https://play.google.com/store/apps/details?id=io.github.hidroh.tldroid
My favorite is commandlinefu.com, have a function in your
.bashrc
or.zshrc
like thisLet's try
cmd mount cd
, I called my functioncmd
, you can call it whatever you wantThe function above searches commandlinefu's website, it's a community driven website much like here, users have the ability to upvote commands and so on. Then it shows the top results as in the picture.
or there's a new way to do that by using this.
http://samirahmed.github.io/fu/
Here's a tutorial.
Let's do
fu cron
Figure out how to open a terminal window and issue the command
man man
. Type the space bar to advance to the next screen whenever it says "More" at the bottom. You are reading the manual page for the manual-reading program,man
!There is a very small chicken-and-egg problem for you to get through. The
man
command helps you read the manual about every command on the system. But theman
output uses another command calledmore
. You can also readman more
to learn additional navigation commands formore
.And that is everything! I learned everything I know about unix by reading the man pages for hundreds of commands.
Many have mentioned
man
already. A little cool feature forman
few are aware of iswhich produces a PostScript file for the manual page. PostScript can be easily converted to PDF. This results in a much nicer formatting than the default command line terminal version of
man
.For example:
I've just tested it on Ubuntu (and it should work on other Linuces) and Mac OS.