2018/07/28-linux

which: show the full path of (shell) commands,it prints to stdout the full path of the executables,it does this by searching for an executable or script in the directories listed in the environment variable PATH。

查找命令的完整文件路径(查找可执行文件的完整文件路径,在变量PATH配置的目录中寻找)

-a(--all),print all matching executables in PATH,not just the first.

whereis:locate the binary,source,and manual page files for a command

-b:search only for binaries

-m:search only for manual sections 

-s:search only for sources 

-u:search for unusual entries. 不在b(binary),m(manual),s(source)下的特殊文件

locate

find:search for files in a directory hierarchy

root用户操作

which ifconfig

/sbin/ifconfig

su myuser

which ifconfig

which:no ifconfig in (/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin)

which touch  

/usr/bin/touch

which -a touch  

/usr/bin/touch

/bin/touch

/usr/bin/X11/touch

which touch/which -a touch:列出第一个/列出所有同名的

root用户操作

whereis ifconfig

ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

su myuser

whereis ifconfig

ifconfig:/sbin/ifconfig /usr/share/man/man8/ifocnfig.8.gz

which找不到的,whereis找到了
 

whereis passwd

passwd:/usr/bin/passwd /etc/passwd.old /etc/passwd /usr/bin/X11/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man1/passwd.lssl.gz /usr/share/man/man5/passwd.5.gz

whereis -m passwd

passwd:/usr/share/man/man1/passwd.1.gz /usr/share/man/man1/passwd.lssl.gz /usr/share/man/man5/passwd.5.gz

whereis -b passwd

passwd:/usr/bin/passwd /etc/passwd.old /etc/passwd /usr/bin/X11/passwd

which/whereis/locate 搜索数据库文件,find搜索硬盘,所以

which/whereis/locate 搜索速度块,find搜索速度慢。

猜你喜欢

转载自blog.csdn.net/qzw752890913/article/details/82115628
今日推荐