星期三, 6月 11, 2008

Linux 使用 man 顯示 mkdir 的函式說明而不是指令說明的方法

前幾天在 ptt LinuxDev 回覆相同的問題,雖然很簡單,不過其實我以前也不知道。

用 man 指令來查 man (man man),可以看到最下面有提示,會發現相關指令有 whatis 跟 apropos 可以用,通常我們會用 whatis 來查有哪些 manual、 whereis 查檔案在哪、而另一個指令 apropos 可用來做模糊搜尋,通常來說 whatis 就很夠用了。

  • whatis --- 查 manual
  • whereis --- 查檔案位置
  • apropos --- 關聯搜尋
如果 whatis 出現 nothing appropriate 的訊息,這表示 whatis 的資料庫尚未建立,通常用最小方式安裝系統會出現這種訊息,可以用 /usr/sbin/makewhatis 來建立資料庫,如:
root# whatis mkdir
mkdir: nothing appropriate
root# man whatis
root# /usr/sbin/makewhatis
成功建立資料庫後正常訊息應該會像這樣:
root# man mkdir
mkdir                (1)  - make directories
mkdir                (1p)  - make directories
mkdir                (2)  - create a directory
mkdir                (3p)  - make a directory
root# man 3p mkdir
至於 linux man 指令編號的意義如下:
參考 Filesystem Hierarchy Standard - http://www.pathname.com/fhs/
man1 User programs
man2 System calls
man3 Library calls
man4 Special files (/dev)
man5 File formats
man6 Games
man7 Miscellaneous
man8 System administration
此外我們可以把 man 到的東西轉成 PDF:
man -t man | lp -Pps
一些常見用法:
man intro
man 3 intro
man -a intro
whatis intro
apropos intro
建議沒事時看一看的 manual:

ascii(7) A short, handy page that simply lists ASCII codes in tables—
very handy when you need to know silly details like the octal
constant for Ctrl+G.

boot(7) A nice overview of the kernel boot sequence. If you are trying
to build distribution from scratch or just want to learn how
Linux boots, this is a good read.

bootparam(7) A nice summary of the low-level options that the kernel can
take on the command line. This list is long, and it is most
assuredly not complete, but it is very informative.

charsets(7) A nice overview of character sets used in Linux, with a brief
overview of the features of each. If you work on internationalized
programs (i18n), this is a must read.

hier(7) A good overview of the Filesystem Hierarchy Standard, which
describes the conventions used to lay out the directories in a
Linux system. It answers burning questions like “What’s the
difference between /bin and /usr/bin?” If you are developing
an application for distribution, read this before you
decide where to install your files.

man(7) So you want to write a man page? This section tells you how,
giving you just enough troff to get by as well as an explanation
of the conventions used in Linux man pages.

operator(7) Lists the C operators and their precedence. If you hate using
extra parentheses in your code, you should study this man
page. After reading this page, you should be able to find the
bug in the following C statement:
if ( 1 & 2 == 2 ) printf("bit one is set\n");

regex(7) An introduction to regular expressions, which is a topic every
programmer should master.

suffixes(7) In Linux, file suffixes are conventions for the user. The OS
relies on more reliable techniques to determine a file type.
This man page describes many of the known conventional
suffixes in use. It is not complete but can be helpful.

units(7) Lists standard unit multipliers defined by SI.6 Did you know
that according to SI rules, a megabyte is actually 1,000,000
bytes and not 1,048,576 bytes (220 bytes)? Disk drive
manufacturers know this, and you should too. We software
developers tend to use the prefixes for decimal multipliers
when we mean to use the binary prefixes.
The SI defines unique prefixes for such binary values that
no one uses. Perhaps we should. By the way, 1,048,576 bytes
is properly called a mebibyte (abbreviated MiB). Although this
terminology is not likely to catch on any time soon, you must
be aware of the potential for confusion when you are talking
requirements with a scientist, hardware engineer, or disk drive
vendor.
There’s also some nifty trivia in here, such as the prefix for a
million billion billion. Impress your friends.

uri(7), url(7), Three keys for the same man page, describing the components
urn(7) of a URL and what they mean. You may think you know all
the things that can go into a URL, but check this page out
and see whether you learn anything.

沒有留言: