linux常用命令-帮助命令-授之以渔

原创Blog,转载请注明出处

http://blog.csdn.net/hello_hwc

我的虚拟机系统是CentOS,版本较老,谅解

一、为什么要学习帮助命令?

授人以鱼不如授人以渔,学会了怎么看帮助文档,是寻找到一个解决一类问题,而不是一个问题的方法。

二、常用的几个命名

1、man

-w 打印相关帮助文档的位置

-k 在man页中查找指定字符串和apropos命令相同

-f 和whatis相同

然后我们通过man ls命令来详细分析下man page中的内容

[[email protected] ~]# man ls
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
       Written by Richard Stallman and David MacKenzie.

REPORTING BUGS
       Report bugs to <[email protected]>.

COPYRIGHT
       Copyright © 2006 Free Software Foundation, Inc.
       This is free software.  You may  redistribute  copies  of  it
       under   the   terms   of   the  GNU  General  Public  License
       <http://www.gnu.org/licenses/gpl.html>.   There  is  NO  WAR-
       RANTY, to the extent permitted by law.

SEE ALSO
       The full documentation for ls is maintained as a Texinfo man-
       ual.  If the info and ls programs are properly  installed  at
       your site, the command

              info ls

       should give you access to the complete manual.

ls 5.97                          February 2010                           LS(1)

这里可以看到,info ls可以给出详细描述

首先会看到NAME,COPYRIGHT等每一部分的title,具体代表含义参照以下

NAME		名字,简单的命令是用来做什么的
SYNOPSIS	简短的指令使用语法
DESCRIPTION	详细的描述命令的使用方法
OPTIONS		针对SYNOPSIS,进行详细的阐述
COMMANDS	执行的时候可下达的命令
FILES		指令相关的文件
SEE ALSO	和这个指令相关的命令
EXAMPLE		范例
BUGS		尚存在的漏洞
COPYRIGHT	版权信息
REPORTING BUGS	发现Bug可以上传的邮箱
AUTHOR		作者

然后,又会看到LS(1)后面跟了一个1,这个数字也是有特定含义的

1	指令或者可执行文档
2	内核可调用的函数
3	常用函数库
4	档案说明
5	档案格式
6	游戏
7	linux系统的说明性内容
8	root可用的管理命名
9	和内核相关的文件

在man页中如何翻页,查找

箭头上下 上下行切换

Home/End 到第一页、最后一页

/String 查找一个字符串,n下一个查找到的结果,N上一个

q 结束这次

何时用man命令

我的心得是:这个命令基本不熟悉,需要详细的去看看自己想要的功能如何使用的时候,一般顺序是NAME-SYNOPSIS-DESCRIPTION-EXAMPLE

2、--help

列出常用命名的常用选项

使用场合:知道这个命令的使用领域,和简单使用方法,只是不熟悉某些选项

