In Linux, we often need to find some files, as well as the directory where the files are located. Then we need to use some basic files to find the Class command.
There are several main file lookup commands:
which to view the full path of a command or executable file
whereis Display binary file path, user manual file path, source file path
Locate to view file paths with a database
Find search hard disk for specific files
which
The role of the which command, in the specified path path, searches for the location of a system command and returns the first search result. You can see if a system command exists and the location of the source file where the command resides.
• Command format:
which [options] [--] programname [...]
• Option Parameters:
-A: Lists all the commands that can be found in the path directory, not just the first found command name
--skip-alias: Ignore aliases
Example 1: Search the full path of the Useradd command with root and normal user respectively
650) this.width=650; "Src=" http://s5.51cto.com/wyfs02/M00/86/DD/wKioL1fNeYOyc5m0AAAxJaF5skI894.jpg " Title= "Which-1.jpg" alt= "Wkiol1fneyoyc5m0aaaxjaf5ski894.jpg"/>
Root user can find the full path of ifconfig
650) this.width=650; "Src=" http://s2.51cto.com/wyfs02/M01/86/DD/wKioL1fNeZSBssbtAACJmgVVnwU782.jpg " Title= "Which-2.jpg" alt= "Wkiol1fnezsbssbtaacjmgvvnwu782.jpg"/>
We found that the Useradd command was missing from the normal user tip.
Because the which command searches for a command based on the directory within the path variable set by the user.
Therefore, different path settings find the command of course not the same!
Example 2: what happens to find which itself with Which?
650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/86/DD/wKioL1fNewHxEiraAABdBagBANs076.jpg " Title= "Which-3.jpg" alt= "Wkiol1fnewhxeiraaabdbagbans076.jpg"/>
There are two which, one of which alias which is the command alias, which equals the following string of commands + parameters
We can omit the alias by appending the option--skip-alias, as shown in
650) this.width=650; "Src=" http://s5.51cto.com/wyfs02/M01/86/DE/wKiom1fNe-jA97YqAAA4MzPpI50804.jpg " Title= "Which-4.jpg" alt= "Wkiom1fne-ja97yqaaa4mzppi50804.jpg"/>
Example 3: find the full path to the CD command
650) this.width=650; "Src=" http://s1.51cto.com/wyfs02/M00/86/DE/wKiom1fNfEejTgW7AAB6DpMZ_jY867.jpg " Title= "Which-5.jpg" alt= "Wkiom1fnfeejtgw7aab6dpmz_jy867.jpg"/>
The full path to the CD command cannot be found, and the directory where the CD command is located is not defined in path
which
The Whereis command displays the binary program file path, the user manual file path, the source file path
• Command format:
Whereis [-BMSU] [-bms directory ...-f] filename ...
• Option Parameters:
-B: Search only the path to the binaries file (common)
For example:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/86/DE/wKiom1fNgn_CZgY-AAA1k_QVoj0492.jpg "title=" Whereis-3.jpg "alt=" Wkiom1fngn_czgy-aaa1k_qvoj0492.jpg "/>
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/86/DD/wKioL1fNgMnyOURaAADxo1Q9sZA733.jpg "style=" float: none; "title=" whereis-1.jpg "alt=" Wkiol1fngmnyouraaadxo1q9sza733.jpg "/>
Note that the ordinary user through the which command can not find AddUser, and Whereis could find!
This is because the system itself exists adduser this file, the which command cannot be found because the path command is not joined to the specified directory
So, when you can't find some of the commands, you might want to look it up with a file-search command.
-M: Search only the User manual file path (Common)
For example:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/86/DD/wKioL1fNgMnRag8cAABNp4eLvyQ323.jpg "title=" Whereis-2.jpg "style=" Float:none; "alt=" wkiol1fngmnrag8caabnp4elvyq323.jpg "/>
-S: Search only for source code paths
-U: Search for a file path other than the above 3 paths under the default path
-B: Specifies the path to the search executable file.
-M: Specifies the path to the search Help file.
-S: Specifies the path to search for source code files.
Not to be continued!!
This article is from the "Ccschan" blog, make sure to keep this source http://ccschan.blog.51cto.com/11854461/1846587
Basic Linux Basics Command----3