How can I display the creation date of a file in Linux

0
197

It is possible that more than once it has happened to you that you have had some inconvenience in being able to see the creation date of a file on a Linux server. If you ever wondered how I can display the creation date of a file in Linux, you are in the right place.

In this article, we are going to show you how to obtain the crtime, or CReation Time, that is, dates of access, modification, and creation of a file in a GNU/Linux system.

Note that you will only be able to know the creation date of a file in Linux if the file system is created as EXT4. If, on the other hand, it is earlier, it is not possible to know these data.

Before starting, in order to know if the file system is EXT4, we must enter the df-T command in the file. Once we have confirmed this, we proceed to consult and display the date of creation of a file in Linux.

If in the directory, we get an older output, the middle dash in the “Birth” field means that the file system we are working on does not support saving the creation date, so it is not possible to display that date .

Therefore, it happens that the user space tools are not capable of obtaining this information properly, at least in older versions.

check file date in linux

How to display the creation date of a Linux file in a few steps

When we use operating systems like Linux, each component within it is labeled as a file and every time we make a change in any of these, they are saved in an inode.

In order to obtain the INODE_NUMBER, or the inode number that is inside the file, we must look for it in the following way: Is-i-file. With it we can get the inode number that we must use in the following command.

Linux is responsible for differentiating and selecting each file by its respective inode number, which is not the same name with which it was created. The idea is to use the “Stat” or “Statistics” command, as its name indicates, to display the status of the file system by creating useful information such as:

  • File creation date
  • inode number
  • Modifications made
  • Last status change
  • Last access, among others.

In order to do so, we must start with the system root that contains the file to review as a reference. In Linux, they exist with parameters like

  • Ctime, which displays the time of change

  • Atime, generates the access time

  • Mtime, the modification time

  • Crtime, the date and time the file was created.

verify-file-linux

Find file creation date

As explained above, we are going to use Crtime, to be able to display the date and time of creation of a Linux file. Since this parameter is the one in charge of finding the inode of the file, through the command: ~$ stat.

In order to execute this action, we must go to the directory where the file is located, and from there analyze the information that is displayed, such as the last date of access and modification, links, size, inode number, etc.

Now with the inode number, we’re going to copy and paste it into the directory, keeping the brackets like this: debugfs -R ‘stat ‘ /dev/sda1. Where /dev/sda1 is where the drive is mounted. And we can see that in the crtime line we get the date we were looking for.

If, instead, what you want is to display the modification dates, you must use the long list option (-l), all file modification dates are displayed by default in Linux.

If in addition to this you add “-u” what you will get are the dates of the last time the file was opened for reading or modification.

That’s how easy it is to learn how I can display the creation date of a file in Linux. Any questions you have you can leave it in the comment box a little below.

Previous articleHands always cold: what is it and tips to relieve them
Next articleSecurity tips so you don’t get hacked this Easter