Is there a specific Unix/Linux command that would show when a file was renamed? I have a file in a Linux box and want to know when the file got renamed. I tried ls -ltr
but that command only shows the date when it was created and not when it was last modified.
Is there a specific Unix/Linux command to do this?
There's no way to tell for sure whether a file has been renamed. When a file is renamed, its inode number doesn't change. (This may not be true for “exotic” filesystems, such as network filesystems, but it's true for all “native” Unix filesystems.)
Give me the files, stat!The stat command can show file size, type, UID/GUID and the access/modify time. Here is the stat of my “/etc” folder. Notice the simplicity of the command. You can see the date it was last accessed, the modify time and the last change.
You can use the ls command to list files including their modification date by adding the -lt flag as shown in the example below. The flag -l is used to format the output as a log. The flag -t is used to list last modified files, newer first.
You can use the stat command on a file to check access and modification times or set up RCS to track changes. You can use MD5 or sum to get the current state of the file, copy that value to a file and then that file to verify that the original file wasn't changed.
You can use
stat filename
Check Access
when it was last read.
Check Modify
when it was updated.
Check Change
if it was renamed.
Plus other file info like blocks, inodes, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With