[[email protected] ~]# file --help
Usage: file [OPTION]... [FILE]...
Determine file type of FILEs.

  -m, --magic-file LIST      use LIST as a colon-separated list of magic
                               number files
  -z, --uncompress           try to look inside compressed files
  -b, --brief                do not prepend filenames to output lines
  -c, --checking-printout    print the parsed form of the magic file, use in
                               conjunction with -m to debug a new magic file
                               before installing it
  -f, --files-from FILE      read the filenames to be examined from FILE
  -F, --separator string     use string as separator instead of `:'
  -i, --mime                 output mime type strings
  -k, --keep-going           don't stop at the first match
  -L, --dereference          causes symlinks to be followed
  -n, --no-buffer            do not buffer output
  -N, --no-pad               do not pad output
  -p, --preserve-date        preserve access times on files
  -r, --raw                  don't translate unprintable chars to \ooo
  -s, --special-files        treat special (block/char devices) files as
                             ordinary ones
      --help                 display this help and exit
      --version              output version information and exit

3、whatis

查找whatis的数据库,寻找关键字的描述信息。在我们学会了man之后,可以直接man whatis来看信息

使用场合:我们想知道这个命令使用来干嘛的,或者我们想知道这个命令的种类

[[email protected] ~]# whatis ls
ls                   (1)  - list directory contents
ls                   (1p)  - list directory contents
[[email protected] ~]# whatis CD
cd                   (1p)  - change the working directory
cd [builtins]        (1)  - bash built-in commands, see bash(1)

4、help

查看shell内建指令的帮助信息,例如我们cd就是一个bash内建指令

[[email protected] ~]# cd --help
bash: cd: --: invalid option
cd: usage: cd [-L|-P] [dir]
[[email protected] ~]# 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.

其他的内建指令

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, sus-
       pend, test, times, trap, type, typeset,  ulimit,  umask,  una-
       lias, unset, wait
 
时间: 2025-01-10 23:55:30

linux常用命令-帮助命令-授之以渔的相关文章

第十三天(linux常用的基础命令 )

按照下面的要求创建一个新的逻辑卷:    *) 逻辑卷命名为database, 属于 datastore 卷组.    *) 在 datastore卷组中的逻辑卷,500M.    *)使用{ext3|ext4|xfs}文件系统对新的逻辑卷进行格式化    *)逻辑卷应该在系统启动的时候自动挂载在/mnt/database 目录下.    *)lvm扩大至1G, 并且保留其原有资料的完整性; 新增加一个 SWAP 分区    *) 大小为512MB,    *) 使该 SWAP 能够每次开机生效

Linux常用系统性能监控命令

-->Linux常用系统性能监控命令 Linux常用系统性能监控命令 2016-01-19 Linux爱好者 Linux爱好者 Linux爱好者 微信号 LinuxHub 功能介绍 伯乐在线旗下账号,「Linux爱好者」专注分享 Linux/Unix 相关内容,包括:工具资源.使用技巧.课程书籍等.   来源:工学1号馆 链接:http://wuyudong.com/archives/56 监控CPU使用率 使用下面的命令: [[email protected] ~]# gnome-system

Linux 常用 性能 检测 命令 解释

1.uptime [[email protected] ~]# uptime 15:08:15 up 98 days,  4:19,  2 users,  load average: 0.07, 0.29, 0.14 当前时间   系统运行至今的时间   多少用户登录当前系统   分别是1分钟,5分钟,15分钟前至今的负载情况 load average是队列平均长度,在队列中等待执行的进程数量 该值越低,说明进程更有可能立即被CPU处理,相反越高,说明进程更有可能阻塞 该命令可以检查服务器负载是

Linux 常用的压缩命令有 gzip 和 zip

Linux 常用的压缩命令有 gzip 和 zip,两种压缩包的结尾不同:zip 压缩的后文件是 *.zip ,而 gzip 压缩后的文件 *.gz 相应的解压缩命令则是 gunzip 和 unzip gzip 命令: # gzip test.txt 它会将文件压缩为文件 test.txt.gz,原来的文件则没有了,解压缩也一样 # gunzip test.txt.gz 它会将文件解压缩为文件 test.txt,原来的文件则没有了,为了保留原有的文件,我们可以加上 -c 选项并利用 linux

Linux常用的shell命令汇总

今天我们一起来看看Linux系统下常用的系统级命令,包括软硬件查看.修改命令,有CPU.内存.硬盘.网络.系统管理等命令. 说明:所有命令是在Centos 6.4 64位的虚拟机系统进行测试的.这些命令是需要大家深深的记在脑海里的哦 硬件篇 CPU相关 lscpu #查看的是cpu的统计信息. cat /proc/cpuinfo   #查看CPU信息详细信息,如每个CPU的型号,主频等 内存相关 free -m #概要查看内存情况  这里的单位是MB cat /proc/meminfo #查看内

linux 常用查看文件命令

linux常用命令有很多,今天来给大家介绍下几个简单的查看命令: 首先是ls命令,他只是查看目录没有查看文件的能力,相反的cat命令可以完整的显示出: 如图9-1所示 当我们查看文件时,又想看文件的大小那怎么办呢?别担心linux有一个命令可以那就是查看命令选项-lh, 如图9-2所示: 想要查看文件的原状态信息用stat命令就可以实现: 如图9-3所示: 如果要查看文件的类型,我们用file命令就可以完成: 如图9-4所示: 当你在查阅文档时,要在当前路径和上一路径来回切换时,请用#cd –,

linux常用的网络管理命令

网络配置 rhel/Centos中常用的网络管理命令: 设置ip基本信息相关配置文件 5,6版本:system-config-network(setup) 配置文件位置:/etc/sysconfig/network-scripts/ifcfg-eth[0-n] 7版本:nmcil nmtui(图形界面) 配置文件位置:/etc/sysconfig/network-scripts/ifcfg-en***** ifcfg-eth0,ifcfg-en******网络配置文件信息 TYPE=Ethern

Linux常用的基础命令

(一)回顾 Linux文件系统法则 文件名命名严格区分大小写 文件名可以使用除了/以外的任意字符,但是不建议使用特殊字符,包括空格,可以使用下划线连接多个单词 文件名长度不能超过255个字符 以.开头的文件为隐藏文件 工作目录:working directory 家目录:home (二)Linux常用命令 pwd:printing working directory/打印工作目录 cd:change directory/切换目录. 使用方法:cd [path], 如果不加任何path表示回到用户

LINUX常用配置及命令

一.   Fedora系统配置 1.      [设置网卡IP] 步骤如下: 1)     用root用户登陆,打开/etc/sysconfig/network-scripts/ifcfg-eth0文件 注意:打开的文件要根据网卡来设置,如:网卡eth1的配置文件就是ifcfg-eth1. 2)     设置以下内容: DEVICE=eth0 BOOTPROTO=static IPADDR=10.128.32.36 NETMASK=255.0.0.0 ONBOOT=yes GATEWAY=10.

linux常用文字处理命令总结

linux grep命令 作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权限是所有用户. 主要参数 -n:显示匹配行及 行号. -v:显示不包含匹配文本的所有行. -I:不区分大 小写(只适用于单字符). -l:查询多文件时只输出包含匹配字符的文件名. -e:使用扩展的正则表达式 -w: 只匹配整个单词,而不是字符串的一部