stat Command: File Times Access, Modify, Change, the -c Format and Checking the File System with -f
The Linux stat command prints the status of a file or file system. It is used when you need detailed information about a file. Reading a test file twice in a row on an AlmaLinux 9.8 server and then changing its content and permissions one after another, checking each step with stat, showed that even after two reads, the Access time changed only the first time, and changing the permissions changed only the Change time.
The output below was produced on an AlmaLinux 9.8 server under the root account with a test file. The inode numbers, device numbers, owner account and group, file system ID, block counts and inode counts are example values.
1️⃣ How to Use the Linux stat Command and Read Its Output
The basic form is [stat options file]. Given only a file name, it prints the size, permissions, owner account and all four times at once.
stat report.txt File: report.txt
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 1048587 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ user) Gid: ( 1000/ user)
Access: 2026-10-29 07:53:50.226365456 +0000
Modify: 2026-10-29 07:53:50.226365456 +0000
Change: 2026-10-29 07:53:50.226365456 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000The first line is the file name, and the second and third lines show the size and block count, file type, device and inode number, and hard link count. The fourth line shows the permissions and owner account, and the four lines below it are the times. The meaning of each line is shown in the table below.
| Line · Field | Meaning |
|---|---|
| File | Name of the file checked. For a symbolic link, the target follows the arrow |
| Size | File size (bytes) |
| Blocks | Number of blocks used on disk (512-byte units) |
| IO Block | Block size used for I/O (bytes) |
| regular file, etc. | File type (regular file, directory, symbolic link, etc.) |
| Device | Number of the device the file is on (hex h/decimal d) |
| Inode | Number that identifies this file within the file system |
| Links | Number of hard links |
| Access (permissions line) | Permissions (octal/symbolic) |
| Uid · Gid | Owner account and group (number/name) |
| Access | Time of the last read |
| Modify | Time the file content changed |
| Change | Time the metadata (permissions, owner, etc.) changed |
| Birth | Time the file was created |
Run on a symbolic link, it shows information about the link itself. The target appeared after the arrow on the File line, and the size was 10 bytes, the length of the target name report.txt.
stat link.txt File: link.txt -> report.txt
Size: 10 Blocks: 0 IO Block: 4096 symbolic link
Device: fd01h/64769d Inode: 1048589 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ user) Gid: ( 1000/ user)
Access: 2026-10-29 07:53:50.229365476 +0000
Modify: 2026-10-29 07:53:50.229365476 +0000
Change: 2026-10-29 07:53:50.229365476 +0000
Birth: 2026-10-29 07:53:50.229365476 +0000Adding -L showed the information of report.txt, the file the link points to, and the Inode number was also the same as report.txt.
stat -L link.txt File: link.txt
Size: 23 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 1048587 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ user) Gid: ( 1000/ user)
Access: 2026-10-29 07:53:50.226365456 +0000
Modify: 2026-10-29 07:53:50.226365456 +0000
Change: 2026-10-29 07:53:50.226365456 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000Given a file that does not exist, it printed an error message and ended with exit code 1. The statx in the error message is the name of the Linux system call that reads file information.
stat nofile.txtstat: cannot statx 'nofile.txt': No such file or directoryecho $?12️⃣ Checking Times with the stat Command
It is easy to assume that Access changes every time a file is read, but with relatime, the Linux kernel's default mount option, Access is updated only when it is equal to or earlier than Modify or Change, or when a day has passed since it was recorded. Right after the test file was created, all four times were the same.
stat report.txt | tail -n 4Access: 2026-10-29 07:53:50.226365456 +0000
Modify: 2026-10-29 07:53:50.226365456 +0000
Change: 2026-10-29 07:53:50.226365456 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000Reading it once with cat changed only Access, to 07:53:54.
cat report.txtserver=web01
port=8080stat report.txt | tail -n 4Access: 2026-10-29 07:53:54.244391040 +0000
Modify: 2026-10-29 07:53:50.226365456 +0000
Change: 2026-10-29 07:53:50.226365456 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000Reading it again right away left Access unchanged, because Access was already later than Modify.
cat report.txtserver=web01
port=8080stat report.txt | tail -n 4Access: 2026-10-29 07:53:54.244391040 +0000
Modify: 2026-10-29 07:53:50.226365456 +0000
Change: 2026-10-29 07:53:50.226365456 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000echo appended one line to the end of report.txt.
echo "user=admin" >> report.txtChecking again showed that Modify and Change had changed to the same time. Changing the content also changes metadata such as the size, so Change is recorded as well.
stat report.txt | tail -n 4Access: 2026-10-29 07:53:54.244391040 +0000
Modify: 2026-10-29 07:53:58.253416566 +0000
Change: 2026-10-29 07:53:58.253416566 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000With chmod, only the permissions were changed to 600, leaving the content as is.
chmod 600 report.txtThis time only Change changed, because only the metadata, the permissions, changed.
stat report.txt | tail -n 4Access: 2026-10-29 07:53:54.244391040 +0000
Modify: 2026-10-29 07:53:58.253416566 +0000
Change: 2026-10-29 07:54:00.257429322 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000Reading it again after the content changed updated Access to 07:54:02, while Birth stayed the same from start to finish. The table below sums up which times changed at each step.
cat report.txtserver=web01
port=8080
user=adminstat report.txt | tail -n 4Access: 2026-10-29 07:54:02.261442076 +0000
Modify: 2026-10-29 07:53:58.253416566 +0000
Change: 2026-10-29 07:54:00.257429322 +0000
Birth: 2026-10-29 07:53:50.226365456 +0000| Action | Times changed |
|---|---|
| Right after creation | All four times the same |
| First read with cat | Access |
| Second read with cat | No change |
| Content added with echo | Modify · Change |
| chmod 600 (permissions only) | Change |
| cat after the content changed | Access |
3️⃣ Setting the Output Format with stat -c
To print only the values a script needs, give a format string after -c. %n is the file name, %s the size in bytes, %a and %A the permissions in base 8 and in symbols, and %U and %G the owner account and group.
stat -c '%n %s %a %A %U %G' report.txtreport.txt 34 600 -rw------- user userGiven several files, it prints one line per file. %h is the number of hard links and %F the file type.
stat -c '%n %h %F' report.txt logs link.txtreport.txt 1 regular file
logs 2 directory
link.txt 1 symbolic link%F prints only the type recorded in the inode, so the format inside the file, such as whether it is text or an image, is checked with the file command.
The uppercase %X, %Y, %Z and %W print times as seconds counted from January 1, 1970 (Epoch). Because they are in seconds, the difference between two times takes a single subtraction; for this file, Access (1793260442) was 12 seconds later than Birth (1793260430).
stat -c '%W %X %Y %Z' report.txt1793260430 1793260442 1793260438 1793260440-c appends a newline after each format and prints escape characters literally. To insert tabs or newlines, use --printf. --printf does not append a newline at the end, so write [\n] in the format yourself.
stat -c '%n\t%s' report.txtreport.txt\t34stat --printf='%n\t%s\n' report.txt notes.txtreport.txt 34
notes.txt 16-t prints only the values on one line, without field names. The fourth value, 8180, is the file type and permissions combined as a hexadecimal number (%f), meaning a regular file with permissions 600.
stat -t report.txtreport.txt 34 8 8180 1000 1000 fd01 1048587 1 0 0 1793260442 1793260438 1793260440 1793260430 4096Frequently used formats are collected in the table.
| Format | Meaning |
|---|---|
| %n · %N | File name · quoted name (with the target for a link) |
| %s · %b | Size (bytes) · block count (512-byte units) |
| %a · %A | Permissions (octal) · permissions (symbolic) |
| %U · %G | Owner account name · group name |
| %u · %g | Owner account number · group number |
| %h · %i | Hard link count · inode number |
| %F | File type |
| %x · %X | Access time · Epoch seconds |
| %y · %Y | Modify time · Epoch seconds |
| %z · %Z | Change time · Epoch seconds |
| %w · %W | Birth time (- if unknown) · Epoch seconds (0 if unknown) |
4️⃣ Checking the File System with stat -f
When you need information about the file system that holds a file rather than about the file itself, add -f. Giving the current folder (.) prints information about the file system where that folder is.
stat -f . File: "."
ID: fd0100000000 Namelen: 255 Type: xfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 26214400 Free: 18874368 Available: 18874368
Inodes: Total: 52428800 Free: 52301120Type was xfs and the maximum file name length (Namelen) was 255. The Blocks line gives, in 4096-byte blocks, the total (Total), free blocks (Free) and blocks available to regular users (Available). On this xfs, Free and Available were the same.
| Item | Description |
|---|---|
| File | Name of the file checked |
| ID | File system ID |
| Namelen | Maximum file name length (usually 255) |
| Type | File system type (e.g. xfs, ext2/ext3) |
| Block size | Block size of the file system |
| Fundamental block size | Base block size used to count blocks |
| Blocks: Total / Free / Available | Number of blocks: total / free / available to regular users |
| Inodes: Total / Free | Number of inodes: total / remaining |
-f also accepts a format given with -c. %T is the type, %S the block size and %l the maximum name length. For block counts, %b is the total, %f the free and %a the available blocks; for inode counts, %c is the total and %d the remaining number.
stat -f -c '%T %S %b %f %a %c %d %l' .xfs 4096 26214400 18874368 18874368 52428800 52301120 255The usable capacity is the number of Available blocks multiplied by the block size. With the example values, 18874368 × 4096 bytes is 72GiB.
The root file system on the Debian 12 test server is ext4, but the Type from stat -f came out as ext2/ext3, a single name that groups ext2, ext3 and ext4. For block counts, Available was 2787349, less than Free at 3058498. The ext family keeps some blocks reserved for the root account, so regular users can use less.
stat -f -c "%T %S %b %f %a %c %d" /ext2/ext3 4096 6006478 3058498 2787349 6285088 6096388🔲 stat Command Options
| Option | Copy | Description |
|---|---|---|
| -L | Prints information about the file a symbolic link points to instead of the link | |
| -cFORMAT | Prints only the values you need, using a format string | |
| --printf=FORMAT | Prints with escape characters such as tabs or newlines, without a trailing newline | |
| -t | Prints only the values on one line, without field names | |
| -f | Prints information about the file system that holds the file |
| Option | Copy | Description |
|---|---|---|
| --cached=MODE | Sets how cached attributes are used (always, never, default). Useful on remote file systems | |
| --help | Print help and exit | |
| --version | Print version information and exit |
🔲 stat Command Simulator
The simulator below computes stat output using the same test file. The virtual clock advances by about 2 seconds each time you run a command line, so running cat, echo and chmod in turn lets you see the order in which the times change.
5️⃣ Practical stat Command Examples
🔲 Checking Permissions and Comparing Backup Times
A single -c format checks the permissions and owner account of several deployed files at once. Running [stat -c '%a %U:%G %n' deploy.sh site/*] printed one line per file, making it easy to spot config.php, which should have permissions 600, and deploy.sh, which needs execute permission.
stat -c '%a %U:%G %n' deploy.sh site/*755 root:root deploy.sh
600 root:root site/config.php
644 root:root site/index.php
755 root:root site/logs%y also lets you compare whether a backup made before editing a configuration file kept the original's modification time. Copying app.conf with cp and with cp -p showed that app.conf.new, made with cp, had a Modify time of 09:10:15, the time of the copy, while app.conf.keep, made with cp -p, had 09:10:12, the same as the original.
cp app.conf backup/app.conf.newcp -p app.conf backup/app.conf.keepstat -c '%y %n' app.conf backup/app.conf.new backup/app.conf.keep2026-11-14 09:10:12.310266747 +0000 app.conf
2026-11-14 09:10:15.730260811 +0000 backup/app.conf.new
2026-11-14 09:10:12.310266747 +0000 backup/app.conf.keepTo find the most recently modified file in a folder, sort %Y with sort -n.
echo 'retry' >> site/logs/app.logstat -c '%Y %n' site/index.php site/config.php site/logs/app.log | sort -n1794647412 site/config.php
1794647412 site/index.php
1794647417 site/logs/app.logAfter adding a line to app.log and running it, app.log, with the largest Epoch seconds, appeared on the last line.
🔲 Common Beginner Mistakes
If you leave out the quotes around the format string, the format after the space is treated as a file name. Running [stat -c %n %s app.conf] first printed an error saying there is no file named %s, then printed only the name of app.conf, and the exit code was 1. With the format in quotes, the name and size came out on one line.
stat -c %n %s app.confstat: cannot statx '%s': No such file or directory
app.confstat -c '%n %s' app.confapp.conf 23Because they differ by a single upper/lowercase letter, %y and %Y are easy to mix up. Both print the same Modify time in different forms. Specifying both together printed %y as a date and time and %Y as Epoch seconds, 1794647412. Use %Y to compare times in scripts and %y when people read them.
stat -c '%y %Y' app.conf2026-11-14 09:10:12.310266747 +0000 1794647412Another mistake is judging when a file was created from the Modify time alone. touch -d was used to create a new file, old.log, with Access and Modify set to January 1, 2026.
touch -d '2026-01-01 00:00:00' old.logstat old.log | tail -n 4Access: 2026-01-01 00:00:00.000000000 +0000
Modify: 2026-01-01 00:00:00.000000000 +0000
Change: 2026-11-14 09:10:18.502256000 +0000
Birth: 2026-11-14 09:10:18.501256002 +0000Access and Modify were January 1, but Change and Birth were November 14, the day the file was created.
🔲 Reading the Results of stat
touch updated the times of app.conf, and the four time lines were printed before and after the update to compare which lines changed.
stat app.conf | tail -n 4Access: 2026-11-14 09:10:15.730260811 +0000
Modify: 2026-11-14 09:10:12.310266747 +0000
Change: 2026-11-14 09:10:12.310266747 +0000
Birth: 2026-11-14 09:10:12.310266747 +0000touch app.confstat app.conf | tail -n 4Access: 2026-11-14 09:10:20.808251998 +0000
Modify: 2026-11-14 09:10:20.808251998 +0000
Change: 2026-11-14 09:10:20.808251998 +0000
Birth: 2026-11-14 09:10:12.310266747 +0000Before touch, only Access was later than Modify, at 09:10:15, which is the time cp read app.conf in the backup example above. After touch, the three lines Access, Modify and Change all changed to the same 09:10:20, and only the Birth line stayed at 09:10:12.
Since Birth stayed the same, this confirmed that only the times of the same file were updated.
You can type cat, echo and chmod yourself to see the order in which the times change in the stat Command Simulator.
🔢 FAQ & Recommended Content
Linux · Files
Linux ls Command
How to use the ls command to list files and directories along with their file type, size and date.
Linux · Disk
df Command: Check Disk Usage with -h, -T, and -i Options
The df command shows the total, used and free space of mounted devices.
Linux · Files
Linux find Command: The -name, -type, -size, -mtime Options and -delete
How to use the find command to search for files by criteria such as name, size and modification time.
ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.