Linux的帮助用法

whatis

whatis 使用数据库来显示命令的简短描述

此工具在系统刚安装后,不可立即使用,需要制作数据库后才可使用

执行下面命令生成数据库

#CentOS 7 版本以后
mandb 
#CentOS 6 版本之前
makewhatis

范例:

[root@centos8 ~]#whatis ls
ls: nothing appropriate.
​
#生成man相关数据库
[root@centos8 ~]#mandb
Processing manual pages under /usr/share/man...
Updating index cache for path `/usr/share/man/mann'. Wait...done.
Checking for stray cats under /usr/share/man...
...省略...0 
old database entries were purged.
[root@centos8 ~]#whatis ls
ls (1)               - list directory contents
​
[root@centos8 ~]#whatis 
calcal (1)              - display a calendar
cal (1p)             - print a calendar
[root@centos8 ~]#man -f cal
cal (1)              - display a calendar
cal (1p)             - print a calendar</pre>

查看命令的帮助

查看内部命令的帮助

  • help COMMAND

  • man bash

范例:

[20:49:21 root@centos8 ~]#type history 
history is a shell builtin
[21:05:29 root@centos8 ~]#help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
 Display or manipulate the history list.

 Display the history list with line numbers, prefixing each modified
 entry with a `*'.  An argument of N lists only the last N entries.

 Options:
 -c  clear the history list by deleting all of the entries
 -d offset  delete the history entry at position OFFSET.

 -a  append history lines from this session to the history file
 -n  read all history lines not already read from the history file
 and append them to the history list
 -r  read the history file and append the contents to the history
 list
 -w  write the current history to the history file

 -p  perform history expansion on each ARG and display the result
 without storing it in the history list
 -s  append the ARGs to the history list as a single entry

 If FILENAME is given, it is used as the history file.  Otherwise,
 if HISTFILE has a value, that is used, else ~/.bash_history.

 If the HISTTIMEFORMAT variable is set and not null, its value is used
 as a format string for strftime(3) to print the time stamp associated
 with each displayed history entry.  No time stamps are printed otherwise.

 Exit Status:
 Returns success unless an invalid option is given or an error occurs.</pre>

外部命令及软件帮助

  • COMMAND --help 或 COMMAND -h

  • 使用 man 手册(manual): man COMMAND

  • 信息页:info COMMAND

  • 程序自身的帮助文档:README、INSTALL、ChangeLog

  • 程序官方文档

  • 相关网站,如:技术论坛

  • 搜索引擎

外部命令的--help 或 -h

显示用法总结和参数列表,大多数命令使用,但并非所有的

[21:09:01 root@centos8 ~]#date --help
Usage: date [OPTION]... [+FORMAT]
 or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
​
[21:09:42 root@centos8 ~]#cal -h
Usage:
 cal [options] [[[day] month] year]
 cal [options] <timestamp|monthname>
​
[root@centos8 ~]#strace --help
strace: invalid option -- '-'
Try 'strace -h' for more information.
​
[root@centos8 ~]#openssl --help
Invalid command '--help'; type "help" for a list.
​
[root@centos8 ~]#date -h
date: invalid option -- 'h'
Try 'date --help' for more information.
​
[root@centos8 ~]#shutdown -h
Shutdown scheduled for Fri 2020-03-20 08:26:27 CST, use 'shutdown -c' to cancel

格式说明:

  • [] 表示可选项

  • CAPS或 <> 表示变化的数据

  • ... 表示一个列表

  • x |y| z 的意思是“ x 或 y 或 z ”

  • -abc的意思是 -a -b –c

  • { } 表示分组

man命令

man 提供命令帮助的文件,手册页存放在/usr/share/man

几乎每个命令都有man的“页面”

中文man需安装包

  • man-pages

  • man-pages-zh-CN

man 页面分组

不同类型的帮助称为不同的“章节”,统称为Linux手册,man 1 man

  • 1:用户命令

  • 2:系统调用

  • 3:C库调用

  • 4:设备文件及特殊文件

  • 5:配置文件格式

  • 6:游戏

  • 7:杂项

  • 8:管理类的命令

  • 9:Linux 内核API

man命令的配置文件:

