linux查看帮助信息,命令帮助信息的获取

获取命令的的获取

Linux中命令分为内建命令和外部命令,内建命令是shell自带的命令。在获取命令帮助信息时,先确定命令是内建命令还是外部命令,使用type命令,可以查看命令的类型。外部命令获取帮助信息有以下几种方式:

使用命令自带的简要格式的使用帮助

使用man帮助文档手册,用man命令查看

使用info command获取命令的在线文档

查看应用程序自带的帮助文档:/usr/share/doc/command-VERSION

主流发行版官方文档

程序官方文档

type:

语法

type command

实例

内建命令

[root@localhost ~]# type echo

echo 是 shell 内嵌

外部命令

[root@localhost ~]# type wc

wc 是 /usr/bin/wc

内建命令获取帮助

内建命令获取帮助信息使用用help命令

命令格式:

~]#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,

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.

外部命令使用帮助

1. 命令自带的简要个格式使用帮助

语法

COMMAND –help

实例

[root@localhost ~]# wc –help

用法:wc [选项]… [文件]…

或:wc [选项]… –files0-from=F

Print newline, word, and byte counts for each FILE, and a total line if

more than one FILE is specified. With no FILE, or when FILE is -,

read standard input. A word is a non-zero-length sequence of characters

delimited by white space.

The options below may be used to select which counts are printed, always in

the following order: newline, word, character, byte, maximum line length.

-c, –bytes print the byte counts

-m, –chars print the character counts

-l, –lines print the newline counts

–files0-from=文件 从指定文件读取以NUL 终止的名称,如果该文件被

指定为”-“则从标准输入读文件名

-L, –max-line-length 显示最长行的长度

-w, –words 显示单词计数

–help 显示此帮助信息并退出

–version 显示版本信息并退出

GNU coreutils online help:

请向 报告wc 的翻译错误

要获取完整文档,请运行:info coreutils ‘wc invocation’

2. manual帮助文档手册

man命令是Linux下的帮助指令,通过man指令可以查看Linux中的指令帮助、配置文件帮助和编程帮助等信息。帮助文档手册存放在/usr/share/man目录下。

语法

man COMMAND

查看指定#章节帮助

man # COMMAND

选项

-a:在所有的man帮助手册中搜索

-f:等价于

-P:指定内容时使用分页程序;

-M:指定man手册搜索的路径。

章节

1 Executable programs or shell commands用户命令章节,所有使用户都可以使用

2 System calls (functions provided by the kernel)系统调用命令章节(由内核提供的函数);

3 Library calls (functions within program libraries)c库调用章节(由库程序提供的函数);

4 Special files (usually found in /dev)设备及特殊文件帮助文档;

5 File formats and conventions eg /etc/passwd配置文件的格式及相关参数;

6 Games 游戏帮助文档;

7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)杂项帮助文档;

8 System administration commands (usually only for root)系统管理命令使用帮助文档;

9 Kernel routines [Non standard]内核程序代码的帮助文档;

手册各部分功能

NAME:命令名称及功能说明

SYNOPSIS:命令使用格式摘要;

DESCRIPTION:详细描述信息;

OPTIONS:选项详细说明;

AUTHOR:作者;

BUGS:报告程序bug的途径;

EXAMPLES:使用示例;

SEE ALSO:额外参考;

FILES:相关配置文件

manual手册中部分符号的意义:

[]:表示该符号内的内容为可选内容

<>:表示该符号内的内容为必选内容

a|b|c:多选一

…:同类内容可出现多次

man page手册页操作方法:

手册页man page是用less程序来查看的,可以方便地使屏幕上翻和下翻, 所以在man page里可以使用less的所有选项。

快捷键

空格键:项文件尾翻一屏

b:项文件首部翻一屏

ctrl+d:向文件尾部翻半屏

ctrl+u:向文件首部翻半屏

回车键:向文件尾部翻一行

k:向文件首部翻一行

G:跳转至最后一行

q:quit,退出

末行输入:

#G(末行模式下输入):跳转至指定的#行

1G(末行模式下输入):跳转至文件首部

/keyword:从文件首部向文件尾部依次查找,不区分大小写

?keyword:从文件尾部向文件首部依次查找

实例

查看wc命令帮助信息

[root@localhost ~]# man wc

查看sleep第3章节的帮助信息

[root@localhost ~]# whatis sleep

sleep (1) – 延迟指定数量的时间

sleep (3) – sleep for the specified number of seconds

sleep (1p) – suspend execution for an interval

sleep (3p) – suspend execution for an interval of time

[root@localhost ~]# man 3 sleep

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/105081

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值