`ls -lh` can leave `backup.img` halfway down the screen because the names set the order. I’m curious to see how that same directory reads when size calls the shots.
A size-ranked listing points you to an entry to inspect without turning the directory into one disk-usage total. GNU `ls -S` starts by ordering the entries by size.
Sort directory entries by size with ls
GNU ls sorts a directory’s entries by size with -S, putting larger entries first. Add -l to show the size beside each name, and use the full ls command reference when you need its other listing options.
ls -lhS
The -S option sorts by each entry’s file size, while -l supplies the size column and -h makes the values readable. The capture below uses ls -laS, so it includes hidden entries and shows the sizes in bytes.

GNU ls does not combine every file under a directory tree into one global ranking. It sorts the entries in the directory it lists.
Choose which entries and sizes to show
These options change the contents or display of the listing without changing the size-sort task.
| Option | Effect | Use it when |
|---|---|---|
| -l | Shows a long listing with a size column | You need to compare sizes beside file names |
| -h | Displays sizes with readable unit suffixes | Byte counts are hard to scan |
| -a | Includes dot-prefixed names, plus . and .. | Hidden entries belong in the listing |
| -A | Includes dot-prefixed names but omits . and .. | You want hidden files without the two directory markers |
The -a option adds hidden entries, as in this ls -la output. For a fuller explanation of dot-prefixed names, see how to show hidden files in Linux.

Readable suffixes make a listing quicker to scan, but they round the displayed values. This ls -laSh capture shows the same size order with human-readable units.

The -S sort still compares file sizes, not the rounded labels. Different file sizes can both display as 4.0K after rounding.
Reverse the order or limit the listing
Replace size-demo in the examples with the directory you want to inspect. Reverse the size order when the smallest entries matter, or limit the long listing when you only need the largest few names.
List the smallest entries first
Add -r to reverse the size sort. The following command puts smaller entries first.
ls -lhSr
This ls -laShr capture shows the same reverse order while including hidden entries. Its zero-byte entries come before the larger files.

Show only the largest entries
Pipe the largest-first listing to head when you need only its first rows. The total line uses one row, so head -n 4 shows the total plus up to three entries.
ls -lhS size-demo | head -n 4
A directory’s listed size is not its disk usage
In a long ls listing, the size beside a directory describes the directory entry itself, not the combined contents underneath it. Use du when you need a disk-space estimate for files and directories.
du -ah --max-depth=1 size-demo | sort -hr | head -n 6
The -a option includes files, while –max-depth=1 stops at the named directory and its immediate entries. GNU sort’s -h option compares readable units numerically, and -r places larger values first. The du command in Linux reports disk usage, while the sort command handles the ordering step.

For recursive directory totals, see how to list directories by their total size. To search individual files across descendants, use the steps for how to find large files across a directory tree.
| What you need to compare | Command | What the size means |
|---|---|---|
| Entries in one directory | ls -lhS | Each entry’s displayed file or directory-entry size |
| Files and disk use in a directory | du -ah –max-depth=1 | Disk space attributed to files and directory contents at this depth |
| Individual files through a tree | find with a size filter | File-by-file search, rather than one ls listing |
Use the size that answers your question
Use ls when you want to rank entries in one directory. Switch to du when the question is how much space a directory’s contents use.
ls -lhS
Frequently asked questions
Use these distinctions when the basic size sort is not quite the listing you need.
Does ls -S search subdirectories?
No. It sorts the entries in each directory listing and does not produce one combined recursive file list.
Does -h change the sort order?
No. -S compares file sizes, while -h changes how long format displays each size, so rounded labels can match even when exact sizes differ.
![How to Sort Files By Size in Linux? [Command Line]](https://www.linuxfordevices.com/wp-content/uploads/2026/09/sort-files-by-size-terminal-featured-1-1024x576.png)