How to check file creation date in Linux Ubuntu commandline. Here is an easiest way to check timestamp of file in Linux.
Let us learn about the two commands to check file creation date in Ubuntu and check last modified file in Linux.
Method 1. Using Stat Command
To check the file creation date, simply run the following command where demofile1.txt is the name of the file
$ stat demofile1.txt
From the output, the Birth directive shows the file creation date.
The above command displays all the informtion attched to the file. To narrow down the search result file creation date, pass the -c %w arguments as shown.
$ stat -c %w demofile1.txt
The ‘stat’ command displays information about the specified file(s). With no option, ‘stat’ reports all information about the given files.
Method 2. Using debugfs Command
The other way of checking the file creation date is by using the debugfs command. However, this is a multi-stage operation and more complex than the stat command.
First, you need to get the file’s inode number using the ls command shown.
$ ls -i demofile1.txt
Next, find the partition where the file is located using the df command shown
$ df ./demofile1.txt
Finally, run the following debugfs command to find out the file creation date.
$ sudo debugfs -R 'stat <2256081>' /dev/sda2
NOTE: 2256081 is the inode number of the file. The crtime field displays the file creation time and date.
The following output shows the crtime alongwith ctime, atime and mtime.
Inode: 2256081 Type: regular Mode: 0664 Flags: 0x80000
Generation: 3350473792 Version: 0x00000000:00000001
User: 1000 Group: 1000 Size: 316
File ACL: 0 Directory ACL: 0
Links: 1 Blockcount: 8
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x666680f0:285a5028 -- Mon Jun 10 09:58:32 2024
atime: 0x666680f0:257de410 -- Mon Jun 10 09:58:32 2024
mtime: 0x666680f0:285a5028 -- Mon Jun 10 09:58:32 2024
crtime: 0x666680f0:257de410 -- Mon Jun 10 09:58:32 2024
Size of extra inode fields: 32
EXTENTS:
(0):8994391
(END)
That’s all. You are all aware of the two ways of checking the file creation date on a Linux Ubuntu system.