Does renaming affect the file modify or access time? Is there a list somewhere of what changes which times?
Renaming does update the Change time:
$ mkdir tmp $ cd tmp $ echo abc > a $ stat a File: `a' Size: 4 Blocks: 8 IO Block: 4096 regular file Device: 26h/38d Inode: 5038682 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000 / zelda Gid: ( 1000/ zelda) Access: 2013-12-12 07:06:58.981107444 +0100 Modify: 2013-12-12 07:06:58.981107444 +0100 Change: 2013-12-12 07:06:58.981107444 +0100 Birth: - $ mv a b $ stat b File: `b' Size: 4 Blocks: 8 IO Block: 4096 regular file Device: 26h/38d Inode: 5038682 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/ zelda) Gid: ( 1000/ zelda) Access: 2013-12-12 07:06:58.981107444 +0100 Modify: 2013-12-12 07:06:58.981107444 +0100 Change: 2013-12-12 07:07:14.893238472 +0100 Birth: -
The Access time is updated when reading the contents of a file. Modify when you actually update the file (opening for modification is not enough to change Modify time).
A modification affecting the file's mtime is a change of the file's data: a write of a nonzero amount of bytes, or a truncation that ends up modifying the file. Creating a file sets its mtime to the current date as well. Merely opening a file for writing doesn't affect the mtime, assuming the file isn't created or truncated.
Reading from a file (if a nonzero number of bytes is read) or executing a file sets its atime to the current time. Merely opening a file for reading never affects the atime. On Linux, this is now disabled by default in most circumstances; the
atime mount option restores atime updates, while the
noatime mount option disables them completely.
Programs can change the mtime and the atime of a file; the basic command to do this is
touch. Some file copy programs set the copy to the same mtime as the original, for example
cp -p or
A change affecting the file's ctime is a change of the file's metadata: permissions, owner, times, link count, etc. Renaming a file also updates its ctime. Changes of the file data also affect the ctime, but reading from a file doesn't change the ctime even if it changes the atime. It is impossible to change the ctime in any way other than setting it to the current time (even root is constrained, but root can indirectly set the ctime by first changing the system time or by accessing the partition containing the filesystem directly).