Leave yesterday's, to yesterday, today, you will start again.
OK, in the first stage we learned the operation commands of the file directory:
| 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
| Ls |
Cd |
Pwd |
Mkdir |
Rm |
RmDir |
Mv |
Cp |
Touch |
Cat |
nl |
More |
Less |
Head |
Tail |
Next we will learn the file Lookup command:
| 1 |
2 |
3 |
4 |
| which |
Whereis |
Locate |
Find (Exec/xargs) |
Words don't say much, which walk up:
Which viewing the location of an executable file
Whereis viewing the location of a file
Locate to view file locations with a database
Find actual search hard disk query file name
The purpose of the which command is to search for the location of a system command in the path specified by the path variable, and to return the first search result, that is, by using the which command, you can see whether a system command exists, and which command is executed at which point.
1. Command format:
which executable file name
2. Command function:
The which instruction searches for the location of a system command in the path specified by the path variable, and returns the first search result.
3. Command parameters:
-n Specifies the length of the file name, which must be greater than or equal to the longest file name in all files.
-P is the same as the-n parameter, but the path to the file is included here.
-W Specifies the width of the field at the output.
-V Displays version information.
4. Usage examples:
Example 1: Finding files, displaying command paths
Command:
which pwd it outputs a path/bin/pwd, which is to search for a running document based on the directory within the path variable configured by the user, so the commands found for different path configurations are certainly not the same.
Example 2: Use which to find which
Command:
Which which it will output two paths: Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
/usr/bin/which
One of these two aliases. This is called a "command alias", and if a command has alias, which will print out its alias and path.
Example 3: Find the CD command
Command:
which CD
Output a bunch:/usr/bin/which:no CD in (PATH)
In this case, the CD command was not found because the CD command is not in the search scope, it is a bash built in command ~, but which is searched from PATH. All cannot be found.
One Linux command per day (--which) command