Linux中如何使用帮助总结

简介:

1.写在前面

   一直以来,虽然知道有问题问男人,对LINUX的帮助没有认真使用过,不会了就baidu,google,今天认真学习了下各种帮助命令,才知道自己的基本功有多么差。


2.使用帮助前

如果,我们想查看命令的帮助,应该首先确定这个命令的类型。

1
2
3
4
5
[root@localhost /] # type cd
cd  is a shell  builtin
[root@localhost /] # type su
su  is  /bin/su
[root@localhost /] #

Linux的命令分为两种:

内置命令(SHELL内置)

外部命令(文件系统上必定存在相应可执行文件)

使用type COMMAND的方式获取命令类型。


3.help or --help or man or info

通过确定命令类型后,我们就要选择命令来查看帮助了。


4.结论一:help COMMAND

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@localhost /] # type cd
cd  is a shell  builtin
[root@localhost /] # help cd
cd cd  [-L|-P] [ dir ]
      Change the current directory to DIR.  The variable $HOME is the
     default DIR.  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, i.e. `.'.  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 then  try the word as a variable
     name.  If that variable has a value,  then  cd  to the value of that
     variable.  The -P option says to use the physical directory structure
     instead of following symbolic links; the -L option forces symbolic links
     to be followed.
[root@localhost /] #

如果是内置命令,我们可以通过:

help COMMAND

来查看COMMAND命令的帮助。如果我们对内置命令使用man,则会出现:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
BASH_BUILTINS(1)                                              BASH_BUILTINS(1)
NAME
        bash ,  :,  .,  [,   alias bg , bind,  break builtin cd command , compgen, complete,  continue declare dirs , disown,  echo enable eval exec exit export , fc,  fg ,
        getopts hash , help,  history , jobs,  kill let local logout popd printf pushd pwd read readonly return set shift shopt ,   source ,  suspend,   test ,   times ,
        trap type , typeset,  ulimit umask unalias unset , wait -  bash  built- in  commands, see  bash (1)
BASH BUILTIN COMMANDS
        Unless  otherwise noted, each  builtin  command  documented  in  this section as accepting options preceded by - accepts -- to signify the end of the options.  For exam-
        ple, the :,  true false , and  test  builtins  do  not accept options.
        : [arguments]
               No effect; the  command  does nothing beyond expanding arguments and performing any specified redirections.  A zero  exit  code is returned.
         .  filename [arguments]
        source  filename [arguments]
               Read and execute commands from filename  in  the current shell environment and  return  the  exit  status of the last  command  executed from filename.  If  filename
               does not contain a slash,  file  names  in  PATH are used to  find  the directory containing filename.  The  file  searched  for  in  PATH need not be executable.  When
               bash  is not  in  posix mode, the current directory is searched  if  no  file  is found  in  PATH.  If the sourcepath option to the  shopt  builtin   command   is  turned
               off,  the  PATH  is  not searched.  If any arguments are supplied, they become the positional parameters when filename is executed.  Otherwise the positional
               parameters are unchanged.  The  return  status is the status of the last  command  exited within the script (0  if  no commands are executed), and  false   if   file -
               name is not found or cannot be  read .
        alias  [-p] [name[=value] ...]
               Alias  with  no  arguments or with the -p option prints the list of aliases  in  the form  alias  name=value on standard output.  When arguments are supplied, an
               alias  is defined  for  each name whose value is given.  A trailing space  in   value causes the next word to be checked  for  alias  substitution when the  alias   is
               expanded.   For  each name  in  the argument list  for  which  no value is supplied, the name and value of the  alias  is printed.  Alias returns  true  unless a name
               is given  for  which  no  alias  has been defined.
        bg  [jobspec ...]
               Resume each suspended job jobspec  in  the background, as  if  it had been started with &.  If jobspec is not present, the shell's notion of the current  job  is
               used.   bg  jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started
               without job control.
        bind [-m keymap] [-lpsvPSV]
        bind [-m keymap] [-q  function ] [-u  function ] [-r keyseq]
        bind [-m keymap] -f filename

上面实际上不是cd的帮助,而是BASH的介绍。


也就是说,对于内置命令,寻求帮助的途径是:

help COMMAND


5.结论二:man COMMAND

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
LS(1)                            User Commands                           LS(1)
NAME
        ls  - list directory contents
SYNOPSIS
        ls  [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 octal escapes  for  nongraphic characters
        --block-size=SIZE
               use SIZE-byte blocks
        -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]

对于外部命令,应该使用man,或者长选项--help的方式获取帮助。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[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 .
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 octal escapes  for  nongraphic characters
       --block-size=SIZE      use SIZE-byte blocks
   -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]         control whether color is used to distinguish  file
                                types.  WHEN may be `never ', `always' , or `auto'
   -d, --directory            list directory entries instead of contents,
                                and  do  not dereference symbolic links
   -D, --dired                generate output designed  for  Emacs' dired mode
   -f                          do  not  sort enable  -aU, disable -lst


6.man NUMBER COMMAND

1
man is manual

就像我们买了一些家电设备一样,都会有一个使用手册,这些手册都有一个目录结构,这样会方便用户查找。其实man也是分章节的。

1
2
3
4
5
6
7
8
1:User Commands(用户命令,所有用户可以使用的命令 /bin /usr/bin /usr/local/bin)
2:System Call(系统调用)
3:Library Call(库调用)
4:特殊文件(block file , character file。设备文件)
5:文件格式(解释COMMAND对应配置文件的语法格式)
6:games,游戏
7:杂项
8:管理命令(通常是管理员才有权限使用的命令/sbin  /usr/sbin /usr/local/sbin)

查看具体的章节,直接man NUMBER COMMAND即可。


7.如何快速定位

通过前面的知识,我们知道,可以使用man来指定章节查看,可是如果内容过多,如何有效,快速定位到我们想要的内容呢?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
下一页:SPACE
下一行:ENTER
上一页:b(before)
上一行: k
查找:
/keyword
向下搜索
?keyword
向上搜索
(默认不区分大小写)
搜索后,可能有多个
对/keyword而言
n 表示下一个
N 表示前一个
?keyword恰好相反



8.关于info

info COMMAND

偏向命令的一些历史信息。如果可以man,就不用info了。


9.总结

学习完如何使用帮助后,然后独立解决了设置时间,感觉很好。

就算工作再怎么满,我也要挤出点时间学习,我相信我的LINUX水平会不断提高的~



本文转自zfz_linux_boy 51CTO博客,原文链接:http://blog.51cto.com/zhangfengzhe/1405530,如需转载请自行联系原作者




相关文章
|
Linux
Linux下安装中文输入法总结
Linux下安装中文输入法总结
4911 0
|
负载均衡 Linux 应用服务中间件
Linux下各种锁地理解和使用以及总结解决一下epoll惊群问题(面试常考)
Linux下各种锁地理解和使用以及总结解决一下epoll惊群问题(面试常考)
Linux下各种锁地理解和使用以及总结解决一下epoll惊群问题(面试常考)
|
网络协议 Linux 网络安全
Windows和Linux常用TCP端口探测工具总结
Windows和Linux常用TCP端口探测工具总结
852 0
Windows和Linux常用TCP端口探测工具总结
|
Linux C语言
Linux:文件目录类指令(内含:文件目录所有用法总结摘要+所有用法案例)
Linux:文件目录类指令(内含:文件目录所有用法总结摘要+所有用法案例)
296 0
Linux:文件目录类指令(内含:文件目录所有用法总结摘要+所有用法案例)
|
应用服务中间件 Linux nginx
Linux查看进程号总结
Linux查看进程号总结
500 0
Linux查看进程号总结
|
存储 域名解析 网络协议
Linux网络服务总结,复习看这个很方便(DHCP、FTP、SSH、DNS、NFS、PXE)
Linux网络服务总结,复习看这个很方便(DHCP、FTP、SSH、DNS、NFS、PXE)
522 0
Linux网络服务总结,复习看这个很方便(DHCP、FTP、SSH、DNS、NFS、PXE)
|
存储 监控 安全
Linux系统管理常用知识点总结(6-11章)(二)
Linux系统管理常用知识点总结(6-11章)(二)
192 0
Linux系统管理常用知识点总结(6-11章)(二)
|
存储 机器学习/深度学习 监控
Linux系统管理常用知识点总结(6-11章)(一)
Linux系统管理常用知识点总结(6-11章)(一)
336 0
Linux系统管理常用知识点总结(6-11章)(一)
|
Linux Shell Go
Linux系统管理常用知识点总结(1-6章)(二)
Linux系统管理常用知识点总结(1-6章)(二)
208 0
Linux系统管理常用知识点总结(1-6章)(二)
|
Linux 开发工具
Linux系统管理常用知识点总结(1-5章)(一)
Linux系统管理常用知识点总结(1-5章)(一)
297 0
Linux系统管理常用知识点总结(1-5章)(一)