Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article8 min readViews1

mtime, ctime, and birth time in Linux: what stat shows

One timestamp changes with chmod, another with writing, and birth time may be unknown. We verify this on an isolated file and demonstrate what conclusions cannot be drawn from stat alone.

Comments 0

A man compares a folder to three analog clocks on a desk
In this article

Short answer: in GNU stat, the mtime field shows the time of the last data modification of the file, ctime shows the time of the last state change of inode, and birth shows the file birth time if the file system provides it. ctime does not indicate creation time. One timestamp sets a boundary for the investigation, but by itself it does not identify the user, process, or reason for the change.

For a readable snapshot, separate directives are required: %y for mtime, %z for ctime, and %w for birth time. If the birth time is unknown, %w outputs -. Preserve the time zone and fractional seconds: without them, comparing two snapshots is more difficult.

Capturing fields separately

First, check the utility version and the exact path. Separately determine whether the path is a symbolic link: without --dereference, GNU stat reads the metadata of the link itself, while with --dereference it reads the metadata of its target. The command below, without this parameter, only reads the metadata of the specified object. Substitute an existing file; do not modify its timestamps for an experiment on a production server.

stat --version

stat --printf='name=%n\nmode=%A\nsize=%s\nmtime=%y\nctime=%z\nbirth=%w\n' -- /path/to/file

In the output, timestamp values are not the only important fields. The mode and size fields help clarify exactly what changed, while the full path protects against comparing two files with the same name. For investigating a large directory tree, it is useful to additionally save device and inode, but these are separate fields and a separate question.

Field

What it records

What it does not prove

mtime

Last modification of file data

Which user or process wrote the data and exactly what changed

ctime

Last modification of inode state: for example, permissions, owner, or data

File creation time

birth

File birth time, if the file system stores and serves it

That the file was not copied or restored

atime

Last recorded access to the data

Each read: the update may be delayed or disabled

The semantics of the directives are described in the GNU stat guide. The section GNU File timestamps explains when the timestamps themselves are updated and what limitations apply; Linux definitions are also provided in inode(7). Documentation confirms the meaning of the fields but does not replace verification of a specific operation and file system.

Relying on a single indicator is premature. An old mtime does not guarantee old content: it can be preserved during copying or set separately. A fresh ctime indicates that the state of inode has changed, but does not reveal the initiator. Birth time may be entirely absent.

Isolated test: changing permissions and writing

The check was performed on November 16, 2026, on GNU coreutils 9.7. The script creates a separate directory of the form /tmp/stat-times.XXXXXX, identifies all paths within it, and removes only the directory matching this pattern. Files from the working server are not used. The tested local file system supported file birth time; this result cannot be transferred to NFS or other file systems.

Save the script as stat-times-lab.sh in a separate test directory. To run it, a regular user with write permissions to /tmp is sufficient. Bash, GNU stat, touch, chmod, sleep, cat, and rm are required.

#!/usr/bin/env bash
set -euo pipefail

lab_root="$(mktemp -d /tmp/stat-times.XXXXXX)"
cleanup() {
case "$lab_root" in
/tmp/stat-times.??????) rm -rf -- "$lab_root" ;;
*) printf 'Refusing cleanup outside the lab: %s\n' "$lab_root" >&2 ;;
esac
}
trap cleanup EXIT

target_file="$lab_root/report.txt"
snapshot() {
label="$1"
printf '=== %s ===\n' "$label"
stat --printf='mode=%A\nsize=%s\nmtime=%y\nctime=%z\nbirth=%w\n' -- "$target_file"
}

printf 'alpha\n' >"$target_file"
chmod 0644 -- "$target_file"
touch -d '2026-01-02 03:04:05 UTC' -- "$target_file"
snapshot initial

sleep 1
chmod 0600 -- "$target_file"
snapshot after_chmod

sleep 1
printf 'beta\n' >>"$target_file"
snapshot after_append

printf '%s\n' '=== content ==='
cat -- "$target_file"

First, check the syntax, then run the lab. The trap handler cleans only the created temporary directory; after the actual run, the directory was absent.

bash -n stat-times-lab.sh

TZ=Europe/Moscow bash stat-times-lab.sh

What changed in the three snapshots

The actual run completed with code 0. Below is its full output; times ctime and birth apply only to this run and are not reference values for another machine.

