Linux指令搜尋指令whereis與which的差別
一 whereis
1、文法
whereis 指令名
搜尋指令所在的路徑以及幫助文檔所在的位置
選項:
-b:隻查找可執行檔案
-m:隻查找幫助檔案
2、實戰
[[email protected] ~]# whereis ls
ls:/usr/bin/ls /usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
[[email protected] ~]# whoami
root
[[email protected] ~]# whatis
whatis what?
[[email protected] ~]# whatis ls
ls (1)- list directory contents
ls (1p)- list directory contents
[[email protected] ~]# whereis -b ls
ls:/usr/bin/ls
[[email protected] ~]# whereis -m ls
ls:/usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
二 which
1、文法
which 指令名
搜尋指令所在路徑及别名
2、實戰
[[email protected] ~]# which ls
alias ls="ls --color=auto"
/usr/bin/ls
[[email protected] ~]# which pwd
/usr/bin/pwd
[[email protected] ~]# whereis cd
cd:/usr/bin/cd /usr/share/man/man1/cd.1.gz/usr/share/man/man1p/cd.1p.gz
[[email protected] ~]# which cd
/usr/bin/cd
三 PATH環境變量
定義的是系統搜尋指令的路徑
[[email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
以上就是Linux指令搜尋指令whereis與which的差別的講解,如有疑問請留言或者到本站社群交流讨論,大家共同進步,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支援!