文章目录
3.1 获得命令帮助
3.1.1whatis
命令概述:
whatis 命令是用于查询一个命令执行什么功能,并将查询结果打印到终端上,相当于man -f
使用语法
使用语法:
whatis 命令/系统调用/库函数/特殊文件名
参考示例:
chz@ubuntu:~$ whatis cp
cp (1) - copy files and directories
chz@ubuntu:~$ whatis chown
chown (1) - change file owner and group
chown (2) - change ownership of a file
chz@ubuntu:~$ whatis ls
ls (1) - list directory contents
chz@ubuntu:~$ whatis man
man (1) - 在线参考手册的接口
man (7) - macros to format man pages
3.1.2help
命令概述:
help命令用于显示shell内部命令的帮助信息,help命令只能显示shell内部命令的帮助信息,而linux系统中绝大多数命令是外部命令,所以help命令的作用非常有限。而对于外部命令的帮助信息可以使man命令或者info命令查看。
命令格式:
help [参数] 内部命令
查看外部命令: 外部命令 --help
常用参数
-d 输出每个命令的简短描述
-s 输出短格式的帮助信息
-m 以伪man手册的格式显示帮助信息
参考示例
显示cd命令的帮助信息
chz@ubuntu:~$ 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.
......
以短格式显示cd命令的帮助信息
chz@ubuntu:~$ help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
输出cd命令的简短描述
chz@ubuntu:~$ help -d cd
cd - Change the shell working directory.
以伪man手册格式输出cd命令的帮助信息
chz@ubuntu:~$ help -m cd
NAME
cd - Change the shell working directory.
SYNOPSIS
cd [-L|[-P [-e]] [-@]] [dir]
DESCRIPTION
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
......
3.1.3man
命令概述:
快速查询linux帮助手册,并且格式化显示。
使用语法:
man [参数] 命令
参数列表
参数名 | 作用 |
---|---|
-a | 在所有的man帮助手册中搜索 |
-d | 检查新加入的文件是否有错误 |
-f | 显示给定关键字的简短描述信息 |
-p | 指定内容时使用分页程序 |
-M | 指定man手册搜索的路径 |
-w | 显示文件所在位置 |
man中的快捷键
快捷键 | 功能 |
---|---|
q/ctrl+z | 退出 |
Enter | 按行下翻 |
Space | 按页下翻 |
b | 上翻一页 |
/字符串 | 在手册页中查找字符串 |
参考示例
查看指定命令的帮助信息:
chz@ubuntu:~$ man ls
找到某个命令的帮助信息存储:
chz@ubuntu:~$ man -w ls
/usr/share/man/man1/ls.1.gz
找到某个配置文件的帮助信息的存储位置
(如果即有passwd命令,又有/etc/passwd文件,则需要手动指定帮助信息的编号。编号规则:普通命令为1,函数为2,库文件为3,设备为4,配置文件为5,游戏为6,宏文件为7,系统命令为8,内核程序为9,TK指令为10)
chz@ubuntu:~$ man -w 5 passwd
/usr/share/man/zh_CN/man5/passwd.5.gz