ls -c vs. ls -u / manpage / architecture question

Chuck Swiger cswiger at
Fri Feb 24 18:30:29 PST 2006

lalev at wrote:
[ ... ]
> I could see in the source of ls that these two options
> are opposite of each other, but being ignorant about
> the architecture of UNIX file system, i'm not positive
> that in addition to the time of last modification
> and the time of last access, there is not
> another time - "file status change time".
> Or is it what I suppose, that the -c option is just on by default
> and no other than these 2 times are saved in the file system
> info about the file.

There are three timestamps kept per file in Unix (see "man 2 stat"):

    The time-related fields of struct stat are as follows:

     st_atime      Time when file data last accessed.  Changed by the
                   mknod(2), utimes(2), read(2) and readv(2) system calls.

     st_mtime      Time when file data last modified.  Changed by the
                   mkdir(2), mkfifo(2), mknod(2), utimes(2), write(2) and
                   writev(2) system calls.

     st_ctime      Time when file status was last changed (inode data modifi-
                   cation).  Changed by the chflags(2), chmod(2), chown(2),
                   creat(2), link(2), mkdir(2), mkfifo(2), mknod(2),
                   rename(2), rmdir(2), symlink(2), truncate(2), unlink(2),
                   utimes(2), write(2) and writev(2) system calls.

By default, ls uses st_mtime; -c means st_ctime; -u means st_atime.


More information about the freebsd-questions mailing list