Fundamentals 3 min read

How to Check File Size in Linux Using ls, du, and stat Commands

This article explains three common Linux commands—ls, du, and stat—for checking file sizes, showing the exact syntax, example usage with a sample file, and how each command displays size information, including human‑readable formats.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
How to Check File Size in Linux Using ls, du, and stat Commands

In Linux you can use several commands to view file size. Below are three commonly used commands.

1. Using ls command

The ls command lists files and directories. To see file size, use the -l option. Example: ls -l filename Replace filename with the target file. For example: ls -l example.txt This displays detailed information including size in bytes.

2. Using du command

The du command estimates directory size; with -h it shows human‑readable sizes for a single file. Example: du -h filename Replace filename with the target file. For example: du -h example.txt This outputs the size in KB, MB, GB, etc.

3. Using stat command

The stat command displays detailed status information, including file size. Example: stat filename Replace filename with the target file. For example: stat example.txt This shows file size in bytes along with other metadata.

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.

LinuxShellcommand-linelsdufile sizestat
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

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.