Recently we wanted to check when did the permissions of a specific file changed.
Unfortunately, there exists no such flag and we do not have a 100% working solution for it.
What we did was to check the last modification time of the file status information
(ctime
) using the ls -lc
command.
This command could indicate the last permissions change time but it is not a reliable source as it represents the modification time of other elements as well.
The modification time of the file status information (ctime
) gets updated when any inode
information regarding the file changes.
This means that the modification time of the file status information (ctime
) will get updated when any of the following changes:
owner
– The numeric user ID (UID) of the file’s owner.group
– The numeric group ID (GID) of the file’s group.link count
– The number of links to the file.mode
– The bit string that indicated the permissions and privilegesserial
– The serial number of the file.device
– The numeric ID of the device containing the file.
Explanation of ls parameters
- The parameter
-c
of thels
command when used with the-l
will showctime
and sort by name. - The parameter
-c
of the ls command when used with the-l
and the-t
will showctime
and sort byctime
(newest first).
Example that demonstrates that we get different values in the time column of -l
when -c
is used
$ ls -lc ~/.ssh/ total 28 -rwx------. 1 george george 225 May 16 17:05 config -rwx------. 1 george george 1743 Jun 2 13:36 id_rsa -rwxrwx---. 1 george george 405 May 16 17:05 id_rsa.pub -rwxrwx---. 1 george george 32 May 16 17:05 Details.txt -rw-r--r--. 1 george george 9155 May 30 14:32 known_hosts $ ls -l ~/.ssh/ total 28 -rwx------. 1 george george 225 Mar 22 11:36 config -rwx------. 1 george george 1743 Jan 25 10:22 id_rsa -rwxrwx---. 1 george george 405 Jan 25 10:22 id_rsa.pub -rwxrwx---. 1 george george 32 Jan 25 10:22 Details.txt -rw-r--r--. 1 george george 9155 May 30 14:32 known_hosts
This post is also available in: Greek