在 Linux 中常常需要執行指令,在不知道指令或是參數之前都會看手冊

使用 man 指令時,容易因為有相同名稱檔案或指令而導致看錯手冊

舉個例子像是 passwd

passwd 這同時有指令 /usr/bin/passwd 的手冊,也是檔案 /etc/passwd 的手冊

這時需要查一下有哪些 manual

查名稱有 passwd 的手冊

man -f passwd
passwd (1)           - change user password
passwd (1ssl)        - compute password hashes
passwd (5)           - the password file
-f, --whatis:
    same as whatis(1).
    Search for all words in expression in manual page names only.

查名稱包含 passwd 的手冊

man -k passwd
chgpasswd (8)        - update group passwords in batch mode
chpasswd (8)         - update passwords in batch mode
gpasswd (1)          - administer /etc/group and /etc/gshadow
grub-mkpasswd-pbkdf2 (1) - generate hashed password for GRUB
mkpasswd (1)         - Overfeatured front end to crypt(3)
openssl-passwd (1ssl) - compute password hashes
pam_localuser (8)    - require users to be listed in /etc/passwd
passwd (1)           - change user password
passwd (1ssl)        - compute password hashes
passwd (5)           - the password file
update-passwd (8)    - safely update /etc/passwd, /etc/shadow and /etc/group
-k, --apropos:
    same as apropos(1).
    Support the full expression syntax. The search is case-insensitive and matches whole words only.

手冊的章節 section

此時會顯示跟 passwd 相關的手冊,括號中的數字表示手冊的章節

下面有所有章節的目錄

Manual Sections
the sections of the manual are:

    (1)     Executable programs or shell commands
    (2)     System calls (functions provided by the kernel)
    (3)     Library calls (functions within program libraries)
    (4)     Special files (usually found in /dev)
    (5)     File formats and conventions eg /etc/passwd
    (6)     Games
    (7)     Miscellaneous  (including  macro  packages  and  conventions)
    (8)     System administration commands (usually only for root)
    (9)     Kernel routines [Non standard]

上述例子輸出關於 passwd 的結果,章節 1 是指令的手冊;章節 5 是檔案的手冊

想看指令的手冊的話

man 1 passwd

想看檔案的手冊的話

man 5 passwd