|
获取帮助是学习Linux一个必须要掌握的命令,Linux提供了极为详细的帮助工具及文档,一定要养成查帮助文档的习惯,可以大大减少需要记忆的东西并提高效率,man命令是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。 使用帮助命令前要查看命令是内部命令还是外部命令,内部命令获取帮助使用--help命令而外部命令则使用man命令。在这里使用centos7系统为大家初步讲解一下Linux下怎样获取使用帮助。
查询命令是内部命令还是外部命令用type命令:
[iyunv@centos7 ~]# type cd
cd is a shell builtin
这里输出的结果显示cd命令为内部命令,要查询cd命令的使用帮助这里就需要使用help命令:
#help COMMAND (使用格式)
以cd命令为例:
[iyunv@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.
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.
If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed
-P use the physical directory structure without following symbolic
links
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
The default is to follow symbolic links, as if `-L' were specified.
Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.
我们都知道内部命令获取使用帮助使用help命令,那么我们来讲解一下外部命令获取使用帮助的方法;
首先可以使用man命令:# man COMMAND (命令格式);其次也可以使用# COMMAND --help;或者使用查询信息页# info COMMAND ;再或者查看程序自身的帮助文档README INSTALL ChangeLog
man命令:
首先man文件的位置:/usr/share 放置共享文件的地方;/usr/share/man:手册页存放;/usr/share/doc:软件杂项的文件说明
mandb数据库制作:
centos 7之中
[iyunv@centos7 ~]# mandb
Purging old database entries in /usr/share/man...
mandb: warning: /usr/share/man/man8/fsck.fat.8.manpage-fix.gz: ignoring bogus filename
Processing manual pages under /usr/share/man...
...
man命令的配置文件存放在/etc/man_db.conf
centos 6之中
[iyunv@centos6 ~]# makewhatis
man命令的配置文件存放在/etc/man.config
几乎每个命令都有man的“页面” ,man页面分组为不同的“章节”这些统称为Linux手册。
man [章节] COMMAND
1: 用户命令
2: 系统调用
3: C库调用
4: 设备文件及特殊文件
5: 配置文件格式
6: 游戏
7: 杂项
8: 管理类的命令
9:Linux 内核API
看懂man命令语法
[]:可选内容
<>:必须给出内容
a|b|c:多选一
…:同一个内容出现多次
man的参数:
man -a COMMAND
当COMMAND有多个man手册页时,首先打开的是man 1,不做任何操作使用q退出时,直接进入下一个man #(#为下一个章节)手册页。
man -k COMMAND 列出所有匹配的页面
man命令的操作方法:
使用less命令实现 Space, ^V, ^f, ^F: 向文件尾翻屏
b, ^B: 向文件首部翻屏
d, ^D: 向文件尾部翻半屏
u, ^U: 向文件首部翻半屏
RETURN, ^N, e, ^E or j or ^J: 向文件尾部翻一行
y or ^Y or ^P or k or ^K:向文件首部翻一行
q: 退出
#:跳转至第#行
1G: 回到文件首部
G:翻至文件尾部
/KEYWORD: 以KEYWORD指定的字符串为关键字,从当前位置向文件 尾部搜索;不区分字符大小写;
n: 下一个
N:上一个
?KEYWORD: 以KEYWORD指定的字符串为关键字,从当前位置向文件 首部搜索;不区分字符大小写;
n: 跟搜索命令同方向,下一个
N:跟搜索命令反方向,上一个
info COMMAND
有超链接稳文档,info是信息页,提供作者、版本,什么时候发布等更详细信息,man手册是告诉你怎么用
README
绝大多数程序都有相应的帮助文档,保存在/usr/share/doc文件夹中
|
|