Home  >  Article  >  Operation and Maintenance  >  Linux command tutorial: Comparative search command whereis and which difference

Linux command tutorial: Comparative search command whereis and which difference

巴扎黑
巴扎黑Original
2017-09-08 10:46:302011browse

This article mainly introduces relevant information about the difference between Linux command search commands whereis and which. Here are examples of how to distinguish their usage. Friends in need can refer to

Linux The difference between command search command whereis and which

一whereis

1. Syntax

##whereis Command name

Search the path where the command is located and the location of the help document


Options:


-b: Search only Executable file

-m: Only search for help files

2, actual combat

##

[root@localhost ~]# whereis ls
ls:/usr/bin/ls /usr/share/man/man1/ls.1.gz/usr/share/man/man1p/ls.1p.gz
[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/ls.1.gz/usr/share/man/man1p/ls.1p.gz

二which


1. Syntax


which command name


Search command path and alias


2. Actual combat


##
[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/cd.1.gz/usr/share/man/man1p/cd.1p.gz
[root@localhost ~]# which cd
/usr/bin/cd


Three PATH environment variables

are defined System search command path


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

The above is the detailed content of Linux command tutorial: Comparative search command whereis and which difference. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn