
它与 “man” 命令非常相似,但该命令只打印给定命令的一行说明。它可以方便地了解命令的用途,而不需要额外的细节。
whatis 命令的一般语法:
whatis [OPTIONS...] [COMMAND]
1. 显示(多个)命令的信息
whatis [command] [command]
whatis 命令可用于提供多个 Linux 命令的简要手册说明。为此,只需指定几条命令即可。
示例:
下面是运行 whatis ls mkdir 时可能看到的输出示例:
ls (1) - list directory contents mkdir (1) - make directories
在本例中:
- ls (1)是- ls命令,- (1)指的是- ls所在的手册章节。说明 “列出目录内容” 是对- ls命令作用的简要概括。
-  mkdir (1)是mkdir命令,(1)指的是mkdir所在的手册章节。关于 “创建目录” 的说明简要概括了mkdir命令的作用。
2. 显示调试信息
whatis -d [command]
要在终端中显示 Linux 命令的调试信息,请使用带有 -d 选项的 whatis 命令。
3. 通过正则表达式搜索
whatis -r [command]
-r 选项按关键字名称搜索命令。如果其中任何名称与页面名称的任何部分匹配,就会输出该匹配结果。
示例:
运行 whatis -r cp 时,将返回与正则表达式 cp 匹配的所有命令的列表。
cp (1) - copy files and directories cpio (1) - copy files to and from archives scp (1) - secure copy (remote file copy program) gcp (1) - advanced file copier
4. 按规则搜索命令
whatis -w [command* or *command]
使用 -w 选项可以使用通配符搜索 Linux 命令。指定一个模式,搜索与该条件规则匹配的命令。
示例:
whatis -w cd* 将显示 man 页中所有以 “cd” 开头的命令的描述。
cd (1) - change the shell working directory cdrecord (1) - record audio or data Compact Discs or Digital Versatile Discs from a master cdrdao (1) - writes audio CD-Rs in disc-at-once (DAO) mode cdparanoia (1) - an audio CD reading utility which includes extra data verification features
5. 使用其他操作系统的手册页
| 1 | whatis -m [manual_directory] [command] | 
通过 -m 选项可以访问包含要搜索的手册页面的目录路径。
示例:
如果从 /opt/myprogram/man 目录搜索 cat 命令,会得到以下结果:
cat (1) - concatenate files and print on the standard output
更多 Linux 命令
下面罗列了最常见的一些 Linux 命令,您可以根据自己的需要查阅对应命令的详细解析:
| 目录操作 | rmdir·cd·pwd·exa·ls | 
| 文件操作 | cat·cp·dd·less·touch·ln·rename·more·head | 
| 文件系统操作 | chown·mkfs·locate | 
| 网络 | ping·curl·wget·iptables·mtr | 
| 搜索和文本处理 | find·grep·sed·whatis·ripgrep·fd·tldr | 
| 系统信息和管理 | env·history·top·who·htop·glances·lsof | 
| 用户和会话管理 | screen·su·sudo·open | 
此外,我们还整理 Linux 命令行大全,以帮助大家全面深入地学习 Linux。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
    















暂无评论内容