科技常识:Linux命令搜索命令whereis与which的区别

2021-03-12 09:27:34
导读 今天小编跟大家讲解下有关Linux命令搜索命令whereis与which的区别 ,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关Linux命令

今天小编跟大家讲解下有关Linux命令搜索命令whereis与which的区别 ,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关Linux命令搜索命令whereis与which的区别 的相关资料,希望小伙伴会喜欢也能够帮助大家。

Linux命令搜索命令whereis与which的区别

一 whereis

1、语法

whereis 命令名

搜索命令所在的路径以及帮助文档所在的位置

选项:

-b:只查找可执行文件-m:只查找帮助文件

2、实战

[root@localhost ~]# whereis lsls:/usr/bin/ls /usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz[root@localhost ~]# whoamiroot[root@localhost ~]# whatiswhatis what?[root@localhost ~]# whatis lsls (1)- list directory contentsls (1p)- list directory contents[root@localhost ~]# whereis -b lsls:/usr/bin/ls[root@localhost ~]# whereis -m lsls:/usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz

二 which

1、语法

which 命令名

搜索命令所在路径及别名

2、实战

[root@localhost ~]# which lsalias ls='ls --color=auto'/usr/bin/ls[root@localhost ~]# which pwd/usr/bin/pwd[root@localhost ~]# whereis cdcd:/usr/bin/cd /usr/share/man/man1/cd.1.gz/usr/share/man/man1p/cd.1p.gz[root@localhost ~]# which cd/usr/bin/cd

三 PATH环境变量

定义的是系统搜索命令的路径

[root@localhost ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

以上就是Linux命令搜索命令whereis与which的区别的讲解,如有疑问请留言或者到本站社区交流讨论,大家共同进步,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

来源:爱蒂网

免责声明:本文由用户上传,如有侵权请联系删除!

猜你喜欢

最新文章