Get File Creation Date/Time in Bash
1. OverviewIn this tutorial, we’ll learn various methods to get the file creation date on Linux systems.2. Why Can’t We Get the Creation Date on Old Systems?Older systems run old versions of filesystems, which don’t store the file creation date.As the POSIX standard only specifies three types of timestamps to be stored for a file, there is no requirement for a filesystem to support anything beyond them. These three timestamps store information about:Last data access –atimeLast data modification –mtimeFile status changes –ctimeHowever, newer filesystems such asext4,zfs,btrfs,JFS,andXFSdo store the creation timestamp in separate fields:ext4 –crtimezfs –crtimeXFS –crtimebtrfs –otimeJFS –di_otimeThese fields point to data stored in file inodes.3. Getting the File Creation Date UsingstatThe easiest way to get the file creation date is with the stat command.Let’s create a file and check its creation time:$ date; echo Hello file Fri Dec 17 11:26:25 IST 2021 $ cat file Hello $ stat file File: file Size: 6 Blocks: 8 IO Block: 4096 regular file Device: 19h/25d Inode: 1451722 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/baeldung) Gid: ( 1000/baeldung) Access: 2021-12-17 11:26:25.578441510 0530 Modify: 2021-12-17 11:26:25.578441510 0530 Change: 2021-12-17 11:26:25.578441510 0530 Birth: 2021-12-17 11:26:25.578441510 0530CopyAs we can see, the creation date is shown in the “Birth” field.Now, let’s modify the file and check that only the “Modify” field changes, as it indicates the last modification time:$ echo Modified file $ cat file Hello Modified $ stat file File: file Size: 15 Blocks: 8 IO Block: 4096 regular file Device: 19h/25d Inode: 1451722 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/baeldung) Gid: ( 1000/baeldung) Access: 2021-12-17 11:26:25.578441510 0530 Modify: 2021-12-17 11:28:32.290443553 0530 Change: 2021-12-17 11:28:32.290443553 0530 Birth: 2021-12-17 11:26:25.578441510 0530CopyWe can also instructstatonly to give us the required data, which is the file creation date in our case.For this, we can use the–formatflag with%was its value:$ stat -c %w file 2021-12-17 11:26:25.578441510 0530CopyAdditionally, there are many other formats, which can be found withstat –help:$ stat --help ... The valid format sequences for files (without --file-system): ... %U user name of owner %w time of file birth, human-readable; - if unknown %W time of file birth, seconds since Epoch; 0 if unknown %x time of last access, human-readable ...Copy4. Getting the File Creation Date UsingdebugfsWe can also use the debugfs command to find the creation date on ext4 filesystems. However, it is not as intuitive as thestatcommand since its primary purpose is to debug filesystems.Firstly, we need the inode number of our file. We can find it with the ls command.The-iflag makeslsprint the inode numbers of files:$ ls -i ./file 5118705 ./fileCopyWe also need the filesystem of the file. We can find this with the df command:~ $ df ./file Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 26046564 8380600 16338936 34% /CopyNow, we can pass this information to thedebugfscommand.The syntax isdebugfs -R ‘stat inode’ /dev/sdXwhereinodeis our file inode, and/dev/sdXis the filesystem of the file:$ sudo debugfs -R stat 5118705 /dev/sda2 debugfs 1.46.4 (18-Aug-2021) Inode: 5118705 Type: regular Mode: 0644 Flags: 0x80000 Generation: 2975709199 Version: 0x00000000:00000001 User: 1000 Group: 1000 Project: 0 Size: 8 File ACL: 0 Links: 1 Blockcount: 8 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x61bc31c8:19fee850 -- Fri Dec 17 06:44:24 2021 atime: 0x61bc3224:7f8fe250 -- Fri Dec 17 06:45:56 2021 mtime: 0x61bc31c8:19fee850 -- Fri Dec 17 06:44:24 2021 crtime: 0x61bc2b65:71f8e150 -- Fri Dec 17 06:17:09 2021 Size of extra inode fields: 32 Inode checksum: 0x5ddd5b4b EXTENTS: (0):5279293CopyHere, the creation time is in thecrtimefield mentioned earlier. We can see that we created the file on“Fri Dec 17 06:17:09 2021”.While thectimefield sounds similar tocrtime,it does not tell us the file creation date. It shows us the last time the file status was changed due to modifications such as changing the file permissions.5. ConclusionIn this article, we covered the historical reasons for the unavailability of file creation dates, along with the methods to get the creation date on modern systems.

相关新闻

基于大模型构建文件格式不符合平台要求导致上传失废标风险智能识别系统完

基于大模型构建文件格式不符合平台要求导致上传失废标风险智能识别系统完

这里写自定义目录标题欢迎使用Ma rkdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个…

2026/9/3 17:23:08 阅读更多 →
嵌入式开发实战:从PPT方案到稳定产品的防坑落地指南

嵌入式开发实战:从PPT方案到稳定产品的防坑落地指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 17:22:07 阅读更多 →
Java项目构建脚本实战:从Maven到Jenkins统一构建流程

Java项目构建脚本实战:从Maven到Jenkins统一构建流程

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 17:22:07 阅读更多 →

最新新闻

OFDM系统MATLAB仿真:从原理到误码率曲线实践指南

OFDM系统MATLAB仿真:从原理到误码率曲线实践指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 18:03:48 阅读更多 →
py-kms新版部署实践:KMS激活服务器搭建与排障指南

py-kms新版部署实践:KMS激活服务器搭建与排障指南

简介:Py-KMS是一款基于Python的开源KMS服务实现,用于在内网或离线下模拟微软KMS激活机制,批量激活Windows与Office产品,适合需统一管理授权的中小企业、IT运维人员及开发测试者。此版本源自ThunderEX维护的持续更新分支&#xff0…

2026/9/3 18:03:48 阅读更多 →
jacob-1.18 jar和dll配置详解:从JNI原理到UnsatisfiedLinkError排查

jacob-1.18 jar和dll配置详解:从JNI原理到UnsatisfiedLinkError排查

简介:Jacob 1.18 是 Java COM Bridge 的完整组件包,面向 Windows 平台上需要调用 COM 组件的 Java 开发者,可解决 Office 文档自动化、Excel 读写、PowerPoint 控制等互操作需求。压缩包共 92 个文件,以 HTML API 文档为主&#x…

2026/9/3 18:03:48 阅读更多 →
【鲁棒优化、大M法、CCG算法】计及风、光、负荷不确定性两阶段鲁棒优化附Matlab代码

【鲁棒优化、大M法、CCG算法】计及风、光、负荷不确定性两阶段鲁棒优化附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,擅长毕业设计辅导、数学建模、数据处理、算法改进、程序设计科研仿真。🍎 往期回顾关注个人主页:完整代码获取 定制创新 论文复现私信🍊个人信条:做科研&#xff0c…

2026/9/3 18:03:48 阅读更多 →
【机械臂控制】基于matlab具有参数不确定性的动态非线性系统机械臂鲁棒控制研究附Matlab代码

【机械臂控制】基于matlab具有参数不确定性的动态非线性系统机械臂鲁棒控制研究附Matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,擅长毕业设计辅导、数学建模、数据处理、算法改进、程序设计科研仿真。🍎 往期回顾关注个人主页:完整代码获取 定制创新 论文复现私信🍊个人信条:做科研&#xff0c…

2026/9/3 18:03:48 阅读更多 →
AI内容生成边界:技术博客助手为何拒绝娱乐类请求?

AI内容生成边界:技术博客助手为何拒绝娱乐类请求?

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 18:02:48 阅读更多 →

日新闻

AI智能体辅助JS逆向:从V8环境搭建到补环境实战

AI智能体辅助JS逆向:从V8环境搭建到补环境实战

先别急着点开,这不是劝退文,而是想讲清楚一件事:用 AI 做逆向值不值得学?如果要用,怎么搭一套“V8 环境 AI 智能体”来提升效率。最近逆向圈、爬虫圈都在聊 AI Agent、AST 工程逆向、JS 逆向这些词,很多新手…

2026/9/3 0:00:29 阅读更多 →
安卓设备通过修改机型信息解锁游戏高帧率:原理、操作与风险指南

安卓设备通过修改机型信息解锁游戏高帧率:原理、操作与风险指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 0:00:29 阅读更多 →
ARM版OpenJDK 11安装部署全攻略:下载、配置与避坑指南

ARM版OpenJDK 11安装部署全攻略:下载、配置与避坑指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/3 0:00:29 阅读更多 →

周新闻

备战数据库管理工程师校招:索引、事务、备份恢复核心考点解析

备战数据库管理工程师校招:索引、事务、备份恢复核心考点解析

每年校招季我都会接触不少准备数据库方向笔试的同学,看到最多的状态就是:简历上写着“熟悉 MySQL”“了解索引优化”,一碰到数据库管理工程师的笔试卷,却在索引、事务、锁、备份恢复这些题目上翻车。网易这套 2018 校园招聘数据库…

2026/9/3 4:22:22 阅读更多 →
数字电路时序基石:深入理解建立时间与保持时间

数字电路时序基石:深入理解建立时间与保持时间

1. 这不是“背公式”的事:时间参数到底在约束什么你翻过数字电路教材,一定见过这两个词:建立时间(Setup Time)和保持时间(Hold Time)。它们常被并列写在触发器(Flip-Flop&#xff09…

2026/9/3 4:22:01 阅读更多 →
蓝桥杯国赛超声波测距机:从单片机原理到嵌入式系统实战

蓝桥杯国赛超声波测距机:从单片机原理到嵌入式系统实战

1. 项目缘起:从赛题到超声波测距机的诞生第八届蓝桥杯单片机设计与开发国赛的题目,我至今记忆犹新。它没有直接给出一个花哨的名字,而是用“超声波测距机”这个朴实无华的功能描述,精准地勾勒出了考核的核心。对于当时备赛的我而言…

2026/9/3 4:22:59 阅读更多 →

月新闻

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能

持续集成 流水线自动化与 声明式交付 实践:原型怎样变成可用功能分类:[AI/大模型]细分主题:AI 增强型 CI/CD 流水线自动化与 GitOps 实践:Agent 工作流、工具调用与任务拆解:从原型到生产的验收清单很多团队在尝试用大…

2026/9/3 4:17:49 阅读更多 →
容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场

容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场

容器编排 生产环境运维与排障实战:复盘记录怎样真正派上用场分类:[工程技术]细分主题:Kubernetes 生产环境运维与排障实战:可复制的项目复盘模板与决策记录大部分团队的事故复盘报告,最后都变成了躺在 Confluence 或钉…

2026/9/3 4:18:56 阅读更多 →
容器 容器化技术与镜像安全管理:核心链路应该先拆哪一步

容器 容器化技术与镜像安全管理:核心链路应该先拆哪一步

容器 容器化技术与镜像安全管理:核心链路应该先拆哪一步分类:[工程技术]细分主题:Docker 容器化技术与镜像安全管理:核心链路的逐步实现与关键代码取舍面对一个积累了五六年历史包袱的单体架构应用(包含 Web 接口、后台…

2026/9/3 4:21:44 阅读更多 →