1.which
语法:
which [options]--------option为查找对象
描述:
在
环境变量PATH指定的目录下,查找指定参数的
可执行文件的位置,
必须是可执行文件
-
gwwu@hz-dev2.wgw.com:~/bin>ls -al
-
total 20
-
drwxrwxr-x 2 gwwu gwwu 4096 Feb 25 16:20 .
-
drwx------ 21 gwwu gwwu 4096 Feb 25 16:20 ..
-
-rwxrw-r-- 1 gwwu gwwu 7 Feb 25 16:20 wgw
-
-rw-rw-r-- 1 gwwu gwwu 3 Feb 25 16:20 wgw1
-
-rw-rw-r-- 1 gwwu gwwu 7 Feb 25 16:20 wgw.sh
-
gwwu@hz-dev2.wgw.com:~/bin>echo $PATH
-
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/sbin:/home/gwwu/bin
-
gwwu@hz-dev2.wgw.com:~/bin>which wgw
-
~/bin/wgw
-
gwwu@hz-dev2.wgw.com:~/bin>which wgw1
-
/usr/bin/which: no wgw1 in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/sbin:/home/gwwu/bin)
-
gwwu@hz-dev2.wgw.com:~/bin>which wgw.sh
-
/usr/bin/which: no wgw.sh in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/sbin:/home/gwwu/bin)
-
gwwu@hz-dev2.wgw.com:~/bin>
2.whereis
语法:whereis [-bmsu] [-BMS directory... -f] filename...
描述:
-b:只查找二进制文件
-m:只查找帮助文件manual路径下的文件
-s: 只查找source源文件
-u:查找没有说明文档的文件
-B:修改或限制whereis查找二进制文件的路径
-M:修改或限制whereis查找帮助部分的路径
-S:修改或限制shereis查找源文件的路径
-f: 在带有-B/-M/-S中的任何一个后必须使用-f
whereis查找的速度非常快,这是因为linux系统会将搜索系
统内的特定档案。-------具体是啥就不清楚了,哪位大侠知道的话回复一下
-
gwwu@hz-dev2.wgw.com:~/bin>whereis passwd
-
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
3.locate
从数据库查找数据
locate命令可以在搜寻数据库时快速找到档案,数据库由updatedb程序来更新,updatedb是由cron daemon周期性建立的,locate命令在搜寻数据库时比由整个由硬盘资料来搜寻资料来得快,但较差劲的是locate所找到的档案若是最近才建立或刚更名的,可能会找不到,在内定值中,updatedb每天会跑一次,可以由修改crontab来更新设定值。(etc/crontab).
4. find
从硬盘中查找文件和目录---------内容很多,单独在详细说明,这里只要关注它是从硬盘查找就可以了
5.type
用来区分某个命令到底是由shell自带的,还是由shell外部的独立二进制文件提供的。如果一个命令是外部命令,那么使用-p参数,会显示该命令的路径,相当于which命令。
-
gwwu@hz-dev2.aerohive.com:~/bin>type cp
-
cp is aliased to `cp -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type ls
-
ls is aliased to `ls --color=auto'
-
gwwu@hz-dev2.aerohive.com:~/bin>type mv
-
mv is aliased to `mv -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type cp
-
cp is aliased to `cp -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type dir
-
dir is /usr/bin/dir
-
gwwu@hz-dev2.aerohive.com:~/bin>type pwd
-
pwd is a shell builtin
-
gwwu@hz-dev2.aerohive.com:~/bin>type -p dir
-
/usr/bin/dir
-
gwwu@hz-dev2.aerohive.com:~/bin>which dir
-
/usr/bin/dir
-
gwwu@hz-dev2.aerohive.com:~/bin>type cp
-
cp is aliased to `cp -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type ls
-
ls is aliased to `ls --color=auto'
-
gwwu@hz-dev2.aerohive.com:~/bin>type mv
-
mv is aliased to `mv -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type cp
-
cp is aliased to `cp -i'
-
gwwu@hz-dev2.aerohive.com:~/bin>type dir
-
dir is /usr/bin/dir
-
gwwu@hz-dev2.aerohive.com:~/bin>type pwd
-
pwd is a shell builtin
-
gwwu@hz-dev2.aerohive.com:~/bin>type -p dir
-
/usr/bin/dir
-
gwwu@hz-dev2.aerohive.com:~/bin>which dir
-
/usr/bin/dir
阅读(562) | 评论(0) | 转发(0) |