Читать книгу Linux Bible - Christopher Negus - Страница 166
Finding files by date and time
ОглавлениеDate and time stamps are stored for each file when it is created, when it is accessed, when its content is modified, or when its metadata is changed. Metadata includes owner, group, time stamp, file size, permissions, and other information stored in the file's inode. You might want to search for file data or metadata changes for any of the following reasons:
You just changed the contents of a configuration file, and you can't remember which one. So, you search /etc to see what has changed in the past 10 minutes: $ find /etc/ -mmin -10
You suspect that someone hacked your system three days ago. So, you search the system to see if any commands have had their ownership or permissions changed in the past three days: $ find /bin /usr/bin /sbin /usr/sbin -ctime -3
You want to find files in your FTP server (/var/ftp) and web server (/var/www) that have not been accessed in more than 300 days so that you can see if any need to be deleted: $ find /var/ftp /var/www -atime +300
As you can glean from the examples, you can search for content or metadata changes over a certain number of days or minutes. The time options (-atime
, -ctime
, and -mtime
) enable you to search based on the number of days since each file was accessed, changed, or had its metadata changed. The min
options (-amin
, -cmin
, and -mmin
) do the same in minutes.
Numbers that you give as arguments to the min
and time
options are preceded by a hyphen (to indicate a time from the current time to that number of minutes or days ago) or a plus (to indicate time from the number of minutes or days ago and older). With no hyphen or plus, the exact number is matched.