AI Hints
Home›Linux Tutorial›ls Options
Linux · Lesson 19 of 120

ls Options

Long, all, and human sizes.

⏱ 2 min read▶ Video at 22:02🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Plain LS only shows names. But LS can tell you much more, if you ask with options. Options are letters after a dash, that change how a command behaves.

ls Options
From the video: ls Options
  • Plain ls: names only
  • Options add detail
  • A dash, then a letter

The long listing

Dash L, a lowercase L, asks for the long listing. Now each item gets a whole line, with its permissions, its owner, its size, and the date it was last changed. We'll decode every column in a moment.

Terminal
ls -l
total 24
drwxr-xr-x 2 sam sam 4096 Jan  5 09:00 Documents
drwxr-xr-x 2 sam sam 4096 Jan  5 09:00 Downloads
drwxr-xr-x 2 sam sam 4096 Jan  5 09:00 Music
drwxr-xr-x 2 sam sam 4096 Jan  5 09:00 Pictures
-rw-r--r-- 1 sam sam   30 Jan  5 09:00 notes.txt
-rw-r--r-- 1 sam sam   58 Jan  5 09:00 todo.txt

Human readable sizes

Sizes in the long listing are in bytes, which gets hard to read for big files. Add dash H, for human readable. Now LS shows sizes like twenty four K, meaning about twenty four kilobytes. Here we look inside Pictures.

Terminal
ls -l Pictures
total 56
-rw-r--r-- 1 sam sam 24000 Jan  5 09:00 beach.jpg
-rw-r--r-- 1 sam sam 31000 Jan  5 09:00 party.jpg
ls -lh Pictures
total 56K
-rw-r--r-- 1 sam sam 24K Jan  5 09:00 beach.jpg
-rw-r--r-- 1 sam sam 31K Jan  5 09:00 party.jpg

Combining options

You can combine options. LS dash L, and LS dash H, can be written together as LS dash LH. The order of the letters doesn't matter. Three options you'll use all the time are, L for long, A for all, and H for human sizes. And capital S sorts by size, while T sorts by time.

keyvalue
-llong listing
-aall, even hidden
-hhuman sizes
-S / -tsort by size / time

Summary

Dash L gives the long listing, dash H shows friendly sizes, and you can combine them, like dash LH. Next, files that LS hides from you.

Key takeaways
  • ls -l
  • ls -lh
  • Combine letters
Next up: Hidden Files — names that start with a dot