When I run ls -l, it lists a modification time for both files and directories.  As noted in this thread, the modification time for directories does not reflect all of its contents. It also does not seem to be affected by changing the name of the directory. What exactly does the modification time for a directory reflect?

Is it the latest modification time of a file (or directory) in the top level of the directory?

2 Answers 2


Note that, in Unix, a directory does not "contain" the files in it. Rather, it contains links to them. See the link(2) system call for further information.

This means that the "direct" contents of a directory is a list of filenames and corresponding i-numbers. The modification date of the directory, therefore, indicates whenever this list changed. Operations that would cause such changes would include, but not necessarily be limited to, the following:

  • Creating a new file in the directory
  • Removing (or, rather, unlink(2)ing) a file from the directory
  • Renaming a file in the directory
  • Hard-linking a file elsewhere into the directory

Think of directory as of simple file containing list of other files. Whenever you change its contents (rename files, add or remove contained files) the modification time of a directory changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .