linux 命令:whatis详解

名称

        whatis - 展示手册页面描述

用法

        whatis [-dlv?V] [-r|-w] [-s list] [-m system[,...]] [-M path] [-L locale] [-C file] name ...

描述

        每个手册页面有一个简短的描述。whatis 搜索手册页名称,展示手册页描述。name 可          以包含通配符 (-w) 或正则表达式 (-r)。 使用这些选项时,可能需要引用名称或转义 (\)            特殊字符以阻止 shell 解释它们。索引数据库在搜索过程中使用,并由 mandb 程序更            新。根据你的安装,这可能由定期 cron 作业运行,或者可能需要在安装新的手册页后            手动运行。 要从相对索引数据库生成旧式文本 whatis 数据库,请发出以下命令:

        whatis -M manpath -w '*' | sort > manpath/whatis

        在这里 manpath 是一个手册页目录比如 /usr/man 。

选项

        -d,--debug

                打印调试信息。

        -v,--verbose

                打印详细警告消息。

        -r,--regex

                正则匹配 name。如果 name 与页面名称的任何部分匹配,则会进行匹配。 由于                    数据库搜索的性质,此选项会导致 whatis 变慢。

        -w,--wildcard

                使用通配符匹配 name。要进行匹配,扩展名称必须与整个页面名称匹配。 由于                    数据库搜索的性质,此选项会导致 whatis 变慢。

        -l,--long

                不要将输出修改为终端宽度。 通常,输出将被截断为终端宽度,以避免因 NAME                  部分编写不当而导致丑陋的结果。

        -s list,--sections list,--section list

                仅搜索给定的手册部分。list 是以冒号或逗号分隔的部分列表。如果列表中的条目                  是一个简单的部分,例如“3”,那么显示的描述列表将包括“3”、“3perl”、“3x”等部                    分中的页面; 而如果列表中的条目具有扩展名,例如“3perl”,则列表将仅包含手                    册部分的该部分中的页面。

        -m system[,...],--systems=system[,...]

                如果这个 system 可以访问其他操作系统的手册页名称,则可以使用此选项访问它                  们。 要搜索 NewOS 的手册页名称,请使用选项 -m NewOS。指定的系统可以是                  逗号分隔的操作系统名称的组合。 要包括对本机操作系统手册页名称的搜索,请                    在参数字符串中包括系统名称 man。 此选项将覆盖 $SYSTEM 环境变量。

        -M path,--manpath=path

                指定一组备用的以冒号分隔的手册页层次结构进行搜索。 默认情况下,whatis 使                  用 $MANPATH 环境变量,除非它为空或未设置,在这种情况下,它将根据你的                    $PATH 环境变量确定适当的 manpath。 此选项会覆盖 $MANPATH 的内容。

        -L locale,--locale=locale

                whatis 通常会通过调用 C 函数 setlocale 来确定你当前的语言环境,该函数询问各                  种环境变量,可能包括 $LC_MESSAGES 和 $LANG。 要临时覆盖确定的值,请                  使用此选项直接向 whatis 提供区域设置字符串。 请注意,在实际开始搜索页面之                  前,它不会生效。 诸如帮助消息之类的输出将始终以最初确定的语言环境显示。

        -C file,--config-file=file

                使用用户配置文件 file 而不是 ~/.manpath。

        -?,--help

                打印帮助文档,退出。

        --usage

                打印简短的帮助文档,退出。

        -V,--version

                展示版本信息。

退出状态

        0        成功执行。

        1        使用、格式、或配置文件错误。

        2        操作错误。

        16      没有找到。

环境变量

        SYSTEM        如果设置了 $SYSTEM,则其效果与将其指定为 -m 选项的参数相同。

        MANPATH      如果设置了 $MANPATH,它的值被解释为要使用的以冒号分隔的手册页                                 层次结构搜索路径。

        MANWIDTH   如果设置了 $MANWIDTH,其值将用作终端宽度(请参阅 --long 选                                         项)。 如果未设置,将使用 ioctl(如果可用)、$COLUMNS 的值计算                                   终端宽度,如果所有其他方法都失败,则返回到 80 个字符。

文件

        /usr/share/man/index.(bt|db|dir|pag)        传统全局索引数据库缓存。

        /var/cache/man/index.(bt|db|dir|pag)        符合 FHS 的全局索引数据库缓存。

        /usr/share/man/.../whatis                          传统 whatis 文本数据库。 

使用示例:

1. whatis:精确匹配

[root@server ~]# whatis ls
ls (1)               - list directory contents
[root@server ~]# whatis cd
cd (1)               - bash built-in commands, see bash(1)

2. whatis -r:正则匹配

[root@server ~]# whatis -r ^ls$
ls (1)               - list directory contents

[root@server ~]# whatis -r ^ls
ls (1)               - list directory contents
lsattr (1)           - list file attributes on a Linux second extended file system
lsb_release (1)      - manual page for FSG lsb_release v2.0
lsblk (8)            - list block devices
lscpu (1)            - display information about the CPU architecture
lsinitrd (1)         - tool to show the contents of an initramfs image
lsipc (1)            - show information on IPC facilities currently employed in the system
lslocks (8)          - list local system locks
lslogins (1)         - display information about known users in the system
lsmem (1)            - list the ranges of available memory with their online status
lsmod (8)            - Show the status of modules in the Linux Kernel
lsns (8)             - list namespaces
lsof (8)             - list open files
lspci (8)            - list all PCI devices
lsscsi (8)           - list SCSI devices (or hosts) and their attributes

[root@server ~]# whatis -r ls$
ExtUtils::Constant::Utils (3pm) - helper functions for ExtUtils::Constant
ls (1)               - list directory contents
pam_shells (8)       - PAM module to check for valid login shell
systemd-cgls (1)     - Recursively show control group contents
tc-cbq-details (8)   - Class Based Queueing

3. whatis -w:通配符匹配

[root@server ~]# whatis -w ls
ls (1)               - list directory contents

[root@server ~]# whatis -w ls*
ls (1)               - list directory contents
lsattr (1)           - list file attributes on a Linux second extended file system
lsb_release (1)      - manual page for FSG lsb_release v2.0
lsblk (8)            - list block devices
lscpu (1)            - display information about the CPU architecture
lsinitrd (1)         - tool to show the contents of an initramfs image
lsipc (1)            - show information on IPC facilities currently employed in the system
lslocks (8)          - list local system locks
lslogins (1)         - display information about known users in the system
lsmem (1)            - list the ranges of available memory with their online status
lsmod (8)            - Show the status of modules in the Linux Kernel
lsns (8)             - list namespaces
lsof (8)             - list open files
lspci (8)            - list all PCI devices
lsscsi (8)           - list SCSI devices (or hosts) and their attributes

[root@server ~]# whatis -w *ls
ExtUtils::Constant::Utils (3pm) - helper functions for ExtUtils::Constant
ls (1)               - list directory contents
pam_shells (8)       - PAM module to check for valid login shell
systemd-cgls (1)     - Recursively show control group contents
tc-cbq-details (8)   - Class Based Queueing
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值