當前位置:聚美館>智慧生活>心理>

linux下whereis和which區別

心理 閲讀(5.27K)
linux下whereis和which區別

Linux命令搜索命令whereis與which的區別

一 whereis

1、語法

whereis 命令名

搜索命令所在的路徑以及幫助文檔所在的位置

選項:

-b:只查找可執行文件

-m:只查找幫助文件

2、實戰

[root@localhost ~]# whereis ls

ls:/usr/bin/ls /usr/share/man/man1/

[root@localhost ~]# whoami

root

[root@localhost ~]# whatis

whatis what?

[root@localhost ~]# whatis ls

ls (1)- list directory contents

ls (1p)- list directory contents

[root@localhost ~]# whereis -b ls

ls:/usr/bin/ls

[root@localhost ~]# whereis -m ls

ls:/usr/share/man/man1/

二 which

1、語法

which 命令名

搜索命令所在路徑及別名

2、實戰

[root@localhost ~]# which ls

alias ls='ls --color=auto'

/usr/bin/ls

[root@localhost ~]# which pwd

/usr/bin/pwd

[root@localhost ~]# whereis cd

cd:/usr/bin/cd /usr/share/man/man1/

[root@localhost ~]# which cd

/usr/bin/cd