您的位置:首页 > 运维架构 > Linux

Linux上获取命令帮助的几种方式

2017-01-01 11:00 495 查看
一.加参数-h或者--help
例如:
[root@ntp ~]# clock -h
hwclock - query and set the hardware clock (RTC)

Usage: hwclock [function] [options...]

Functions:
-h | --help         show this help
-r | --show         read hardware clock and print result
--set          set the rtc to the time given with --date
-s | --hctosys      set the system time from the hardware clock
-w | --systohc      set the hardware clock to the current system time
--systz        set the system time based on the current timezone
--adjust       adjust the rtc to account for systematic drift since
the clock was last set or adjusted
-c | --compare      periodically compare the system clock with the CMOS clock
--getepoch     print out the kernel's hardware clock epoch value
--setepoch     set the kernel's hardware clock epoch value to the
value given with --epoch
-v | --version      print out the version of hwclock to stdout

Options:
-u | --utc          the hardware clock is kept in UTC
--localtime    the hardware clock is kept in local time
-f | --rtc=path     special /dev/... file to use instead of default
--directisa    access the ISA bus directly instead of /dev/rtc
--badyear      ignore rtc's year because the bios is broken
--date         specifies the time to which to set the hardware clock
--epoch=year   specifies the year which is the beginning of the
hardware clock's epoch value
--noadjfile    do not access /etc/adjtime. Requires the use of
either --utc or --localtime
--adjfile=path specifies the path to the adjust file (default is
/etc/adjtime)
--test         do everything except actually updating the hardware
clock or anything else
-D | --debug        debug mode
[root@ntp ~]# dir --help
用法:dir [选项]... [文件]...
列出 FILE 的信息(默认为当前目录)。
如果不指定-cftuvSUX 或--sort 选项,则根据字母大小排序。

长选项必须使用的参数对于短选项时也是必需使用的。
-a, --all                     不隐藏任何以. 开始的项目
-A, --almost-all              列出除. 及.. 以外的任何项目
--author                  与-l 同时使用时列出每个文件的作者
-b, --escape                  以八进制溢出序列表示不可打印的字符
--block-size=大小         块以指定大小的字节为单位
-B, --ignore-backups          不列出任何以"~"字符结束的项目
-c                            配合-lt:根据ctime 排序并显示ctime(文件
状态最后更改的时间)
配合-l:显示ctime 但根据名称排序                                其他情况:按ctime 排序
-C                            每栏由上至下列出项目
--color[=WHEN]            控制是否使用色彩分辨文件。WHEN 可以是
"never"(默认)、"always"或"auto"其中之一
-d, --directory               当遇到目录时列出目录本身而非目录内的文件
-D, --dired                   产生适合Emacs 的dired 模式使用的结果
-f                            不进行排序,-aU 选项生效,-lst 选项失效
-F, --classify                加上文件类型的指示符号(*/=@| 其中一个)
--format=关键字           交错-x,逗号分隔-m,水平-x,长-l,
单栏-1,详细-l,垂直-C
--full-time               即-l --time-style=full-iso
-g                            类似-l,但不列出所有者
--group-directories-first
在文件前分组目录。此选项可与--sort 一起使用,
但是一旦使用--sort=none (-U)将禁用分组
-G, --no-group                以一个长列表的形式,不输出组名
-h, --human-readable          与-l 一起,以易于阅读的格式输出文件大小
(例如 1K 234M 2G)
--si                      同上面类似,但是使用1000 为基底而非1024
-H, --dereference-command-line
跟随命令行列出的符号链接
--dereference-command-line-symlink-to-dir
跟随命令行列出的目录的符号链接
--hide=PATTERN            隐藏符合PATTERN 模式的项目
(-a 或 -A 将覆盖此选项)
--indicator-style=方式    指定在每个项目名称后加上指示符号方式:
none (默认),classify (-F),file-type (-p)
-i, --inode                   显示每个文件的inode 号
-I, --ignore=PATTERN          不显示任何符合指定shell PATTERN 的项目
-k                            即--block-size=1K
-l                            使用较长格式列出信息
-L, --dereference             当显示符号链接的文件信息时,显示符号链接所指示
的对象而并非符号链接本身的信息
-m                            所有项目以逗号分隔,并填满整行行宽
-n, --numeric-uid-gid         类似 -l,但列出UID 及GID 号
-N, --literal                 输出未经处理的项目名称 (如不特别处理控制字符)
-o                            类似 -l,但不列出有关组的信息
-p,  --indicator-style=slash  对目录加上表示符号"/"
-q, --hide-control-chars      以"?"字符代替无法打印的字符
--show-control-chars      直接显示无法打印的字符 (这是默认方式,除非调用
的程序名称是"ls"而且是在终端输出结果)
-Q, --quote-name              将条目名称括上双引号
--quoting-style=方式      使用指定的quoting 方式显示条目的名称:
literal、locale、shell、shell-always、c、escape
-r, --reverse                 排序时保留顺序
-R, --recursive               递归显示子目录
-s, --size                    以块数形式显示每个文件分配的尺寸
-S                            根据文件大小排序
--sort=WORD               以下是可选用的WORD 和它们代表的相应选项:
extension -X       status   -c
none      -U       time     -t
size      -S       atime    -u
time      -t       access   -u
version   -v       use      -u
--time=WORD               和-l 同时使用时显示WORD 所代表的时间而非修改时
间:atime、access、use、ctime 或status;加上
--sort=time 选项时会以指定时间作为排序关键字
--time-style=STYLE        和-l 同时使用时根据STYLE 代表的格式显示时间:
full-iso、iso、locale、posix-iso、+FORMAT。
FORMAT 即是"date"所用的时间格式;如果FORMAT
是FORMAT1<换行>FORMAT2,FORMAT1 适用于较旧
的文件而FORMAT2 适用于较新的文件;如果STYLE
以"posix-"开头,则STYLE 仅在POSIX 语系之外
生效。
-t                            根据修改时间排序
-T, --tabsize=宽度    指定制表符(Tab)的宽度,而非8 个字符
-t                    按修改时间排序
-T, --tabsize=COLS    指定制表符(Tab)的宽度,而非8个字符
-u                    同-lt 一起使用:按照访问时间排序并显示
同-l一起使用:显示访问时间并按文件名排序
其他:按照访问时间排序
-U                    不进行排序;按照目录顺序列出项目
-v                    在文本中进行数字(版本)的自然排序
-w, --width=COLS           assume screen width instead of current value
-x                         list entries by lines instead of by columns
-X                         sort alphabetically by entry extension
-1                         list one file per line

