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.
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 filenameReplace filename with the target file. For example:
ls -l example.txtThis 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 filenameReplace filename with the target file. For example:
du -h example.txtThis outputs the size in KB, MB, GB, etc.
3. Using stat command
The stat command displays detailed status information, including file size. Example:
stat filenameReplace filename with the target file. For example:
stat example.txtThis shows file size in bytes along with other metadata.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.