#CentOS 6 之前版 man 的配置文件/
etc/man.config 
​
#CentOS 7 之后版 man 的配置文件
/etc/man_db.conf
​
#ubuntu  man 的配置文件
/etc/manpath.config

格式:

MANPATH /PATH/TO/SOMEWHERE   #指明man文件搜索位置

也可以指定位置下搜索COMMAND命令的手册页并显示

man -M /PATH/TO/SOMEWHERE COMMAND

查看man手册页

man [OPTION...] [SECTION] PAGE...
man  [章节]  keyword

man 帮助段落说明

  • NAME 名称及简要说明

  • SYNOPSIS 用法格式说明

  • [] 可选内容

  • <> 必选内容

  • a|b 二选一

  • { } 分组

  • ... 同一内容可出现多次

  • DESCRIPTION 详细说明

  • OPTIONS 选项说明

  • EXAMPLES 示例

  • FILES 相关文件

  • AUTHOR 作者

  • COPYRIGHT 版本信息

  • REPORTING BUGS bug信息

  • SEE ALSO 其它帮助参考

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:跟搜索命令反方向,上一个

常用选项

#列出所有帮助
man -a keyword
​
#列出所有匹配的页面,使用 whatis  数据库
man -k keyword
​
#相当于 whatis
man -f keyword
​
#打印man帮助文件的路径
man -w  [章节] keyword

范例:

[root@centos8 ~]#dnf install man-pages
[root@centos8 ~]#man -w 1 passwd
/usr/share/man/man1/passwd.1.gz
[root@centos8 ~]#whatis passwd
openssl-passwd (1ssl) - compute password hashes
passwd (1)           - update user's authentication tokens
[root@centos8 ~]#man 1ssl openssl-passwd
[root@centos8 ~]#man 7 ascii
[root@centos8 ~]#man 7 utf8

查看passwd相关命令和文件,man帮助文件路径

[root@centos8 ~]#whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

info

man常用于命令参考,GNU工具 info 适合通用文档参考

没有参数,列出所有的页面

info 页面的结构就像一个网站

每一页分为“节点”

链接节点之前 *

info 命令格式

info [ 命令 ]

导航info页

  • 方向键,PgUp,PgDn 导航

  • Tab键移动到下一个链接

  • d 显示主题目录

  • Home 显示主题首部

  • Enter进入选定链接

  • n/p/u/l 进入下/前/上一层/最后一个链接

  • s 文字文本搜索

  • q 退出 info

Linux 安装提供的本地文档获取帮助

Applications -> documentation->help(centos7)

System->help(centos6)

命令自身提供的官方使用指南

/usr/share/doc 目录

多数安装了的软件包的子目录,包括了这些软件的相关原理说明

常见文档:README INSTALL CHANGES

不适合其它地方的文档的位

置配置文件范例

HTML/PDF/PS 格式的文档

授权书详情

系统及第三方应用官方文档

通过在线文档获取帮助

https://www.kernel.org/doc/html/latest/

http://www.nginx.orghttps://dev.mysql.com/doc/

https://jenkins.io/zh/doc/

https://docs.openstack.org/train/

http://php.net

Linux官方在线文档和知识库命令

通过发行版官方的文档光盘或网站可以获得安装指南、部署指南、虚拟化指南等 通过发行版官方的文档光盘或网站可以获得安装指南、部署指南、虚拟化指南等

http://kbase.redhat.com

http://www.redhat.com/docs

http://access.redhat.com

https://help.ubuntu.com/lts/serverguide/index.html

http://tldp.org2.8.3

红帽全球技术支持服务

rhn.redhat.com或者本地卫星服务器/代理服务器

RHN账户为及其注册和基于网络管理的RHN用户

sosreport 收集所有系统上的日志信息的工具,并自动打成压缩包,方便技术支持人员和红帽全球支持提供分析问题依据

[root@centos8 ~]#dnf -y install sos 
[root@centos8 ~]#sosreport
sosreport (version 3.6)
This command will collect diagnostic and configuration information from
this CentOS Linux system and installed applications.
......

相关网站搜索

https://www.google.com

Openstack filetype:pdf
rhca site:redhat.com/docs
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。