在Linux系统中有数以千计的命令,而且很多的命令又有好多个参数,所以很大一部分不常用的命令或者参数我们恐怕不易记住。
然而当我们想使用的却又不知道具体的参数或者命令的时候怎么办呢,这时候就需要去获取命令的帮助了。
Linux系统中的命令分为两种,内部命令和外部命令,在获取命令帮助信息时,内部命令和外部命令的获取方式是有区别的;
内部命令:
(1) help COMMAND
[root@localhost ~]# 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,
外部命令:
(1)通过命令自带的帮助信息
COMMAND --helo
COMMAND -h
[root@localhost ~]# 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. Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with . -A, --almost-all do not list implied . and .. --author with -l, print the author of each file -b, --escape print C-style escapes for nongraphic characters --block-size=SIZE scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of 1,048,576 bytes; see SIZE format below -B, --ignore-backups do not list implied entries ending with ~ -c with -lt: sort by, and show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first
(2)使用man手册(manual)
man COMMAND
[root@localhost ~]# man tty TTY(1) User Commands TTY(1) NAME tty - print the file name of the terminal connected to standard input SYNOPSIS tty [OPTION]... DESCRIPTION Print the file name of the terminal connected to standard input. -s, --silent, --quiet print nothing, only return an exit status --help display this help and exit --version output version information and exit November 2015
手册页存放在/usr/share/man
man页面分组为不同的章节,不同的章节存放不同的内容,比如说 /bin/passwd和/ect/passwd,一个是用户命令,一个是存放密码的配置文件,查找时请按需查找。
查询命令所属的章节:whatis COMMADN 或者 man -k COMMAND
1: 用户命令
2: 系统调用
3: C库调用
4: 设备文件及特殊文件
5: 配置文件格式
6: 游戏
7: 杂项
8: 管理类的命令
9:Linux 内核API
man命令的快捷键:
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:翻至文件尾部
man命令的配置文件:/etc.man.config | man_db.conf
man搜索:在man出的文件中迅速找到关键字
/KEYWORD:以KEYWORD指定的字符串为关键字,从当前位置向文件尾部搜索 ,n: 下一个,N:上一个
(3) 信息页
man常用于命令参考,GNU工具info适合通用文档参考。
用法: info COMMADN
方向键,PgUp,PgDn 导航
ab键移动到下一个链接
d 显示主题目录
Home 显示主题首部
Enter进入选定链接
n/p/u/l进入下/前/上一层/最后一个链接
s文字文本搜索
q退出info
[root@localhost ~]# info tty File: coreutils.info, Node: tty invocation, Prev: printenv invocation, Up: Working context 19.4 'tty': Print file name of terminal on standard input ========================================================= 'tty' prints the file name of the terminal connected to its standard input. It prints 'not a tty' if standard input is not a terminal. Synopsis: tty [OPTION]... The program accepts the following option. Also see *note Common options::. '-s' '--silent' '--quiet' Print nothing; only return an exit status. Exit status: 0 if standard input is a terminal 1 if standard input is not a terminal 2 if given incorrect arguments --zz-Info: (coreutils.info.gz)tty invocation, 26 lines --Top------------------------------------------------------------------------------------
(4) 程序自带的帮助文档
在 /usr/share/doc目录下,多数安装了的软件包的子目录,包括了这些软件的相关原理说明。
[root@localhost share]# cat /usr/share/doc/openssl-1.0.1e/README OpenSSL 1.0.1e 11 Feb 2013 Copyright (c) 1998-2011 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson All rights reserved. WARNING ------- This version of OpenSSL is built in a way that supports operation in the so called FIPS mode. Note though that the library as we build it is not FIPS validated and the FIPS mode is present for testing purposes only. This version also contains a few differences from the upstream code some of which are: * There are added changes forward ported from the upstream OpenSSL 0.9.8 FIPS branch however the FIPS integrity verification check is implemented differently from the upstream FIPS validated OpenSSL module. It verifies HMAC-SHA256 checksum of the whole shared
(5) 程序官方文档
(6)发行版官方文档
通过发行版官方的文档光盘或网站可以获得
安装指南
部署指南
虚拟化指南
(7)Google (终极大招)