There are 3 kind of "timestamps":
- Access - the last time the file was read
- Modify - the last time the file was modified (content has been modified)
- Change - the last time meta data of the file was changed (e.g. permissions)
To display this information, you can use stat
which is part of the coreutils.
stat
will show you also some more information like the device, inodes, links, etc.
Remember that this sort of information depends highly on the filesystem and mount options. For example if you mount a partition with the noatime
option, no access information will be written.
A utility to change the timestamps would be touch
. There are some arguments to decide which timestamp to change (e.g. -a for access time, -m for modification time, etc.) and to influence the parsing of a new given timestamp. See man touch
for more details.
touch
can become handy in combination with cp -u
("copy only when the SOURCE file is newer than the destination file or when the destination file is missing") or for the creation of empty marker files.
The field st_atime is changed by file accesses, for example, by execve(2), mknod(2), pipe(2),
utime(2) and read(2) (of more than zero bytes). Other routines, like mmap(2), may or may not update
st_atime.
The field st_mtime is changed by file modifications, for example, by mknod(2), truncate(2), utime(2)
and write(2) (of more than zero bytes). Moreover, st_mtime of a directory is changed by the creation
or deletion of files in that directory. The st_mtime field is not changed for changes in owner,
group, hard link count, or mode.
The field st_ctime is changed by writing or by setting inode information (i.e., owner, group, link
count, mode, etc.).