Sometimes, you might be interested to know when a file was created on a Linux system. In this guide, we will check out how to do exactly that. We will explore various ways that you can find out the file creation date on a Linux system.
1. Check the File Creation Date in Linux
The stat command is a command line utility that displays detailed information about a file. It lists information that includes file size, UID (User ID), GID (Group ID), file access, modification time, and creation dates.
To check the file creation date, simply run the following command where sample1.txt is the name of the file
$ stat sample1.txt
From the output, the Birth directive shows the file creation date.
To narrow down to the file creation date, pass the
-c %w arguments as shown.
$ stat -c %w sample1.txt
Let’s make a few changes to the file by adding content using the echo command.
$ echo "Some Text" >> sample1.txt
When you view the file details, you’ll observe that the Modify field changes to indicate that the modification time has changed.
2. Display File Creation Date 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 sample1.txt
Next, find the partition where the file is located using the df command shown
$ df ./sample1.txt
Finally, run the following debugfs command to find out the file creation date.
$ sudo debugfs -R 'stat <8126822>' /dev/sda5
The crtime field displays the file creation time and date.
You are all set! In this guide, we have looked at two ways of revealing or checking the file creation date on a Linux system.