一天一命令-命令帮助

一天一命令-命令帮助

如何系统的学习一个bash命令:

需求,了解命令的格式,选项,帮助手册,案例,练习,拓展。

想要达到什么效果,有没有这样的命令,命令的格式和使用方法,有什么其他的选项,系统中的完整的帮助手册,常用的选项和案例有哪些,拓展的命令使用方法。

5w1h方法:what,why,when,where,who,how

1.程序自身的帮助文档:/usr/share/doc/cmd-version

2.发行版官方文档:http://www.redhat.com/docs

3.Google Hack搜索

4.slideshare幻灯片:http://www.slideshare.net/

type cmd  //查看命令类型,是属于bash内部命令还是外部命令,并显示路径

cmd --version  或者cmd -V  //查看命令工具的版本

whatis  //显示man帮助页面和简单描述

which  //显示文件路径

whereis  //查找文件的二进制,源码,man帮助文件路径

hash  //外部命令缓存

help cmd 或者cmd --help  //内部命令帮助查询

info  //多页面显示命令帮助

man  //主要的命令帮助手册,推荐使用

type

显示命令的类型是内部还是外部命令

Usage: type [-afptP] name [name ...]
-a 显示所有属性,包括alias别名,是内部命令builtin还是外部命令并列出绝对路径
-f 显示文件类型是内部还是外部,并显示路径
-P 大写P,显示命令的绝对路径
-t 显示命令的类型,内部builtin,别名alias,外部file,保留关键字keyword
[执行命令]#type -a ls
ls is aliased to `ls -p --color=auto‘
ls is /usr/bin/ls
[执行命令]#type ll
ll is aliased to `ls -al --color=auto‘
[执行命令]#type -a cd
cd is a shell builtin
cd is /usr/bin/cd
[执行命令]#type -a python
python is /usr/bin/python
[执行命令]#type -a cd ls pwd
cd is a shell builtin
cd is /usr/bin/cd
ls is aliased to `ls -p --color=auto‘
ls is /usr/bin/ls
pwd is a shell builtin
pwd is /usr/bin/pwd
[执行命令]#type whatis
whatis is hashed (/usr/bin/whatis)
[执行命令]#type {
{ is a shell keyword
[执行命令]#type [
[ is a shell builtin
[执行命令]#type apachectl
apachectl is /app/apache25/bin/apachectl

查看命令或软件的版本

[执行命令]#ls --version
ls (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Richard M. Stallman and David MacKenzie.
[执行命令]#python -V
Python 2.7.5

whatis

显示命令的man帮助页面和功能描述

Usage: whatis [OPTION...] KEYWORD...
-r 支持正则表达式regex
[执行命令]#whatis ls
ls (1)               - list directory contents
ls (1p)              - list directory contents
[执行命令]#whatis ll
ll: nothing appropriate.
[执行命令]#whatis cd
cd (1)               - bash built-in commands, see bash(1)
cd (1p)              - change the working directory
[执行命令]#whatis python
python (1)           - an interpreted, interactive, object-oriented programming language
[执行命令]#whatis -r pwd
lckpwdf (3)          - get shadow password file entry
pwd (1)              - print name of current/working directory
pwd (1p)             - return working directory name
pwd.h (0p)           - password structure
pwdx (1)             - report current working directory of a process
ulckpwdf (3)         - get shadow password file entry
unix_chkpwd (8)      - Helper binary that verifies the password of the current user

which

显示命令的绝对路径,是根据PATH设置的目录进行查找的,不同用户的PATH不同,搜索到的文件内容也不相同

Usage: /usr/bin/which [options] [--] COMMAND [...]
[执行命令]#which -a ls
alias ls=‘ls -p --color=auto‘
        /usr/bin/ls
[执行命令]#which -a ll
alias ll=‘ls -al --color=auto‘
        /usr/bin/ls
[执行命令]#which -a cd
/usr/bin/cd
[执行命令]#which -a python
/usr/bin/python
[执行命令]#which apachectl
/app/apache25/bin/apachectl

whereis

查找指定命令的二进制程序,源代码和man手册等相关文件路径

Usage: whereis [options] file
-b 只搜索二进制文件
-m 只搜索man手册
-s 搜索源代码
[执行命令]#whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[执行命令]#whereis ll
ll:
[执行命令]#whereis cd
cd: /usr/bin/cd /usr/share/man/man1/cd.1.gz /usr/share/man/man1p/cd.1p.gz
[执行命令]#whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.1.gz
[执行命令]#whereis kernel
kernel: /usr/lib/kernel /etc/kernel
[执行命令]#whereis apachectl
apachectl: /app/apache25/bin/apachectl
内部命令帮助
[执行命令]#help pwd
pwd: pwd [-LP]
    Print the name of the current working directory.
    Options:
      -L        print the value of $PWD if it names the current working
        directory
      -P        print the physical directory, without any symbolic links
 
    By default, `pwd‘ behaves as if `-L‘ were specified.   
    Exit Status:
    Returns 0 unless an invalid option is given or the current directory
    cannot be read.

外部命令帮助
[执行命令]#whatis --help
Usage: whatis [OPTION...] KEYWORD...
  -d, --debug                emit debugging messages
  -v, --verbose              print verbose warning messages
  -r, --regex                interpret each keyword as a regex
  -w, --wildcard             the keyword(s) contain wildcards
  -l, --long                 do not trim output to terminal width
  -C, --config-file=FILE     use this user configuration file
  -L, --locale=LOCALE        define the locale for this search
  -m, --systems=SYSTEM       use manual pages from other systems
  -M, --manpath=PATH         set search path for manual pages to PATH
  -s, --sections=LIST, --section=LIST
                             search only these sections (colon-separated)
  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Report bugs to [email protected]

man帮助文档

man存放地址:/usr/share/man

man命令的配置文件:c68: /etc/man.conf | c73: /etc/man_db.conf

man章节分类:1.用户命令 2.系统调用 3.C库调用 4.设备文件及特殊文件 5.配置文件格式 6.游戏 7.杂项 8.管理类命令 9.Linux内核API

whatis passwd

man 1 passwd

man 5 passwd

man的显示是使用less命令来实现,操作也一样

向下翻屏:空格,^V,^f,^F

向上翻屏:b,^B

向下翻半屏:d,^D

向上翻半屏:u,^U

向上翻一行:回车,^N,e,^E,j,^J

向下翻一行:y,^Y,^P,k,^K

退出:q

跳转到第n行:n

回到文首:1G

回到文尾:G

向下搜索,不区分字符大小写:/keyword  下一个n;上一个N

向上搜索,不区分大小写:?keyword  下一个n;上一个N

man cmd命令帮助导出到文件且保留原格式

man ls | col -b > ls.txt

到指定位置搜索命令的手册页面并显示:man -M /PATH cmd

#man -aw -M /usr/share/man/ passwd
/usr/share/man/man1/passwd.1.gz
/usr/share/man/man1/sslpasswd.1ssl.gz
/usr/share/man/man5/passwd.5.gz
#man -aw -M /usr/local/share/man/ passwd
没有 passwd 的手册页条目  //默认只会搜索匹配一层目录,不会递归目录查询
#man -aw -M /usr/local/share/man/zh_CN/ passwd
/usr/local/share/man/zh_CN/man5/passwd.5
 
man -k password  //列出所有匹配关键字的man页面列表,使用whatis数据库
man -f passwd  //相当于whatis
man -w [章节]keyword  //打印man帮助文件路径
man -w 5 passwd

其他帮助文档:/usr/share/doc

符号说明:[]:可选内容  <>:必选内容  a|b:二选一  ...:同一内容可出现多次

时间: 2024-08-05 12:09:03

一天一命令-命令帮助的相关文章

iftop命令命令详解

iftop命令命令详解 作者:尹正杰 在Linux命令中有很多内置命令,和外置命令,但是内部命令的功能毕竟是有限的,比如ifconfig,它就不能看到网卡流量的 实时发送情况,尽管咱们知道可以用watch命令去查看网卡的发送接收流量的情况,但是还是不够细致,因为它仅仅能看到我们的 接受和发送的总流量,因此,我们今天来介绍一个比较好使的实施查看网络流量信息的软件---iftop,其实他的工作模式和top很像. 废话不多说~让我们直接进入正题吧: 1.想必大家都会在linux命令行上敲击ifconf

Hart 常用命令 命令格式+命令含义 &lt;中文翻译&gt;

HART通用命令一览 通用命令(0-32)在Spec127中 普通命令(33-114)在 Spec151 中 HART命令0:读标识码返回扩展的设备类型代码,版本和设备标识码.请求:无响应:    字节0:        254     字节1:        制造商ID(Enum)    字节2:        设备类型(Enum)    字节3:        请求的最小前导符数(主->从)    字节4:        通用命令文档版本号    字节5:        设备规范版本号   

linux学习一天一个命令(22)[which命令]

which  查看可执行文件的位置,常用于查看命令的目录

linux学习一天一个命令(15)[vim命令]

vim x:删除光标所在字符(和Delete相同) de:从光标所在位置删除直到单词的词尾 dw:从光标所在位置删除直到下一个单词的词首 db:删除光标之前的这个单词的内容 dG:删除光标所在行到行尾的内容 G:光标跳转到指定位置,在输入G之前输入位置 GG:行尾 gg:行首 Ctrl+g:查看光标所在位置,并且显示文件有多少行(显示位置为百分比显示) :s/old/new/g:将光标所在行的old替换为new :%s/old/new/g:将文件内所有old替换为new :%s/old/new/

linux学习一天一个命令(4)[mkdir命令]

linux mkdir 命令用来创建指定的名称的目录,要求创建目录的用户在当前目录中具有写权限,并且指定的目录名不能是当前目录中已有的目录. 1.命令格式: mkdir [选项] 目录... 2.命令功能: 通过 mkdir 命令可以实现在指定位置创建以 DirName(指定的文件名)命名的文件夹或目录.要创建文件夹或目录的用户必须对所创建的文件夹的父文件夹具有写权限.并且,所创建的文件夹(目录)不能与其父目录(即父文件夹)中的文件名重名,即同一个目录下不能有同名的(区分大小写). 3.命令参数

getconf命令【一天一个命令】

我们时常需要查询系统相关的信息,比如页面大小,整数大小之类,如果编写程序去计算会比较繁琐,这里有一个很有用的命令,可以用来获取系统相关信息.它就是getconf. $ getconf PAGE_SIZE 4096 $ getconf INT_MAX 2147483647 查看Ubuntu操作系统位数 From http://wiki.ubuntu.org.cn/UbuntuSkills#.E6.9F.A5.E7.9C.8B.E7.B3.BB.E7.BB.9F.E6.98.AF32.E4.BD.8

一天一个命令--ifconfig

格式:ifconfig 显示当前激活的网络接口信息. 格式:ifconfig -a 显示所有网络接口的信息,无论是否激活. ifconfig eth1 ifconfig命令跟上指定网络接口名称,就可以查看具体的网卡信息了. ifconfig eth0 up   开启接口 ifconfig eth0 down   关闭接口 系统中网络接口配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 service network restart

linux学习一天一个命令(19)[df命令]

df:查看磁盘(默认是KB) -h:加上单位 -i:查看磁盘inode号 -T:文件系统类型

linux学习一天一个命令(20)[w命令]

w:查看系统负载,有多少人在登录