Linux命令简介及帮助解密
       命令,对linux来说就是他的灵魂,没有命令linux就失去了活力。而这些命令令愿意去琢磨linux的人如痴如醉,相反令linux新手和浅尝辄止的人寸步难行、痛苦不堪。在linux中你必须得承认,命令行是最难的也是最迷人的。简单的说学习linux命令行,就像走路:难走的都是上坡路,容易的多是下破路。
      这时命令的帮助就变得很有必要,linux下有着强大的帮助体系。接下来的内容里面,将细说linux命令的格式及帮助形式。
1.   Linux命令的格式:
命令关键字  [选项]        [参数]
选项的含义是如何执行命令,参数一般是命令执行的对象。命令关键字就相当于让人干一件事,选项指明怎么做,参数就是对谁做。
注意事项:格式中用空格隔开,[]表示可有可无;选项有长格式和短格式之分,长格式用在脚本中,短格式用在命令行;多个命令可以用“;”隔开表示顺序执行。
[root@localhost ~]# ls     ---------->>显示当前目录下的文件和目录但是不包括以点开始的隐藏文件
anaconda-ks.cfg  Desktop  install.log  install.log.syslog  stlong
[root@localhost ~]# ls -a ——————>>显示当前目录下的所有文件,包括隐藏文件
.                .bashrc   .eggcups  .gnome2_private    install.log.syslog  stlong
..               .chewing  .gconf    .gstreamer-0.10    .metacity           .tcshrc
anaconda-ks.cfg  .cshrc    .gconfd   .gtkrc-1.2-gnome2  .nautilus           .Trash
.bash_logout     Desktop   .gnome    .ICEauthority      .redhat             .xsession-errors
.bash_profile    .dmrc     .gnome2   install.log        .scim
[root@localhost ~]# ls --all——————>>ls –a的长格式一样的效果,在脚步里利于预读
.                .bashrc   .eggcups  .gnome2_private    install.log.syslog  stlong
..               .chewing  .gconf    .gstreamer-0.10    .metacity           .tcshrc
anaconda-ks.cfg  .cshrc    .gconfd   .gtkrc-1.2-gnome2  .nautilus           .Trash
.bash_logout     Desktop   .gnome    .ICEauthority      .redhat             .xsession-errors
.bash_profile    .dmrc     .gnome2   install.log        .scim
[root@localhost ~]# rm -rf   stlong  ;ls –a————>>删除stlong这个目录,分号隔开顺序执行。
.                .bashrc   .eggcups  .gnome2_private    install.log.syslog  .tcshrc
..               .chewing  .gconf    .gstreamer-0.10    .metacity           .Trash
anaconda-ks.cfg  .cshrc    .gconfd   .gtkrc-1.2-gnome2  .nautilus           .xsession-errors
.bash_logout     Desktop   .gnome    .ICEauthority      .redhat
.bash_profile    .dmrc     .gnome2   install.log        .scim
[root@localhost ~]#
2.   Linux命令的帮助体系:
Linux命令的帮助体系成员:
1Whatis————显示命令的简短描述,使用定时更新的数据库,刚更新的命令找不到。
例:
[root@localhost ~]# whatis date
date                 (1)  - print or set the system date and time
date                 (1p)  - write the date and time
2command  --help————显示简短描述及选项列表,不是所有的命令都支持。
例:
[root@localhost ~]# ls --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort.
 
长选项必须用的参数在使用短选项时也是必须的。
  -a, --all                  不隐藏任何以 . 字符开始的项目
  -A, --almost-all           列出除了 . .. 以外的任何项目
      --author               -l 同时使用时列出每个文件的作者
[root@localhost ~]# date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
[root@localhost ~]# ip --help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] [-batch filename
where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable | tunnel |
                   maddr | mroute | monitor | xfrm }
       OPTIONS := { -V[ersion] | -s[tatistics] | -r[esolve] |
                    -f[amily] { inet | inet6 | ipx | dnet | link } |
                    -o[neline] | -t[imestamp] }
看懂帮助格式:”[]” 表示该部分可选    “… “表示 前一部分可以重复多次    “x|y|z”  表示xyz任选其一   “-abc=-a –b –c”  <>”表示该部分是一个变量。
Man————>>linux命令的手册、几乎所有的命令都有man帮助文档
3Man的使用技巧:(1)上下翻页CTRL+B/F,(2)按下/输入想要查找的东西N往上一个n下一个,(3q推出,(4)“man – k  关键字“ whatis数据库中查找包含关键字帮助文档,(5man 1 表示查看命令的帮助文档,man 5表示查看命令的配置文档。
例:
[root@localhost ~]# man man
man(1)                                                                  man(1)
 
NAME
       man - format and display the on-line manual pages
 
SYNOPSIS
       man  [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist]
       [-P pager] [-B browser] [-H htmlpager] [-S section_list] [section] name ...
[root@localhost ~]# man -k pass
4Info————>>它是一个GNU倡导的帮助,不是所有命令都支持,比man帮助更详细。格式类似网页,以“*“开始的表示为连接。
使用方法:(1PageUp/PageDown浏览info帮助页,(2Tab键跳到下一个连接,(3Enter键进入选择的连接,(4n下一个连接,p上一个连接,u上一级,(5)“s  关键字“ 表示搜索关键字q退出。
5/usr/share/doc/————>>多数软件安装后都会有帮助文档,一般是配置实例,单个文件存储。
例:
[root@localhost ~]# ls /usr/share/doc/mysql-server-5.0.77/
my-huge.cnf  my-innodb-heavy-4G.cnf  my-large.cnf  my-medium.cnf  my-small.cnf
6)系统官方网站上的document文档————>>系统的官方网站会有大量的帮助文档,例如docs.redhat.com
下面是个人认为比较好的文档:集群、NFSSelinux、虚拟化等的帮助。Linux命令简介及帮助解密_解密
7)浏览器中输入HOWTO————这种方式能解决70%以上的技术问题。Linux命令简介及帮助解密_用好linux命令_02
总结:linux的帮助众多,应该善用。让技术和生活走上坡路。