Written by Chris Gregg, with modifications by Nick Troccoli
Click here for a walkthrough video.
One of the most important tools to find out what a Unix or C command does is the
man command, which display "manual pages" for a particular command.
$ man ls LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them. E.g., '--block-size=M' prints sizes in units of 1,048,576 bytes. See SIZE format below. Manual page ls(1) line 1 (press h for help or q to quit)
To use a man page, you can use the arrow keys to scroll up and down the page, and you type
q to quit, taking you back to where you left off (and restoring the screen, which is a nice option).
You can also perform a search inside a man page by typing a forward slash (
/) and then a search term, followed by the enter key.
If you are not sure what manual page you want, but you do have a keyword, you can search the manual system to find the page you want, by using the command
man -k keyword:
$ man -k printf Printf (3o) - Formatted output functions. asprintf (3) - print to allocated string ber_printf (3) - OpenLDAP LBER simplified Basic Encoding Rules library... dprintf (3) - print to a file descriptor fprintf (3) - formatted output conversion fwprintf (3) - formatted wide-character output conversion printf (1) - format and print data printf (3) - formatted output conversion snprintf (3) - formatted output conversion sprintf (3) - formatted output conversion swprintf (3) - formatted wide-character output conversion vasprintf (3) - print to allocated string vdprintf (3) - print to a file descriptor vfprintf (3) - formatted output conversion vfwprintf (3) - formatted wide-character output conversion vprintf (3) - formatted output conversion vsnprintf (3) - formatted output conversion vsprintf (3) - formatted output conversion vswprintf (3) - formatted wide-character output conversion vwprintf (3) - formatted wide-character output conversion wprintf (3) - formatted wide-character output conversion XtAsprintf (3) - memory management functions $
The numbers in parentheses is the manual "section", and a command may show up in different sections. For example, in the above listing, there are two
printf commands, one in section 1, and one in section 3. Unix commands are in section 1, and C library functions are in section 3.
To find a command in a particular section, put the section number first:
$ man 1 printf # show the unix printf command manual page $ man 3 printf # show the C library function manual page $
A synonym to
man -k keyword is the
apropos -r keyword command:
$ apropos -r ls