https://wiki.archlinux.org/api.php?action=feedcontributions&user=Nolby&feedformat=atomArchWiki - User contributions [en]2024-03-28T23:06:09ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Man_page&diff=153227Man page2011-08-25T10:12:28Z<p>Nolby: </p>
<hr />
<div>[[Category:Utilities (English)]]<br />
{{i18n|Man Page}}<br />
<br />
{{Article summary start|Summary}}<br />
{{Article summary text|Information on man pages, along with recommendations on how to improve their usage}}<br />
<!--<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|}}<br />
--><br />
{{Article summary end}}<br />
<br />
'''Man pages''' (abbreviation for "manual pages") are the extensive documentation that comes preinstalled with almost all substantial UNIX-like operating systems, including Arch Linux. The command used to display them is {{Codeline|man}}.<br />
<br />
In spite of their scope, man pages are designed to be self-contained documents, consequentially limiting themselves to referring to other man pages when discussing related subjects. This is in sharp contrast with the hyperlink-aware info files, GNU's attempt at replacing the traditional man page format.<br />
<br />
==Accessing Man Pages==<br />
To read a man page, simply enter:<br />
<br />
$ man ''page_name''<br />
<br />
Manuals are sorted into several sections:<br />
# General commands<br />
# System calls (functions provided by the kernel)<br />
# Library calls (C library functions)<br />
# Special files (usually found in /dev) and drivers<br />
# File formats and conventions<br />
# Games<br />
# Miscellaneous (including conventions)<br />
# System administration commands (usually requiring root privileges) and daemons<br />
<br />
Man pages are usually referred to by their name, followed by their section number in parentheses. Often there are multiple man pages of the same name, such as man(1) and man(7). In this case, give man the section number followed by the name of the man page, for example:<br />
<br />
$ man 5 passwd<br />
<br />
to read the man page on {{Codeline|/etc/passwd}}, rather than the {{Codeline|passwd}} utility.<br />
<br />
Very brief descriptions of programs can be read out of man pages without displaying the whole page using the {{Codeline|whatis}} command. For example, for a brief description of ls, type:<br />
<br />
$ whatis ls<br />
<br />
and {{Codeline|whatis}} will output "list directory contents."<br />
<br />
==Format==<br />
Man pages all follow a fairly standard format, which helps in navigating them. Some sections which are often present include:<br />
* NAME - The name of the command and a one-line statement of its purpose.<br />
* SYNOPSIS - A list of the options and arguments a command takes or the parameters the function takes and its header file.<br />
* DESCRIPTION - A more in depth description of a command or function's purpose and workings.<br />
* EXAMPLES - Common examples, usually ranging from the simple to the relatively complex.<br />
* OPTIONS - Descriptions of each of the options a command takes and what they do.<br />
* EXIT STATUS - The meanings of different exit codes.<br />
* FILES - Files related to a command or function.<br />
* BUGS - Problems with the command or function that are pending repair. Also known as KNOWN BUGS.<br />
* SEE ALSO - A list of related commands or functions.<br />
* AUTHOR, HISTORY, COPYRIGHT, LICENSE, WARRANTY - Information about the program, its past, its terms of use, and its creator.<br />
<br />
==Searching manuals==<br />
Whilst the {{Codeline|man}} utility allows users to display man pages, a problem arises when one knows not the exact name of the desired manual page in the first place! Fortunately, the {{Codeline|-k}} or {{Codeline|--apropos}} options can be used to search the manual page descriptions for instances of a given keyword. For example, to search for man pages related to "password":<br />
<br />
$ man -k password<br />
<br />
or:<br />
<br />
$ man --apropos password<br />
<br />
This is equivalent to calling the {{Codeline|apropos}} command:<br />
<br />
$ apropos password<br />
<br />
The given keyword is interpreted as a regular expression by default.<br />
<br />
==Colored man pages==<br />
For some users, color-enabled man pages allow for a clearer presentation and easier digestion of the content. Given that users new to Linux are prone to spend a considerable amount of time familiarizing themselves with basic userspace tools, setting up a comfortable environment is a necessity to most.<br />
<br />
There are two prevalent methods for achieving colored man pages: using {{Codeline|most}}, or opting for {{Codeline|less}}. The former is simpler to configure, at the expense of the advanced functionality that is native to {{Codeline|less}}.<br />
<br />
===First method: using 'most'===<br />
Install {{package Official|most}} using [[pacman]]:<br />
# pacman -S most<br />
This is similar to {{Codeline|less}} and {{Codeline|more}}, yet allows rendering colored text in an easier way.<br />
<br />
Edit {{Filename|/etc/man_db.conf}}, uncomment the pager definition and change it to:<br />
DEFINE pager most -s<br />
Test the new setup by typing:<br />
$ man whatever_man_page<br />
<br />
Modifying the color values requires editing {{Filename|~/.mostrc}} (creating the file if it is not present) or editing {{Filename|/etc/most.conf}} for system-wide changes. Example {{Filename|~/.mostrc}}:<br />
% Color settings<br />
color normal lightgray black<br />
color status yellow blue<br />
color underline yellow black<br />
color overstrike brightblue black<br />
Another example showing keybindings similar to {{Codeline|less}} (jump to line is set to 'J'):<br />
% less-like keybindings<br />
unsetkey "^K"<br />
unsetkey "g"<br />
unsetkey "G"<br />
unsetkey ":"<br />
<br />
setkey next_file ":n"<br />
setkey find_file ":e"<br />
setkey next_file ":p"<br />
setkey toggle_options ":o"<br />
setkey toggle_case ":c"<br />
setkey delete_file ":d"<br />
setkey exit ":q"<br />
<br />
setkey bob "g"<br />
setkey eob "G"<br />
setkey down "e"<br />
setkey down "E"<br />
setkey down "j"<br />
setkey down "^N"<br />
setkey up "y"<br />
setkey up "^Y"<br />
setkey up "k"<br />
setkey up "^P"<br />
setkey up "^K"<br />
setkey page_down "f"<br />
setkey page_down "^F"<br />
setkey page_up "b"<br />
setkey page_up "^B"<br />
setkey other_window "z"<br />
setkey other_window "w"<br />
setkey search_backward "?"<br />
setkey bob "p"<br />
setkey goto_mark "'"<br />
setkey find_file "E"<br />
setkey edit "v"<br />
<br />
===Second method: using 'less'===<br />
:<small>''Source: [http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html nion's blog - less colors for man pages]''</small><br />
<br />
Alternatively, getting an approximate coloured result in manual pages with {{Codeline|less}} is also a possibility. This method has the advantage that {{Codeline|less}} has a bigger feature set than {{Codeline|most}}, and that might be the preference for advanced users.<br />
<br />
Add the following to a shell configuration file. For [[Bash]] it would be {{Filename|~/.bashrc}}:<br />
<pre><br />
man() {<br />
env \<br />
LESS_TERMCAP_mb=$(printf "\e[1;31m") \<br />
LESS_TERMCAP_md=$(printf "\e[1;31m") \<br />
LESS_TERMCAP_me=$(printf "\e[0m") \<br />
LESS_TERMCAP_se=$(printf "\e[0m") \<br />
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \<br />
LESS_TERMCAP_ue=$(printf "\e[0m") \<br />
LESS_TERMCAP_us=$(printf "\e[1;32m") \<br />
man "$@"<br />
}<br />
</pre><br />
<br />
To customize the colors, see [[Wikipedia:ANSI escape code]] for reference.<br />
<br />
=== Colored man pages on xterm ===<br />
<br />
:<small>''Source:[http://pub.ligatura.org/fs/xfree86/xresources/xterm XFree resources file for XTerm program]''</small><br />
<br />
A quick way to add color to a manual pages viewed on {{Codeline|xterm/uxterm}} can be made modifying the file {{Filename|~/.Xresources}}.<br />
<br />
Open that file in an editor and add this lines:<br />
<br />
<pre><br />
*VT100.colorBDMode: true<br />
*VT100.colorBD: red<br />
*VT100.colorULMode: true<br />
*VT100.colorUL: cyan<br />
</pre><br />
<br />
Save and run:<br />
<br />
<pre><br />
$ xrdb -load ~/.Xresources<br />
</pre><br />
<br />
Launch a new {{Codeline|xterm/uxterm}}, you will see colorful manual pages.<br />
This combination put colors to ''bold'' and ''underlined'' words in {{Codeline|xterm/uxterm}}. You can play with different combinations of this attributes (see the [http://pub.ligatura.org/fs/xfree86/xresources/xterm sources] of this item).<br />
<br />
==Reading man pages with a browser==<br />
Instead of the standard interface, using browsers such as [[lynx]] and [[Firefox]] to view man pages allows users to reap info pages' main benefit: hyperlinked text.<br />
Additionally, [[KDE]] users can read man pages in Konqueror using:<br />
man:<name><br />
<br />
===Using Local Man Pages===<br />
First, install {{package AUR|man2html}} from the [[AUR]].<br />
<br />
Now, convert a man page:<br />
$ man free | man2html -compress -cgiurl man$section/$title.$section$subsection.html > ~/man/free.html<br />
<br />
Another use for {{codeline|man2html}} is exporting to raw, printer-friendly text:<br />
$ man free | man2html -bare > ~/free.txt<br />
<br />
The GNU implementation of man in the Arch repositories also has the ability to do this on its own:<br />
$ man -H free<br />
<br />
This will read your <code>BROWSER</code> environment variable to determine the browser. You can override this by passing the binary to the -H option.<br />
<br />
===Using Online Man Pages===<br />
There are several online databases of man pages, many of them listed on [[Wikipedia:Man_page#Repositories_of_manual_pages]], including:<br />
*[http://manpages.debian.net/ ''Debian GNU/Linux man pages'']<br />
*[http://leaf.dragonflybsd.org/cgi/web-man ''DragonFlyBSD manual pages'']<br />
*[http://www.freebsd.org/cgi/man.cgi ''FreeBSD Hypertext Man Pages'']<br />
*[http://www.manpages.spotlynx.com/ ''Linux and Solaris 10 Man Pages'']<br />
*[http://manpagehelp.net ''Linux/FreeBSD Man Pages''] with user comments<br />
*[http://linux.die.net/man/ ''Linux man pages at die.net'']<br />
* [http://www.kernel.org/doc/man-pages/ The Linux man-pages project at kernel.org]<br />
*[http://man-wiki.net/index.php/Main_Page Man-Wiki: ''Linux / Solaris / UNIX / BSD'']<br />
*[http://netbsd.gw.com/cgi-bin/man-cgi ''NetBSD manual pages'']<br />
*[http://developer.apple.com/documentation/Darwin/Reference/ManPages/index.html ''Mac OS X Manual Pages'']<br />
*[http://unixhelp.ed.ac.uk/alphabetical/index.html ''On-line UNIX manual pages'']<br />
*[http://www.openbsd.org/cgi-bin/man.cgi ''OpenBSD manual pages'']<br />
*[http://man.cat-v.org/plan_9/ ''Plan 9 Manual — Volume 1'']<br />
*[http://man.cat-v.org/inferno/ ''Inferno Manual — Volume 1'']<br />
*[http://sfdoccentral.symantec.com/sf/5.0MP3/linux/manpages/index.html ''Storage Foundation Man Pages'']<br />
*[http://markhobley.yi.org/manpages/missingman.html ''The Missing Man Project''] [dead link as of 9 July 2010]<br />
*[http://en.linuxpages.info/index.php?title=Main_Page ''Gobuntu Manual Pages''] [dead link as of 9 July 2010]<br />
*[http://www.unix.com/man-page/OpenSolaris/1/man/ ''The UNIX and Linux Forums Man Page Repository'']<br />
*[http://manpages.ubuntu.com/ ''Ubuntu Manpage Repository'']</div>Nolby