Man page (한국어)

From ArchWiki
Jump to navigation Jump to search

Man pages ("manual pages"의 약어)는 아치 리눅스를 포함해 모든 UNIX와 비슷한 운영체제들에 기본적으로 제공되는 설명서들이며 man은 그 설명서들을 표시하는데 사용되는 명령어입니다.

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.

Man 문서 접근하는 방법

man 문서를 읽으려면 아래에 적힌 대로 입력한다.

$ man page_name

설명서들은 아래의 목록들로 정렬이된다.

  1. 일반 명령
  2. 시스템 콜 (커널에서 제공하는 함수들)
  3. 라이브러리 콜 (C 라이브러리 함수들)
  4. 특별한 파일들 (/dev 폴더에서 찾아서 사용랄 수 있는) 그리고 기기들
  5. 파일 포멧들 그리고 conventions
  6. 게임(?)
  7. 여러가지들.. (conventions에 포함된)
  8. 시스템 운영자 멘트 (root 권한을 가진) 그리고 데몬들

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:

$ man 5 passwd

to read the man page on /etc/passwd, rather than the passwd utility.

Very brief descriptions of programs can be read out of man pages without displaying the whole page using the whatis command. For example, for a brief description of ls, type:

$ whatis ls

and whatis will output "list directory contents."


Man pages all follow a fairly standard format, which helps in navigating them. Some sections which are often present include:

  • NAME - The name of the command and a one-line statement of its purpose.
  • SYNOPSIS - A list of the options and arguments a command takes or the parameters the function takes and its header file.
  • DESCRIPTION - A more in depth description of a command or function's purpose and workings.
  • EXAMPLES - Common examples, usually ranging from the simple to the relatively complex.
  • OPTIONS - Descriptions of each of the options a command takes and what they do.
  • EXIT STATUS - The meanings of different exit codes.
  • FILES - Files related to a command or function.
  • BUGS - Problems with the command or function that are pending repair. Also known as KNOWN BUGS.
  • SEE ALSO - A list of related commands or functions.
  • AUTHOR, HISTORY, COPYRIGHT, LICENSE, WARRANTY - Information about the program, its past, its terms of use, and its creator.

설명서 검색

Whilst the 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 -k or --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":

$ man -k password


$ man --apropos password

This is equivalent to calling the apropos command:

$ apropos password

The given keyword is interpreted as a regular expression by default.

Colored man pages

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.

There are two prevalent methods for achieving colored man pages: using most, or opting for less. The former is simpler to configure, at the expense of the advanced functionality that is native to less.

First method: using 'most'

Install most using pacman:

# pacman -S most

This is similar to less and more, yet allows rendering colored text in an easier way.

Edit /etc/man_db.conf, uncomment the pager definition and change it to:

DEFINE     pager     most -s

Test the new setup by typing:

$ man whatever_man_page

Modifying the color values requires editing ~/.mostrc (creating the file if it is not present) or editing /etc/most.conf for system-wide changes. Example ~/.mostrc:

% Color settings
color normal lightgray black
color status yellow blue
color underline yellow black
color overstrike brightblue black

Another example showing keybindings similar to less (jump to line is set to 'J'):

% less-like keybindings
unsetkey "^K"
unsetkey "g"
unsetkey "G"
unsetkey ":"

setkey next_file ":n"
setkey find_file ":e"
setkey next_file ":p"
setkey toggle_options ":o"
setkey toggle_case ":c"
setkey delete_file ":d"
setkey exit ":q"

setkey bob "g"
setkey eob "G"
setkey down "e"
setkey down "E"
setkey down "j"
setkey down "^N"
setkey up "y"
setkey up "^Y"
setkey up "k"
setkey up "^P"
setkey up "^K"
setkey page_down "f"
setkey page_down "^F"
setkey page_up "b"
setkey page_up "^B"
setkey other_window "z"
setkey other_window "w"
setkey search_backward "?"
setkey bob "p"
setkey goto_mark "'"
setkey find_file "E"
setkey edit "v"

Second method: using 'less'

Source: nion's blog - less colors for man pages

Alternatively, getting an approximate coloured result in manual pages with less is also a possibility. This method has the advantage that less has a bigger feature set than most, and that might be the preference for advanced users.

Add the following to a shell configuration file. For Bash it would be ~/.bashrc:

man() {
	env \
		LESS_TERMCAP_mb=$(printf "\e[1;37m") \
		LESS_TERMCAP_md=$(printf "\e[1;37m") \
		LESS_TERMCAP_me=$(printf "\e[0m") \
		LESS_TERMCAP_se=$(printf "\e[0m") \
		LESS_TERMCAP_so=$(printf "\e[1;47;30m") \
		LESS_TERMCAP_ue=$(printf "\e[0m") \
		LESS_TERMCAP_us=$(printf "\e[0;36m") \
			man "$@"

To customize the colors, see Wikipedia:ANSI escape code for reference.

Reading man pages with a browser

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. Additionally, KDE users can read man pages in Konqueror using:


Using Local Man Pages

First, install man2html from the AUR.

Now, convert a man page:

$ man free | man2html -compress -cgiurl man$section/$title.$section$subsection.html > ~/man/free.html

Another use for man2html is exporting to raw, printer-friendly text:

$ man free | man2html -bare > ~/free.txt

The GNU implementation of man in the Arch repositories also has the ability to do this on its own:

$ man -H free

This will read your BROWSER environment variable to determine the browser. You can override this by passing the binary to the -H option.

Using Online Man Pages

There are several online databases of man pages, many of them listed on Wikipedia:Man_page#Repositories_of_manual_pages, including: