- 本章节将要讲解的命令
-
命令
命令 |
用途 |
type |
显示命令类型 |
which |
显示可执行文件的位置 |
help |
获取Shell内建命令的帮助信息 |
man |
显示命令的手册页 |
info |
显示命令的info条目 |
alias |
创建自己的命令 |
-
什么是命令
符合下列4种情况之一的,都可以称为命令。
- 可执行程序,就像我们在/usr/bin中见到的那些文件一样。在这一分类中,程序可以是编译生成的而进制文件,也可以是由Shell、Perl、Python、Ruby等脚本语言编写的脚本。
- Shell中内建命令,通过type命令可查询,cd命令就是其中之一
- Shell函数,Shell函数是一种微型的Shell脚本。
- 别名,别名是我们在其他命令的基础上自己定义的命令
-
type-----显示命令类型
type命令属于Shell内建命令,能够显示指定的命令属于哪种类型,用法如下
type command
[sysadmin@ansible ~]$ type cd
cd is a shell builtin
[sysadmin@ansible ~]$ type ls
ls is aliased to `ls --color=auto'
[sysadmin@ansible ~]$ type cp
cp is /usr/bin/cp
[sysadmin@ansible ~]$
从输出结果看,有3种不同的命令。cd是shell内建命令,ls是别名,cp是可执行程序。
-
which—显示可执行文件的位置
为了确定某个程序的确切位置,可以使用which命令:
[sysadmin@ansible ~]$ which ls
alias ls=‘ls --color=auto’
/usr/bin/ls
-
help----获取shell内建命令的帮助信息
Bash自带的帮助功能可用于所有Shell内建命令,只需要输入help,然后加上命令名称即可,如下示例:
[sysadmin@ansible ~]$ help cd
cd: cd [-L|[-P [-e]]] [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 (
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)