Skip to content

Linux stat Guide

Mattscreative edited this page Dec 5, 2025 · 3 revisions

Linux stat Guide

Complete beginner-friendly guide to stat on Linux, covering Arch Linux, CachyOS, and other distributions including file statistics, file information, and detailed file metadata.


Table of Contents

  1. stat Basics
  2. File Information
  3. Format Options
  4. Multiple Files
  5. Troubleshooting

stat Basics

File Statistics

Basic usage:

# File statistics
stat file.txt

# Shows detailed file information

Directory Statistics

Directory info:

# Directory statistics
stat directory/

# Shows directory information

File Information

Detailed Output

Complete info:

# Detailed information
stat file.txt

# Shows:
# - Size
# - Blocks
# - IO Block
# - Device
# - Inode
# - Links
# - Access
# - Modify
# - Change times

Follow Links

Follow symlinks:

# Follow symbolic links
stat -L symlink

# -L = follow (shows target file info)

Format Options

Custom Format

Format string:

# Custom format
stat -c "%n %s" file.txt

# -c = format
# %n = filename
# %s = size

Format Specifiers

Common formats:

# %n = filename
# %s = size
# %U = user name
# %G = group name
# %a = access rights (octal)
# %A = access rights (human)

Multiple Files

Multiple Files

Multiple stats:

# Multiple files
stat file1.txt file2.txt

# Shows stats for each file

From Input

Pipe input:

# From input
ls *.txt | xargs stat

# Stats for all .txt files

Troubleshooting

stat Not Found

Check installation:

# stat is part of coreutils
# Usually pre-installed

# Check stat
which stat

Summary

This guide covered stat usage, file statistics, and file information for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally