📜  Linux 中的 apropos 命令和示例(1)

📅  最后修改于: 2023-12-03 15:17:21.496000             🧑  作者: Mango

Linux 中的 apropos 命令和示例

apropos 命令是 Linux 中用于搜索系统中所有可用命令和它们所对应的宏和函数说明的命令。通过 apropos 命令,可以方便地查询某个具体功能或关键词相关的命令和说明信息。

语法
apropos [OPTION]... KEYWORD...

其中,KEYWORD 为要查询的关键词。

常用的选项包括:

  • -a:查询所有的关键词,而不是只查询其中一个。
  • -w:只查询完全匹配的关键词,而不是包含该关键词的所有命令。
  • -r:使用正则表达式搜索。
示例
  1. 查询含有 "tar" 关键字的命令:
$ apropos tar

输出:

bcbtar (1)           - Backward-compatible tar file archiver
bsdtar (1)           - manipulate tape archives
gtar (1)             - the GNU version of the tar archiving utility
mate-terminal (1)    - a terminal emulation application
tar (1)              - The GNU version of the tar archiving utility
xzdec (1)            - Small .xz and .lzma decompressors
  1. 查询含有 "file" 和 "search" 关键字的命令:
$ apropos file search

输出:

ack (1)              - grep-like text searcher
adept_search (8)     - Search Adept's packages database
auxfuzz (1)          - auxiliary fuzzer for the tar program and others
bwctl (1)            - administrators' tool for bulk transfer measurement, p...
cpio (1)             - copy files to and from archives
crashmail (1)        - let Postfix report bounces submitted to the local pos...
find (1)             - search for files in a directory hierarchy
grep (1)             - print lines that match patterns
hunspell (1)         - speling checker
iconv (1)            - Convert encoding of given files from one encoding to ...
locate (1)           - find files by name
lsm_release (1)      - Set the release of an LSM rule.
lspatch (1)          - apply patch file to binary file and produce a patched...
lzmainfo (1)         - show information stored in an lzma compressed file
magic (5)            - file command's magic pattern file
numgrep (1)          - Find numbers in text stream
pgrep (1)            - look up or signal processes based on name and other a...
psearch (1)          - Interactive grep-like tool for searching in Python mo...
rgrep (1)            - print lines matching a pattern recursively
rsync (1)            - a fast, versatile, remote (and local) file-copying to...
slocate (8)          - security-enhanced locate
tar (1)              - The GNU version of the tar archiving utility
uniq (1)             - report or omit repeated lines
updatedb (8)         - update a database for mlocate
xargs (1)            - build and execute command lines from standard input
zsoelim (1)          - uncompress named files in temporary files
  1. 查询以 "cr" 开头的命令:
$ apropos '^cr'

输出:

create-crash-report (1) - compress and copy a crashed device's data to a desti...
crontab (1)           - maintain crontab files for individual users (Vixie Cr...
cron (8)              - daemon to execute scheduled commands (Vixie Cron)
crash (8)             - Analyze Linux crash dump data.
crash-vmlinux (8)     - Analyze Linux kernel crash dump data.
createdb (1)          - create a new PostgreSQL database
createuser (1)        - define a new PostgreSQL user account
crontab (5)           - tables for driving cron
cracklib-check (8)    - Check passwords using libcrack2
cracklib-format (8)   - Encode passwords in libcrack2's format, with folding
cracklib-packer (8)   - Generate hash indexes for cracklib dictionaries
cracklib-unpacker (8) - Unpack a cracklib dictionary file
crywrap (1)           - cryptographic wrapper tool using ssh for tunneling

可以看到,以上三个示例均各自说明了 apropos 命令的便利之处。通过查询命令关键字,可以快速地找到所需的命令,并查看命令说明信息,以便下一步操作。