Does directory mtime always change when a new file is created inside?

Is it always true that when a new file is created in a directory - the directory's mtime changes?


The short answer is yes, it should. A longer answer follows.

A directory is a special kind of file; its contents is a set of (filename, i-node) tuples. Thus directory's mtime is updated whenever a tuple is added, removed or changed - that is, a file of any type (including hard links and directories) is added, removed or renamed in the directory (but not in nested directories - those are different "files").

Please note when file's metadata changes (owner, group, mode, atime, ctime, mtime - hosted in i-node), mtime is NOT updated (neither on the file nor containing dir) but the file's ctime does.

See also Base Definitions volume of IEEE Std 1003.1-2001, Section 4.7, File Times Update.