六、在Linux中获取帮助-灵析社区

秋月无边

📜6.1 查看命令的帮助

📑6.1.1 内部命令帮助

  • help COMMAND
  • man bash

范例:


[root@servera ~]# type history
history is a shell builtin
[root@servera ~]# 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.


📑6.1.2 外部命令和软件帮助

  • COMMAND --help 或 COMMAND -h
  • 使用 man 手册(manual): man COMMAND
  • 信息页:info COMMAND
  • 程序自身的帮助文档:README、INSTALL、ChangeLog
  • 程序官方文档
  • 相关网站 CSDN
  • 搜索引擎 百度,谷歌

📜6.2 --help 或 -h 选项

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

范例:


[root@servera ~]# 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.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING          display time described by STRING, not 'now'

[root@servera ~]# cal -h

Usage:
 cal [options] [[[day] month] year]
 cal [options] <timestamp|monthname>

Display a calendar, or some part of it.
Without any arguments, display the current month.


📜6.3 man命令

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

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

中文man需安装包

  • man-pages
  • man-pages-zh-CN

man章节

man 页面分组为不同的“章节”,统称为Linux手册,man 1 man

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

查看man手册

man [章节] keyword


man page 导航



阅读man page

标题

  • Name 主题名称。通常是命令或文件名。非常简短的描述。
  • SYNOPSIS 命令语法的概要
  • DESCRIPTION 提供对主题的基本理解的深度描述
  • OPTIONS 命令执行选项说明
  • EXAMPLES 有关如何使用命令、功能或文件的示例。
  • FLIES 与 man page 相关的文件和目录的列表
  • BUGS 软件中的已知错误


man 常用选项

mandb 更新whatis数据库


列出所有帮助

man -a keyword


搜索man手册

#列出所有匹配的页面,使用 whatis 数据库
man -k keyword


相当于 whatis

man -f keyword


打印man帮助文件的路径

man -w [章节] keyword


📜6.4 info

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

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

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

每一页分为“节点”

链接节点之前

info 命令格式

info [命令]


导航info页

  • 方向键,PgUp,PgDn 导航
  • U 返回父链接
  • D 返回首页

阅读量:497

点赞量:0

收藏量:0