Linux command search commands whereis and which

a whereis

1. Grammar
whereis command name
The path where the search command is located and where the help documentation is located
Options:
-b: look for executable files only
-m: find only help files
2. Actual combat
  1. [root@localhost ~]# whereis ls
  2. ls:/usr/bin/ls /usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
  3. [root@localhost ~]# whoami
  4. root
  5. [root@localhost ~]# whatis
  6. whatis what?
  7. [root@localhost ~]# whatis ls
  8. ls (1)- list directory contents
  9. ls (1p)- list directory contents
  10. [root@localhost ~]# whereis -b ls
  11. ls:/usr/bin/ls
  12. [root@localhost ~]# whereis -m ls
  13. ls:/usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
二 which
1. Grammar
which command name
Search command path and alias
2. Actual combat
  1. [root@localhost ~]# which ls
  2. alias ls='ls --color=auto'
  3. /usr/bin/ls
  4. [root@localhost ~]# which pwd
  5. /usr/bin/pwd
  6. [root@localhost ~]# whereis cd
  7. cd:/usr/bin/cd /usr/share/man/man1/cd.1.gz/usr/share/man/man1p/cd.1p.gz
  8. [root@localhost ~]# which cd
  9. /usr/bin/cd
Three PATH environment variables
Defines the path of the system search command
  1. [root@localhost ~]# echo $PATH
  2. /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326145498&siteId=291194637