=== initial ===
mode=-rw-r--r--
size=6
mtime=2026-01-02 06:04:05.000000000 +0300
ctime=2026-11-16 05:47:20.449882971 +0300
birth=2026-11-16 05:47:20.444145632 +0300
=== after_chmod ===
mode=-rw-------
size=6
mtime=2026-01-02 06:04:05.000000000 +0300
ctime=2026-11-16 05:47:21.452168087 +0300
birth=2026-11-16 05:47:20.444145632 +0300
=== after_append ===
mode=-rw-------
size=11
mtime=2026-11-16 05:47:22.456190349 +0300
ctime=2026-11-16 05:47:22.456190349 +0300
birth=2026-11-16 05:47:20.444145632 +0300
=== content ===
alpha
beta

In the initial snapshot, mtime is older than birth not because of time travel: the script intentionally set mtime to January 2 using the command touch. This is a separate counterexample to attempts to determine file age based on a single mtime.

Field

initial snapshot

after permission change

after data addition

mode

0644

0600

0600

size

6 B

6 B

11 B

mtime

02.01.2026 06:04:05 +03

no change

05:47:22.456190349 +03

ctime

05:47:20.449882971 +03

05:47:21.452168087 +03

05:47:22.456190349 +03

birth

05:47:20.444145632 +03

no change

without change

After chmod, mode changed and ctime shifted. The size and mtime remained the same: the file data was not rewritten. This is a direct counterexample to reading ctime as "creation time".

After adding the line beta, the size increased from 6 to 11 bytes, and mtime and ctime changed. Birth time remained the same in this file system. The match between mtime and ctime to the nanosecond in the last snapshot is an observation from a specific run, not a guarantee of identical values for any write.

Comparison of permissions, size, and the three file timestamps before and after two operations
0 is the original snapshot; chmod changes permissions; +5 B adds five bytes. m0 and m1 are different mtime values; c0, c1, and c2 are sequential ctime values; b0 is the unchanged birth time. Exact values are provided in the native table.

How to Use Timestamps in an Investigation

  1. Record the exact path and immediately save a metadata snapshot using the stat command without modifying the file; include the time zone and full precision. Do not run touch, chmod, or perform an editor save on the file under investigation.

  2. Formulate the hypothesis before reviewing the logs. Writing data to a file must align with mtime and typically with ctime; changing permissions can shift ctime without mtime.

  3. Correlate the time boundary with independent evidence: the application log, auditd, configuration history, version control system, backups, and checksums.

  4. Verify whether the operation in use preserved mtime. Copying, unpacking, and restoring have their own parameters and do not allow drawing universal conclusions from a single timestamp.

  5. If birth is a dash, record "unknown" rather than substituting it with ctime. If a value exists, separately verify the capabilities of the file system and the tool.

  6. Formulate a conclusion with boundaries: which field changed, between which snapshots, and what external event confirms it. If the author or cause is unknown, state it as unknown.

A timestamp does not verify the contents of a backup or archive. If the source directory is still accessible, use a separate check, such as comparing the tar archive with the source directory before cleanup. Time helps build a chronology, while comparison answers a different question: do the data match?

Method Boundaries

  • Support for birth time depends on the file system, kernel, and tool. A dash in %w is a valid result; it does not indicate an error in the stat command.

  • Timestamp accuracy varies. Rounding in a report can make two distinct events appear identical, so the original output should be preserved in full.

  • atime may be updated lazily due to relatime, noatime, and other parameters. In this lab, atime was not verified.

  • On NFS and other network file systems, the clocks of different nodes, caching, and the server implementation are critical. A local test does not confirm this.

  • mtime and ctime do not contain a user, PID, or operation text. Attribution requires pre-configured logs and audit trails.

  • Copying, unpacking, and restoring can create a new inode while preserving individual timestamps. Verify the actual command and its parameters.

Result Criteria

An investigation can be considered complete when every statement is linked to a specific field and independent confirmation. "Data changed" requires mtime and verification of content or logs; "permissions changed" requires ctime, mode, and evidence of the operation; "file created at that time" requires an available birth time and understanding of the file's origin. If no confirmation exists, the correct conclusion is a time boundary and an honest "cause unknown".

In the lab, the hypotheses matched the observation: chmod changed ctime without mtime, and adding data changed both fields. On the production server, repeating a change just to achieve a neat match is not allowed — first save the state, then check the logs and data. A calm chronology is usually more useful than a single, highly confident date.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.