三种方式:man info 与 whatis
如果你对一个命令不熟悉,怎么办?问命令行呗。如果你知道一个命令,却不知道有没有处理相关问题的参数,怎么办?问命令行呗
我觉得从命令行中获得帮助的方式大体分为两种,其一:使用该命令的 --help
参数。比如
mkdir --help
会输出:
需要指出的是,不是所有命令都支持help参数的方式返回手册。比如输入
pwd --help
会返回’invalid option‘无效选项
其二:就是使用专门的查看手册的命令,无论是man info还是whatis都是此种方式。
那么这三种方式有什么区别呢?我们来看一下三种方式对同一个命令的输出有何不同。
man
man 命令返回是这样的
整体看来,man返回的手册返回几个小节,比如NAME,SYNOPSIS。如果想获得参数的说明,man命令是很好的工具。
info
info命令返回更详细的文档,一般包括该命令的历史。和man比起来,描述更多一些,少了写格式化的风格,读起来更贴切。
whatis
会很简短的返回一句话,来描述该命令的功能。虽然没有列出来参数的使用方法,但是至少可以让我们确定是不是有必要继续阅读man命令。
总上,如果你知道一个命令的名字,但是记不清该命令的用法,不如查看一下whatis命令,如果这个命令是你想要的,那么使用man命令查看相关的参数。如果还想了解更多,那就使用info命令吧。
man命令的用法
不加参数的man命令可以查看该命令的使用方法。但是如果想查找关于某方面的命令该怎么办呢。k
参数可以实现查找某方面的命令,比如directory。man man
知道,man -k
"Equivalent to apropos -r
"。
man -k directory
返回如下。
alphasort (3) - scan a directory for matching entries
basename (1) - strip directory and suffix from filenames
bindtextdomain (3) - set directory containing message catalogs
chacl (1) - change the access control list of a file or directory
chdir (2) - change working directory
chroot (2) - change root directory
chroot (8) - run command or interactive shell with special root dir...
closedir (3) - close a directory
dbus-cleanup-sockets (1) - clean up leftover sockets in a directory
depmod.d (5) - Configuration directory for depmod
dir (1) - list directory contents
dirfd (3) - get directory stream file descriptor
fchdir (2) - change working directory
fdopendir (3) - open a directory
find (1) - search for files in a directory hierarchy
futimesat (2) - change timestamps of a file relative to a directory fi...
get_current_dir_name (3) - get current working directory
getcwd (2) - get current working directory
getcwd (3) - get current working directory
getdents (2) - get directory entries
getdents64 (2) - get directory entries
getdirentries (3) - get directory entries in a filesystem-independent format
getwd (3) - get current working directory
git-clone (1) - Clone a repository into a new directory
git-mv (1) - Move or rename a file, a directory, or a symlink
git-stash (1) - Stash the changes in a dirty working directory away
helpztags (1) - generate the help tags file for directory
lookup_dcookie (2) - return a directory entry's path
ls (1) - list directory contents
mkdir (2) - create a directory
mkdirat (2) - create a directory
mkdtemp (3) - create a unique temporary directory
mkfontdir (1) - create an index of X font files in a directory
mklost+found (8) - create a lost+found directory on a mounted Linux secon...
mktemp (1) - create a temporary file or directory
modprobe.d (5) - Configuration directory for modprobe
mountpoint (1) - see if a directory is a mountpoint
oldfind (1) - search for files in a directory hierarchy
opendir (3) - open a directory
pam_mkhomedir (8) - PAM module to create users home directory
pwd (1) - print name of current/working directory
pwdx (1) - report current working directory of a process
readdir (2) - read directory entry
readdir (3) - read a directory
readdir_r (3) - read a directory
remove (3) - remove a file or directory
rewinddir (3) - reset directory stream
rmdir (2) - delete a directory
run-parts (8) - run scripts or programs in a directory
scandir (3) - scan a directory for matching entries
scandirat (3) - scan a directory for matching entries
seekdir (3) - set the position of the next readdir() call in the dir...
telldir (3) - return current location in directory stream
update-info-dir (8) - update or create index file from all installed info fi...
vdir (1) - list directory contents
versionsort (3) - scan a directory for matching entries
whois (1) - client for the whois directory service
返回命令和一句话说明。命令后面的数字表示该命令所属的分类。比如remove(3)和whois(1)中的数字代表如下意义,
- Executable programs or shell commands
3 Library calls (functions within program libraries)
详细代号见 man man