Operations 3 min read

Mastering Linux stat: Inspect File Details and Filesystem Information

This guide explains the Linux stat command, its syntax and options, and provides step‑by‑step examples showing how to display detailed file metadata and filesystem information, with clear explanations of each output field.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Mastering Linux stat: Inspect File Details and Filesystem Information

Overview

The stat command in Linux displays detailed information about a file or directory, including size, permissions, timestamps, and the underlying filesystem.

Syntax

Basic usage:

stat [options] filename_or_directory

Common Options

-f

: Show information about the filesystem containing the file instead of the file itself.

Example 1 – View File Details

Command: stat demo.txt Sample output (illustrated below) and explanation:

File: the name of the file ( demo.txt).

Size: file size in bytes (e.g., 665).

Blocks: number of allocated blocks (e.g., 8).

IO Block: preferred I/O block size (e.g., 4096).

Device: device identifier (e.g., fc01h/64513d).

Inode: inode number (e.g., 1051650).

Links: number of hard links (e.g., 1).

Access: permission bits (e.g., 0664), owner UID and GID (e.g., 508).

Access time: last read timestamp.

Modify time: last content modification timestamp.

Change time: last status change timestamp.

stat command output example 1
stat command output example 1

Example 2 – View Filesystem Information

Using the -f option shows details about the filesystem that holds the file rather than the file itself: stat -f demo.txt The output includes filesystem type, block size, total/available blocks, and more, as illustrated below.

stat command output example 2
stat command output example 2

These examples demonstrate how stat can be used for troubleshooting, auditing file attributes, and gathering filesystem statistics.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxcommand-linestat commandfile metadatafilesystem information
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.