5 个快速获取 Linux 命令帮助的方法

举报
Tiamo_T 发表于 2022/01/14 16:10:19 2022/01/14
【摘要】 请尝试以下方法,这将为您提供有关 Unix 命令的全面帮助。

请尝试以下方法,这将为您提供有关 Unix 命令的全面帮助。

1. 使用 apropos 搜索手册页

使用 apropos 在手册页中搜索有关特定功能的可用 Unix 命令。

$ apropos -r REGEXofUNIXCOMMAND or Description.

关于手册页中的 apropos 命令:

 apropos searches a set of database files containing short
       descriptions of system commands for keywords and displays
       the result on the standard output.

以下示例使用 apropos 显示所有可用的 grep 相关命令。

$ apropos grep
bzegrep (1)          - search possibly bzip2 compressed files for a regular expression
bzfgrep (1)          - search possibly bzip2 compressed files for a regular expression
bzgrep (1)           - search possibly bzip2 compressed files for a regular expression
egrep (1)            - print lines matching a pattern
fgrep (1)            - print lines matching a pattern
grep (1)             - print lines matching a pattern
pgrep (1)            - look up or signal processes based on name and other attributes
rgrep (1)            - print lines matching a pattern
zegrep (1)           - search possibly compressed files for a regular expression
zfgrep (1)           - search possibly compressed files for a regular expression
zgrep (1)            - search possibly compressed files for a regular expression
zipgrep (1)          - search files in a ZIP archive for lines matching a pattern

2.阅读命令的手册页

这是在任何 Unix 命令上获得快速帮助的简单且最有效的方法。我见过很多人(尤其是新手)厌倦了阅读手册页。

虽然 Unix 手册页可能没有很多实际示例,但它确实以详细的方式解释了命令的所有可用选项。


$ man UNIXCOMMAND

$ man tar

如果您不知道特定功能的确切命令名称,请使用 man -k 选项来定位该命令。

下面的示例列出了描述中包含“压缩”一词的所有可用命令。

$ man -k REGEX or UNIXCOMMAND

$ man -k compression
bzip2               (rpm) - A file compression utility.
gzip                (rpm) - The GNU data compression program.
zip                 (rpm) - A file compression and packaging utility compatible with PKZIP.
zlib                 (3)  - compression/decompression library
zlib                (rpm) - The zlib compression and decompression library.

3. 显示关于 Unix 命令的单行描述

要显示有关命令的单行描述,您可以使用 whatis 命令。

$ whatis UNIXCOMMAND

关于手册页中的 whatis 命令:

   whatis  searches a set of database files containing short descriptions
       of system commands for keywords and displays the result on the
       standard output.  Only complete word  matches are displayed.

以下示例显示有关 cron 命令的高级单行信息。

$ whatis cron
cron (8)             - daemon to execute scheduled commands (Vixie Cron)

4. 使用命令本身的 -h 或 –help 选项

有时您可能非常了解命令的功能,但无法记住特定命令的所有可用选项。使用命令的 -h 选项查看命令的所有可用选项。

$ UNIXCOMMAND -h

以下示例将显示有关 netstat 命令的快速帮助

$ netstat -h

5. 使用 Unix info 命令读取 Info 文档

当您无法从 Unix 手册页中找到所需的信息时,请使用 Unix info 命令尝试信息文档,如下所示。

$ info UNIXCOMMAND

$ info sed


【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200