stat Command: File Times Access, Modify, Change, the -c Format and Checking the File System with -f

Test environmentRHEL familyAlmaLinux 9.8root account
File management commandsstatLocation/usr/bin/stat

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 +0000

The 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 · FieldMeaning
FileName of the file checked. For a symbolic link, the target follows the arrow
SizeFile size (bytes)
BlocksNumber of blocks used on disk (512-byte units)
IO BlockBlock size used for I/O (bytes)
regular file, etc.File type (regular file, directory, symbolic link, etc.)
DeviceNumber of the device the file is on (hex h/decimal d)
InodeNumber that identifies this file within the file system
LinksNumber of hard links
Access (permissions line)Permissions (octal/symbolic)
Uid · GidOwner account and group (number/name)
AccessTime of the last read
ModifyTime the file content changed
ChangeTime the metadata (permissions, owner, etc.) changed
BirthTime 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 +0000

Adding -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 +0000

Given 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.txt
stat: cannot statx 'nofile.txt': No such file or directory
echo $?
1

2️⃣ Checking Times with the stat Command

  • ↪️ When Access, Modify, Change and Birth change

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 4
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 +0000

Reading it once with cat changed only Access, to 07:53:54.

cat report.txt
server=web01
port=8080
stat report.txt | tail -n 4
Access: 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 +0000

Reading it again right away left Access unchanged, because Access was already later than Modify.

cat report.txt
server=web01
port=8080
stat report.txt | tail -n 4
Access: 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 +0000

echo appended one line to the end of report.txt.

echo "user=admin" >> report.txt

Checking 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 4
Access: 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 +0000

With chmod, only the permissions were changed to 600, leaving the content as is.

chmod 600 report.txt

This time only Change changed, because only the metadata, the permissions, changed.

stat report.txt | tail -n 4
Access: 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 +0000

Reading 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.txt
server=web01
port=8080
user=admin
stat report.txt | tail -n 4
Access: 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
ActionTimes changed
Right after creationAll four times the same
First read with catAccess
Second read with catNo change
Content added with echoModify · Change
chmod 600 (permissions only)Change
cat after the content changedAccess

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.txt
report.txt 34 600 -rw------- user user

Given 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.txt
report.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.txt
1793260430 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.txt
report.txt\t34
stat --printf='%n\t%s\n' report.txt notes.txt
report.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.txt
report.txt 34 8 8180 1000 1000 fd01 1048587 1 0 0 1793260442 1793260438 1793260440 1793260430 4096

Frequently used formats are collected in the table.

FormatMeaning
%n · %NFile name · quoted name (with the target for a link)
%s · %bSize (bytes) · block count (512-byte units)
%a · %APermissions (octal) · permissions (symbolic)
%U · %GOwner account name · group name
%u · %gOwner account number · group number
%h · %iHard link count · inode number
%FFile type
%x · %XAccess time · Epoch seconds
%y · %YModify time · Epoch seconds
%z · %ZChange time · Epoch seconds
%w · %WBirth 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: 52301120

Type 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.

ItemDescription
FileName of the file checked
IDFile system ID
NamelenMaximum file name length (usually 255)
TypeFile system type (e.g. xfs, ext2/ext3)
Block sizeBlock size of the file system
Fundamental block sizeBase block size used to count blocks
Blocks: Total / Free / AvailableNumber of blocks: total / free / available to regular users
Inodes: Total / FreeNumber 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 255

The 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

OptionCopyDescription
-LPrints information about the file a symbolic link points to instead of the link
-cFORMATPrints only the values you need, using a format string
--printf=FORMATPrints with escape characters such as tabs or newlines, without a trailing newline
-tPrints only the values on one line, without field names
-fPrints information about the file system that holds the file
OptionCopyDescription
--cached=MODESets how cached attributes are used (always, never, default). Useful on remote file systems
--helpPrint help and exit
--versionPrint 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.

stat Command Simulatorstat · coreutils 8.32
[root@server work]#
Use the ↑↓ keys to recall commands you typed earlier.

5️⃣ Practical stat Command Examples

  • ↪️ Checking permissions, comparing backup times and common beginner mistakes

🔲 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.new
cp -p app.conf backup/app.conf.keep
stat -c '%y %n' app.conf backup/app.conf.new backup/app.conf.keep
2026-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.keep

To find the most recently modified file in a folder, sort %Y with sort -n.

echo 'retry' >> site/logs/app.log
stat -c '%Y %n' site/index.php site/config.php site/logs/app.log | sort -n
1794647412 site/config.php
1794647412 site/index.php
1794647417 site/logs/app.log

After 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.conf
stat: cannot statx '%s': No such file or directory
app.conf
stat -c '%n %s' app.conf
app.conf 23

Because 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.conf
2026-11-14 09:10:12.310266747 +0000 1794647412

Another 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.log
stat old.log | tail -n 4
Access: 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 +0000

Access 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 4
Access: 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 +0000
touch app.conf
stat app.conf | tail -n 4
Access: 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 +0000

Before 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

[ls -l] prints the Modify time. Adding -u prints Access and adding -c prints Change, while stat prints all four times at once, including Birth. For report.txt, the three values matched stat's Modify (07:53:58), Access (07:54:02) and Change (07:54:00).

If the file system does not provide a creation time, Birth shows -, and the manual also says [%w] is - if unknown. Running [stat -c '%w %n' /proc] printed [- /proc]. In that case the creation time cannot be known, so judge by the Modify and Change times.

sparse.img, made with [truncate -s 1M], had a Size of 1048576 bytes but Blocks of 0. This is because sparse.img is a sparse file, in which areas with nothing written do not take up disk blocks. Conversely, report.txt, at 23 bytes, had Blocks of 8 (512 bytes × 8 = 4KiB).

ℹ️ 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.

Leave a Reply

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

Prove your humanity: 3   +   10   =