Which (for "execution files") [root @ linux ~] # Which [-a] command parameter:-a: lists all commands that can be found, not just the first command name example: [root @ linux ~] # Whichpasswd/usr/bin/passwdwhereis (for specific files) [root @ li
Which (search for "execution files 』)
[Root @ linux ~] # Which [-a] command
Parameters:
-A: lists all commands that can be found, not the first command name.
Example:
[Root @ linux ~] # Which passwd
/Usr/bin/passwd
Whereis (find a specific file)
[Root @ linux ~] # Whereis [-bmsu] file or directory name
Parameters:
-B: only find binary files.
-M: only find the file under the manual path of the description file.
-S: only find the source file
-U: there is no description file!
Locate file name or directory name
Find
[Root @ linux ~] # Find [PATH] [option] [action]
Parameters:
1. time-related parameters:
-Atime n: n indicates the number of files accessed within one day before n days;
-Ctime n: n indicates an archive whose status has been changed before n days;
-Mtime n: n indicates the number of files that have been modification within one day before n days;
-Newer file: file is an existing file, which means that as long as the file is newer than the file,
Will be listed ~
2. parameters related to user or group names:
-Uid n: n is a number, which is the user's account ID, that is, UID, which is recorded in
The number corresponding to the account name in/etc/passwd. In this regard, we will introduce the fourth article.
-Gid n: n is a number, which is the ID of the group name, that is, GID. this GID is recorded in
/Etc/group ~
-User name: name indicates the user account name! For example, dmtsai
-Group name: name indicates the group name, for example, users;
-Nouser: The owner of the file does not exist./etc/passwd!
-Nogroup: The Owner group of the target file does not exist in the/etc/group file!
When you install the software on your own, it is likely that there are no file owners in the software attributes,
This is possible! At this time, you can use-nouser and-nogroup to search.
3. parameters related to file permissions and names:
-Name filename: searches for files named filename;
-Size [+-] SIZE: searches for files that are larger (+) or smaller (-) than the SIZE. The SIZE specifications include:
C: represents byte, and k: represents 1024 bytes. Therefore, we need to find a value smaller than 50KB.
A large file is "-size + 50 k 』
-Type TYPE: the TYPE of the file to be searched is type. The main types are: general regular files (f ),
Device file (B, c), Directory (d), link File (l), socket (s ),
And FIFO (p.
-Perm mode: searches for files with the archive attribute "exactly equal to" mode. this mode is similar to chmod.
For example, the property of-rwsr-xr-x is 4755!
-Perm-mode: Searches for archives whose attributes "all mode attributes must be included". for example,
We want to search for-rwxr -- r --, that is, 0744 files, using-perm-0744,
When the attribute of an archive is-rwsr-xr-x, or 4755, it is also listed,
Because the attributes of-rwsr-xr-x already include the attributes of-rwxr -- r.
-Perm + mode: Searches for archives whose attributes include the attributes of any mode. for example, we search
-Rwxr-xr-x, that is,-perm + 755, but an archive property is-rw -------
It will also be listed because it has a property of-rw!
4. Additional actions:
-Exec command: command is another command.-exec can be followed by additional commands to process and search
.
-Print: print the result to the screen. this action is a preset action!
Example:
Example 1: list files with updated content (mtime) in the past 24 hours
[Root @ linux ~] # Find/-mtime 0
# That 0 is the key! 0 represents the current time, so from now until 24 hours ago,
# Files with changed content will be listed! What if it was within 24 hours three days ago?
# Find/-mtime 3, which means 3*24 ~ Between 4*24 hours
# All changed files are listed! -Atime and-ctime are used in the same way.
Example 2: find the files under/etc. if the file date ratio is/etc/passwd, list the files.
[Root @ linux ~] # Find/etc-newer/etc/passwd
#-Newer is useful in distinguishing between two archives!
Example 3: Search for dmtsai files under/home
[Root @ linux ~] # Find/home-user dmtsai
# This is also useful ~ When we want to find all the files of any user in the system,
# You can use this command to retrieve all files belonging to a user!
Example 4: search for files that do not belong to anyone in the system
[Root @ linux ~] # Find/-nouser
# Using this command, you can easily find out abnormal files.
# Do not be too nervous when you find a file that does not belong to anyone in the system,
# Sometimes it is normal ~ Especially when you compile software with the original code.
Example 5: find the file named passwd.
[Root @ linux ~] # Find/-name passwd
# Use this-name to search for the file name!
Example 6: Search for archives whose attributes are f (General Archives)
[Root @ linux ~] # Find/home-type f
# This-type attribute is also very helpful! Especially to find out the weird archives,
# For example, you can use find/var-type p or-type s to find the socket and FIFO files!
Example 7: Search for attributes containing SGID, SUID, and SBIT
[Root @ linux ~] # Find/-perm + 7000
# The so-called 7000 is --- s -- t, which is listed as long as it contains s or t,
# Of course, you must use + 7000 and use-7000 to indicate that all three permissions containing --- s -- t are required,
# Therefore, it is + 7000 ~? Hu?
Example 8: use ls-l to list the files found in the previous example ~
[Root @ linux ~] # Find/-perm + 7000-exec ls-l {}\;
# Note that the ls-l after-exec is an additional command,
# The {} represents the meaning of "content found by find ~ Therefore,-exec ls-l {}
# List the files found above with ls-l for long data! As for \;, it indicates
#-What is the meaning of exec commands till now ~ This means that the entire command is only
#-Exec (where commands are issued )\;
# That is to say,-exec must end with \; at last! Do you understand this ?!