Last update at :2024-07-03,Edit by888u
I have recorded part of the usage of the find command once before. The reason why I want to do it again after so many years is that I sadly discovered that a certain site was invaded and a lot of files were changed. At this time, I used the find command to find the changes in a certain time period. file, so I’ll bring it out for reference next time.
Find files by file name
For example, if we want to find a certain file in the system, we know that the file name is a.php
find / -name a.php
As above/ indicates which directory it is in. If you know which directory it is in, you can also write to the directory to make the scope smaller.
Find files by incomplete file name
We can also search for files by incomplete names. For example, we want to find all php files in the system, or know certain 2 letters in the name of the php file.
find / -name *.php #Find all php files find / -name wp*.php #Find the php file whose file name starts with wp
Search by file characteristics
Here we take searching by file size as an example, especially when we need to find large files.
find / -size 1500c #Find files with size 1500bytes find / -size +1500c #Find files larger than 1500bytes find / -size -500c -size +50c #Find files larger than 50bytes and smaller than 500bytes
Other ways to search
For example, through time, through modification time, etc.
find / -amin -10 # Find files accessed in the last 10 minutes on the system find / -atime -2 # Find files accessed in the last 48 hours in the system find / -empty # Find empty files or folders in the system find / -group cat # Find files belonging to group cat in the system find / -mmin -5 # Find files modified in the last 5 minutes in the system find / -mtime -1 #Find files modified in the last 24 hours in the system find / -nouser #Find files belonging to invalid users in the system find / -user fred #Find files belonging to the user FRED in the system find / -mtime +3 #Find files that were changed 3 days ago find / -name '*.php' -mtime -3 #Find php files that have been changed within 3 days find / -name 'wp*' -mtime 0 #Find files starting with wp that have been modified within 24 hours
Recommended site search: registered website domain name registration, Guangdong server hosting godaddy space, US server website, mainland China registration-free server, 6 yuan a year cloud server free cloud server, telecommunications host, Hong Kong server,
发表评论