Linux find commands (with instances) and mtime ctime atime, mtimeatime
This time, I will explain the three time periods displayed in the three Linux Files, and then demonstrate the functions of the find command.
In linux, each file has many time parameters, three of which are the mainCtime, atime, mtime
- Modification time (mtime ):
This time is updated when the file content data is modified, but mtime does not change when the permission or attribute is changed, which is different from ctime.
This time will be updated when you modify the permissions or attributes of the file. ctime is not the create time. It makes me feel like change time, but it is not completely correct, this is because the time will be updated only when the attributes or permissions of the file are updated. If you change the content, the time will not be updated.
This time will be updated when this file is used.
So why does atime not change when I use vim to open a file? Because in my current version,With the concept of relatimeIf we frequently read and access files, we will frequently modify atime, and then frequently access disk I/O. The performance will drop sharply. To be honest, it's slow! After the relatime parameter is used,Atime is not updated unless atime is earlier than mtime or ctime.
Tragedy: Chinese linux has been translated for three times...
Find command details, it has a lot of functions, very powerful, strong real-time, every time you find a file will be very old to find in the disk, so it is very slow...
Find path-option [-print] [-exec-OK command] {}\;
PS: [] is optional, that is, additional options
-Path: the file path.
-Option: the parameters to be described below,Some parameters are followed by operands. Note that
-Print: The find command outputs matching files to the standard output.
-Exec:-OK is an option of-exec. When the command is executed, the user is asked
{}\:Note that there is a space between the braces and the backslash.
-;:Note !!!! A semicolon is required !!!
A command I wrote is displayed,Look! There must be no fewer semicolons (because I always forget to write them several times)Because ls-l itself won't ask the user (rm command will ask, try rm), so naturally it won't use-OK. After I remove-OK, you can execute ls-l normally,
Detailed description of the find Command Parameters
The find command has many parameters, which are described in detail below.
- -Name filename # Find the file named filename, and put the following in a figure.
- -Perm # search by execution permission. You can use the permission code when using permission search.
Isn't that a sequence traversal?
- -Fstype: searches for files in a certain type of file system. The file system type can be found in/etc/fstab.
What does this parameter mean? I don't know how to test it. I haven't found anything after testing it.
- -Mount # The mount point of the file system is not crossed during file query.
This parameter does not seem to be allowed to go to the subdirectory for search. I tried it and the file in the subdirectory said it could not be found.
- -Follow # If a symbolic link file is encountered, the file indicated by the link will be tracked.
When there is a hard link, it will not be tracked. There is an instance below. file_hard is a hard link and file_ln is a symbolic link. When I delete the soft link, it will not be tracked. /test/file indicates that hard links cannot be tracked.
- -Cpio # Use the cpio command to back up the matching files to the tape device.
After a common search result, back up the file and write it to the disk...
- -Prune # ignore a directory
That's not enough ....
Finally, I strongly hope you will correct your criticism !! I still have many questions. I would like to thank you!