SELinux options:

--lcontext                 Display security context.   Enable -l. Lines
will probably be too wide for most displays.
-Z, --context              Display security context so it fits on most
displays.  Displays only mode, user, group,
security context and file name.
--scontext                 Display only security context and file name.
--help            显示此帮助信息并退出
--version         显示版本信息并退出

SIZE 可以是一个可选的整数,后面跟着以下单位中的一个:
KB 1000,K 1024,MB 1000*1000,M 1024*1024,还有 G、T、P、E、Z、Y。

使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。

退出状态:
0  正常
1  一般问题 (例如:无法访问子文件夹)
2  严重问题 (例如:无法使用命令行参数)

请向bug-coreutils@gnu.org 报告dir 的错误
GNU coreutils 项目主页:<http://www.gnu.org/software/coreutils/>
GNU 软件一般性帮助:<http://www.gnu.org/gethelp/>
请向<http://translationproject.org/team/zh_CN.html> 报告dir 的翻译错误
要获取完整文档,请运行:info coreutils 'dir invocation'


二.使用help命令该命令适用于shell内建的命令例如:ls不是shell内建命令,而cd是shell内建命令,所以,可以使用help cd来查看cd命令的帮助信息
[root@ntp ~]# type ls
ls is aliased to `ls --color=auto'
[root@ntp ~]# type cd
cd is a shell builtin
[root@ntp ~]# help ls
-bash: help: no help topics match `ls'.  Try `help help' or `man -k ls' or `info ls'.
[root@ntp ~]# help cd
cd: cd [-L|-P] [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

The default is to follow symbolic links, as if `-L' were specified.

Exit Status:
Returns 0 if the directory is changed; non-zero otherwise.


三.使用info命令(似乎比man编排的更精致些)
例如:(截取)
[root@ntp ~]# info diff
File: diff.info,  Node: Top,  Next: Overview,  Up: (dir)

Comparing and Merging Files
***************************

This manual is for GNU Diffutils (version 2.8.1, 5 April 2002), and
documents the GNU `diff', `diff3', `sdiff', and `cmp' commands for
showing the differences between files and the GNU `patch' command for
using their output to update files.

Copyright (C) 1992, 1993, 1994, 1998, 2001, 2002 Free Software
Foundation, Inc.

Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.1 or any later version published by the Free Software
Foundation; with no Invariant Sections, with the Front-Cover texts
being "A GNU Manual," and with the Back-Cover Texts as in (a)
below.  A copy of the license is included in the section entitled
"GNU Free Documentation License."

(a) The FSF's Back-Cover Text is: "You have freedom to copy and
modify this GNU Manual, like GNU software.  Copies published by
the Free Software Foundation raise funds for GNU development."

* Menu:

* Overview::              Preliminary information.
* Comparison::            What file comparison means.

* Output Formats::        Formats for two-way difference reports.
* Incomplete Lines::      Lines that lack trailing newlines.
* Comparing Directories:: Comparing files and directories.
* Adjusting Output::      Making `diff' output prettier.
* diff Performance::      Making `diff' smarter or faster.

* Comparing Three Files:: Formats for three-way difference reports.
* diff3 Merging::         Merging from a common ancestor.

* Interactive Merging::   Interactive merging with `sdiff'.


四.使用man命令
man的九个章节:
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
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]

直接使用man命令
例如:(截取)
LILYIBMAPPQ1:~ # man dir
DIR(1)                                                                                        User Commands                                                                                        DIR(1)

NAME
dir - list directory contents

SYNOPSIS
dir [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort.

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

-C     list entries by columns

--color[=WHEN]
colorize the output.  WHEN defaults to `always' or can be `never' or `auto'.  More info below

-d, --directory
list directory entries instead of contents, and do not dereference symbolic links

-D, --dired
generate output designed for Emacs' dired mode
按键pageup、 pagedown可以上下翻页
按键q退出
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  system current hardware