Linux使用过程中的四种帮助(可以理解为使用手册)


使用手册

    • (1)`whatis`
    • (2)`help`
    • (3)`man`
    • (4)`info`

(1)whatis whatis命令
是用于查询一个命令执行什么功能,并将查询结果打印到终端上。
等同于使用man -f命令
语法
whatis [xxx] //xxx:命令/系统调用/库函数/特殊文件名

示例
//1 [root@localhost ~]# whatis ls ls(1)- list directory contents ls(1p)- list directory contents//2 [root@localhost ~]# whatis cp cp(1)- copy files and directories cp(1p)- copy files//3 [root@localhost ~]# whatis chown chown(1)- change file owner and group chown(1p)- change the file ownership chown(2)- change ownership of a file chown(3p)- change owner and group of a file //4 [root@localhost ~]# whatis man man(1)- format and display the on-line manual pages man(1p)- display system documentation man(7)- macros to format man pages man(rpm) - A set of documentation tools: man, apropos and whatis. man-pages(rpm) - Man (manual) pages from the Linux Documentation Project. man.config [man](5)- configuration data for man

(2)help
先了解一下shell的概念:shell就是一个命令解释器,当你在linux界面发出一个指令时,命令先传到shell,然后在将这个指令翻译成计算机可以识别的二进制语言,然后传给计算机内核,告诉他要做什么事情。计算机内核将结果返还给shell,shell翻译成人所熟悉的语言,将结果展示出来
语法
help [xxx] //只能用于内部命令,不能用于外部命令 //内部命令:就是shell程序的一部分,在系统启动时就加载进入内存,时常驻内存的, 所以我们执行内部命令的时候执行速度比较快

[xxx] --help //用于外部命令,也是最常用的 //外部命令:也就是文件系统命令,它不是shell程序组成部分,是shell程序之外的程序, 使用时需要从硬盘读取入内存,所以相对来说速度就慢一点。

help help xxx xxx --help
note:区分内部命令和外部命令:使用type命令可以区分
示例
//1 [root@localhost ~]# type cd cd is a shell builtin[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, the word is assumed to bea 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 statusThe 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.[root@localhost ~]# cd --help bash: cd: --: invalid option cd: usage: cd [-L|[-P [-e]]] [dir]//2 [root@localhost ~]# type ll ll is aliased to `ls -l --color=auto' [root@localhost ~]# help ll bash: help: no help topics match `ll'.Try `help help' or `man -k ll' or `info ll'. [root@localhost ~]# ll --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, --alldo not ignore entries starting with . -A, --almost-alldo not list implied . and .. --authorwith -l, print the author of each file 。。。。。。此处省略超级多

(3)man man命令
是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。
man man
查看man的使用方法
man page大致分为一下部分:
NAME:简单命令、数据名称说明
SYNOPSIS:简短的命令语法(sysntax)简介
DESCRIPTION:较为完整的说明,需要认真阅读
OPTION:针对SYNOPSIS中列举的所有可用选项说明
COMMANDS:当这个软件在执行的时候,可用在此软件中使用命令
FILES:这个软件或数据所使用或参考或链接到的文件
SEE ALSE:可以参考的,与这个命令有关的其他说明
EXAMPLE:一些可以参考的范例,这个最好用
BUGS:是否有相关的bug
使用小技巧:
ctrl + F或者Page Down:向下翻页
ctrl + B或者Page Up:向上翻页
gg到第一行
GG到最后一行
/start:能在整手册中搜索start相关字符,使用n查找下一个,使用N查找上一个
j,k与vi中一样使用,j向下一行,k向上一行
d下翻半页
u上翻半页
h获取man使用帮助
q退出man
man section,使用man时可以指定不同的section来浏览
section mean 含义
1 Executable programs or shell commands 是标准用户命令(普通的命令)
2 System calls (functions provided by the kernel) 系统调用
3 Library calls (functions within program libraries) 库调用
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd 是指文件的格式,比如passwd, 就会说明这个文件中各个字段的含义
6 Games 游戏
7 Miscellaneous (including macro packages and conventions), e.g. man(7),groff(7) 附件还有一些变量,比如向environ这种全局变量在这里就有说明
8 System administration commands (usually only for root) 系统管理用的命令,这些命令只能由root使用,如ifconfig
9 Kernel routines [Non standard] 其他
示例
//1 [root@localhost ~]# man 1 ls//2 [root@localhost ~]# man 3 printf

(4)info info命令
是Linux下info格式的帮助指令。
【Linux使用过程中的四种帮助(可以理解为使用手册)】就内容来说,info页面比man page编写得要更好、更容易理解,也更友好,但man page使用起来确实要更容易得多。一个man page只有一页,而info页面几乎总是将它们的内容组织成多个区段(称为节点),每个区段也可能包含子区段(称为子节点)。理解这个命令的窍门就是不 仅要学习如何在单独的Info页面中浏览导航,还要学习如何在节点和子节点之间切换。可能刚开始会一时很难在info页面的节点之间移动和找到你要的东 西,真是具有讽刺意味:原本以为对于新手来说,某个东西比man命令会更好些,但实际上学习和使用起来更困难。
示例
[root@localhost ~]# info info

    推荐阅读