linux获取命令帮助详解

获取帮助的能力决定了你技术能力。

本篇博文教你如何获取命令的帮助文档,如通过help、man和本地安装的方法进行查询。

一、linux中命令的类型

linux 中命令类型分为内部命令和外部命令。
type命令是判断一个命令是外部命令还是内部命令,示例如下:

[root@centos7 ~]#type cd           
cd is a shell builtin               #cd是shell 的内置命令
[root@centos7 ~]#type passwd
passwd is /usr/bin/passwd           #passwd命令存放在/usr/bin/passwd路径下

二、使用man命令获取外部命令帮助信息

man手册分为以下几个章节,但并不是每个命令都包含这些章节。
man章节:

        1 用户命令
        2 系统调用
        3 从库调用
        4 备文件及特殊文件
        5 置文件格式
        6 游戏
        7 杂项
        8 理类的命令
        9 linux的内核API

man命令的手册页存放在/usr/shar/man
man命令的的配置文件:/etc/man.config (CentOS 6)|man_db.conf(CentOS 7)

whatis命令是列出一个命令中manual章节的概述

        [root@centos7 ~]#whatis ls
        ls (1)               - list directory contents
        ls (1p)              - list directory contents

此命令在刚刚安装好的系统中可能不能正常使用;可以手动创建数据库,使用命令makewhatis(CentOS 6);文件存在的位置在/var/cache/man/中。mandb更新数据库(CentOS 7)

一般使用man命令获取帮助的步骤:
type COMMAND –>whatis COMMAND –>man # COMMAND

man命令使用

-a 列出所有帮助信息
-k 搜索关键字,列出所有匹配的页面

        [root@centos7 ~]#man -k passwd
            chpasswd (8)         - update passwords in batch mode
            fgetpwent_r (3)      - get passwd file entry reentrantly
            getpwent_r (3)       - get passwd file entry reentrantly
            gpasswd (1)          - administer /etc/group and /etc/gshadow
            grub2-mkpasswd-pbkdf2 (1) - Generate a PBKDF2 password hash.
            lpasswd (1)          - Change group or user password
            lppasswd (1)         - add, change, or delete digest passwords.
            pam_localuser (8)    - require users to be listed in /etc/passwd
            passwd (1)           - update user's authentication tokens
            sslpasswd (1ssl)     - compute password hashes
            passwd (5)           - password file
            passwd2des (3)       - RFS password encryption
            pwhistory_helper (8) - Helper binary that transfers password hashes from pa...
            saslpasswd2 (8)      - set a user's sasl password
            smbpasswd (5)        - The Samba encrypted password file
            vncpasswd (1)        - change the VNC password

-f 相当于whatis命令

        [root@centos7 ~]#man -f ls
        ls (1)               - list directory contents
        ls (1p)              - list directory contents

-w # 显示路径

    [root@centos7 ~]#man -w ls
    /usr/share/man/man1/ls.1.gz

三、help获取命令帮助

1.查看内部命令 help COMMAND

        [root@centos7 ~]#help cd
        cd: cd [-L|[-P [-e]]] [dir]
            Change the shell working directory.

            Change the current directory to DIR.  The default DIR is the value of the
            HOME shell variable.

2.查看外部命令 COMMAND –help | -h

        [root@centos7 ~]#ls --help
        Usage: ls [OPTION]... [FILE]...
        List information about the FILEs (the current directory by default).
        Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

四、通过本地文档获取帮助

本地文档存放在/usr/shar/man目录下
1、多数安装了的软件包的子目录,包括了这些软件的相关原理说明;
2、常见文档:README INSTALL CHANGES
3、可以通过自己手动安装帮助文档,默认安装在/usr/shar/man

         [root@centos7 ~]#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/httpd-manual-2.4.6-45.el7.centos.noarch.rpm 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值