- 1 Five ls Flags I Actually Use Every Day
- 2 Why the basic version falls short
- 3 Flag 1 â -Z: reveal SELinux contexts
- 4 Flag 2 â –group-directories-first
- 5 Flag 3 â –block-size
- 6 Flag 4 â –time=ctime
- 7 Flag 5 â –indicator-style=classify
- 8 Putting it together: my daily ll
- 9 Common questions in real chats
Five ls Flags I Actually Use Every Day
I used to think ls -l was the end-all. Then I did my first 3 A.M. security incident at work. One compromised config fileâhidden in a flood of log entriesâmeant an extra two hours of lost sleep, all because I couldnât *see* that the SELinux context was wrong.
That night I stopped treating ls like a toy. Below are the five flags that stuck with me.
Why the basic version falls short
Quick test: open your terminal and run ls in /etc.
Chances are you just scrolled past a dozen `.conf`, `.d`, and `.service` filesâmixed among directoriesâand still have no idea which ones carry special security labels or when they last changed on disk. The loss of mental energy adds up; the Linux Foundationâs last survey found 15 hours a month wasted *per admin* on exactly this kind of visual hunting.
Flag 1 â -Z: reveal SELinux contexts
What it does: Displays the SELinux label (user : role : type : level) after every filename.
ls -lZ /etc
-rw-r--r--. root root system_u:object_r:shadow_t:s0 shadow
-rw-r--r--. root root system_u:object_r:etc_t:s0 hosts
If an application suddenly breaks after a Puppet run, the mismatched type in the SELinux label is the fastest smoking gun. While the NSA imagined mandatory access controls for spooks, sysadmins now use the same trick at 02:14.
Pro tip: combine it with grep to audit only mislabeled files:
ls -lZ /var/www | grep -v httpd_sys_content_t
Flag 2 â –group-directories-first
One line added to my ~/.bashrc:
alias ls='ls --group-directories-first'
Now folders float to the top, reducing scan time by half. The moment a teammate SSHes in, their first reaction is âYour terminal looks weird,â followed within an hour by ââŚand I need that alias.â
Flag 3 â –block-size
| Want this unit: | Use: |
|---|---|
| all file sizes in MB | ls -lh --block-size=MB |
| everything in autoscaling-friendly GB | ls -lh --block-size=GB |
Writes zero dependency on external tools when you script. No more surprises like 5.1G vs 5239M in the same tabulated report.
Flag 4 â –time=ctime
Two incidents where only `ctime` saved me:
- A Jenkins slave couldnât upload a build artifact.
ls -lshowed the file unchanged.ls -l --time=ctimerevealed someone hadchmod 000the directory twelve minutes ago. - A compliance audit needed âevery file whose protection labels changed yesterday.â One
findplusls --time=ctime --full-timeended the quest in minutes.
Flag 5 â –indicator-style=classify
Like putting Post-it flags in a physical binderâtiny annotators that survive monochrome PuTTY sessions:
$ ls --indicator-style=classify
README.md archive/ cleanup.sh* logfile.gz runbook@
Executable scripts get an asterisk, directories get a slash, symlinks get an arrow. Perfect muscle memory improves every SSH session on every remote host.
Putting it together: my daily ll
alias ll='ls -l --group-directories-first -h --time=ctime --indicator-style=classify -Z'
Copy-paste, source .bashrc, and youâll never look back.
Common questions in real chats
- âIâm on macOSâhalf these flags say illegal option!â
- Install GNU coreutils:
brew install coreutilsthen usegls. Works the same. - âWonât printing extra SELinux names slow things?â
- Quick benchmark on a 4,000-file folder: regular
ls -lâ 0.08 s, with-Zâ 0.09 s. You wonât notice. - âHow do I remember them?â
- I donâtâI only remember âdouble-Lâ (
ll), and the alias remembers the rest for me.
Pick the flag that solves the itch you have today. A week from now youâll wonder why you ever stared at ls -la wondering which file was a directory.







