No Result
View All Result
CloudReports
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner
No Result
View All Result
CloudReports
No Result
View All Result
Home Linux

How to find the Linux file creation date?

npn by npn
April 24, 2022
in Linux
Reading Time: 5 mins read
0
How to find the Linux file creation date?
0
SHARES
768
VIEWS
Share on FacebookShare on Twitter

Contents

    • 0.1 READ ALSO
    • 0.2 Ubuntu 22.04 versus 20.04 comparison
    • 0.3 Linux’s last command
  • 1 Linux file creation date
  • 2 1. WITH STAT
  • 3 2. USING DEBUGFS
  • 4 Conclusions
5/5 - (9 votes)

In the Linux file manager, the properties of a file frequently display only information about the date it was last accessed and the date it was modified. However, there is no date of creation listed. And you may need to look at it from time to time, for example, to determine when the log was created.

READ ALSO

Ubuntu 22.04 versus 20.04 comparison

Ubuntu 22.04 versus 20.04 comparison

April 26, 2022
37.7k
Linux’s last command

Linux’s last command

April 26, 2022
633

In this article, we will explain what data is stored in Linux file systems and how to determine the date of creation of a Linux file. Two convenient methods will be mentioned at the same time, each with their own set of characteristics.

Linux file creation date

The POSIX standard specifies only three types of timestamps that must be stored by the file system:

ADVERTISEMENT
  • atime – the last time the file was accessed.
  • mtime – the last time the content was modified.
  • ctime – the time when access or owner rights were last modified.

As a result, it is frequently impossible to view information about a file’s creation date in older file systems. However, it is already preserved in modern file systems (ext4, zfs, XFS, and so on).
Data on the date of creation is kept in a separate field:

  • Ext4 – crtime
  • ZFS – crtime
  • XFS – crtime
  • btrfs – otime
  • JFS – di_otime


This information can be viewed in two ways: with the stat utility and with debugfs. However, the first method is not applicable to all Linux distributions. The second method is more universal, but it is more difficult to apply. Let us deal with them one at a time.

1. WITH STAT


The stat utility displays detailed information about the file. This includes the date the Linux file was created. To run it in the terminal, simply enter the file’s path. Consider the following information about the image pic_1.jpeg stored in the /home/root-user/Pictures directory:

stat /home/root-user/Pictures/pic_1.jpeg

The Created column has all of the essential information. You may also use the -c option to specify formatting constraints for displaying information, such as keeping only the specified column blank:

stat -c '%w' /home/root-user/Pictures/pic_1.jpeg

However, there is an issue. When running the stat program on some Linux systems, this field is left blank.

The problem was that the output of this information was only visible in statx(2). Its wrapper has been introduced to the glibc library in version 2.28. Support for this technique was included to the GNU coreutils 8.31 suite of fundamental system utilities. Run the following command to see what version it is:

stat --version

This implies that stat will only show information on the file’s creation if specific circumstances are met, as explained above. For example, everything works fine in Ubuntu 21.10, while the field is empty in Ubuntu 20.04.

2. USING DEBUGFS


Debugfs, unlike the stat utility discussed in the preceding section, has no such version constraints. As a result, it will always function. However, the technique for employing it is a little more perplexing. This is because, in order to examine the date of creation of a file using debugfs, you must first determine its inode number and file system. Get inode will exit using the ls command and the -i option, giving the file’s path:

ls -i /home/root-user/scripts/main_script.txt

The df command is also useful for viewing the file system:

df /home/root-user/scripts/main_script.txt

Now that you’ve gathered all of the necessary data, you may use the debugfs software. It must include the -R option, the inode number, and the file system name:

sudo debugfs -R 'stat <28>' /dev/sda5

Locate the field in the terminal that stores the creation date. This was noted at the opening of the article. It’s crtime in this circumstance.

A thorough description of what an inode is may be found in a dedicated page on our website.

Conclusions


We looked at two methods for determining the creation date of a Linux file. The stat tool is a little more convenient because it simply requires the path to it. However, it will not provide the essential information until GNU coreutils version 8.31 is installed. In this aspect, debugfs is more flexible, but less user-friendly. After all, obtaining data necessitates providing the file’s inode number and file system.

Tags: linux debugfslinux stat
ShareTweetShare
Previous Post

Top 10 Best WordPress SEO themes of 2022

Next Post

What is the location of the MySQL databases?

npn

npn

Related Posts

Ubuntu 22.04 versus 20.04 comparison
Linux

Ubuntu 22.04 versus 20.04 comparison

April 26, 2022
37.7k
Linux’s last command
Linux

Linux’s last command

April 26, 2022
633
What is the location of the MySQL databases?
Linux

What is the location of the MySQL databases?

April 24, 2022
597
Configuring VS Code for Node/JavaScript Development
Javascript

Configuring VS Code for Node/JavaScript Development

August 2, 2021
1.3k
How to create a self-signed SSL certificate for Apache on Ubuntu 16.04
Linux

How to create a self-signed SSL certificate for Apache on Ubuntu 16.04

July 18, 2021
1k
Linux

RPC load balancing strategy

June 25, 2019
1.2k
Next Post
What is the location of the MySQL databases?

What is the location of the MySQL databases?

Discussion about this post

No Result
View All Result

Categories

  • Android (1)
  • Ant Design tutorial (7)
  • App/Game (2)
  • Javascript (16)
  • Layout and Routing (2)
  • Linux (9)
  • PC & LAPTOP (6)
  • PERSONAL FINANCES (1)
  • React (13)
  • SQL (2)
  • TECHNOLOGY & DIGITAL (7)
  • The Basics (5)
  • Web development (37)

Search

No Result
View All Result

Categories

  • Android (1)
  • Ant Design tutorial (7)
  • App/Game (2)
  • Javascript (16)
  • Layout and Routing (2)
  • Linux (9)
  • PC & LAPTOP (6)
  • PERSONAL FINANCES (1)
  • React (13)
  • SQL (2)
  • TECHNOLOGY & DIGITAL (7)
  • The Basics (5)
  • Web development (37)
No Result
View All Result
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner