Linux

How to display the creation date of a file in Linux

It is possible that more than once you have had trouble seeing the creation date of a file on a Linux server. If you've ever wondered how could i see the date creating a file in Linux , You are in the right place.

In this article, we will teach you how to get the crtime, or CReation Time, that is, the dates of access, modification and creation of a file on a system. GNU / Linux .

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

Before you begin, to find out if the file system is EXT4 you must enter the df-T command in the file. Once we corroborate this, we proceed to the consultation and visualization of the creation date of a file in Linux.

If in the directory, we get a previous output, the dash in the middle in the field " Birth" means that the file system we are working in does not support storing the creation date, so it is not possible to display said date.

As a result, userspace tools may not be able to get this information correctly, at least in older versions.



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

When we use operating systems such as Linux , each component itself is tagged as a file and every time we make a change to any of them they are saved in an inode.

In order to obtain the INODE_NUMBER , or the inode number found in the file, we need to search for it as follows: is-i-file . With it we can get the inode number that we need to use in the next command.

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

  • File creation date
  • Inode number
  • Modifications made
  • Last change of state
  • Last access, among others.

To be able to do this, it is necessary to start by having as reference the root of the systems which contains the file to be reviewed. On Linux, they exist with parameters like

  • Ctime , which displays the time of the change
  • Like , generate access time
  • mtime , the modification time
  • Crime , the date and time when the file was created.

Find the file creation date

As we explained previously, 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, via the command: ~$stat.

To perform this action, you must go to the directory where the file is located, and from there analyze the information displayed, such as the last access and the date of modification, the links, the size, the number of inode, etc.

Now with the inode number, which we'll copy and paste into the directory, keeping the brackets as follows: 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 you want to see the modified dates, you must use the long list option (-the), all dates of file modification are displayed by default under linux .

If you also add " -u ", you will get the dates when the file was last opened for reading or editing.

It's that easy to learn how to display the creation date of a file in linux . If you have any questions, you can leave them in the comments area a little further down.

Similar items

Leave your comment

Your email address will not be published. Required fields are marked with *

Button back to top