Bash ’ls’: How -lah Unlocks Your File System After pwd told us where we are, ls tells us what’s there. This is Day 5 of the 1-Month Bash Mastery Plan.


👋 Hey everyone,

Yesterday, we found our anchor. We used pwd to answer the terrifying, existential question of the terminal: “Where am I?” We went from feeling lost in an abstract void to having a “You Are Here” sign. We’re “standing” in /home/murat.

But that’s only half the battle. Now I’m standing in a room… and the lights are off.

I know I’m in my home directory, but what’s in here with me? Are there files? Are there other directories (rooms)? Can I even do anything with them?

This is the second, and more common, state of “terminal-blindness.” pwd is the GPS, but ls is the light switch. And for years, I was just flicking it on to the dimmest possible setting, still stumbling around in the dark. I would type ls, see a few names, and move on, completely ignorant of the rich, vital information all around me.

Today, we’re not just turning on the light. We’re installing floodlights. We’re going to break down the ls command, move from its basic form to the “god-mode” combination that every single sysadmin, developer, and security analyst types dozens of times a day: ls -lah.


My Goal This Week 🎯

My goal for this post is to take you from listing files to understanding them. The ls command is the second pillar of our “navigational triad” (pwd, ls, cd). pwd gives you your location, ls shows you the contents of that location, and cd (which we’ll cover next) lets you move.

By the end of this, you won’t just know what -l, -a, and -h do. You’ll understand why they are so essential, how to read the “alien text” that ls -l produces, and why ls -lah is the single most powerful command for “seeing” your file system.


The Process & The Code 👨‍💻

Let’s start our journey from darkness to light. Open your terminal. You should be in your home directory (if not, just type cd and press Enter, then pwd to confirm).

1. The Basic ls: The Dim Light

Let’s just type the command and see what happens.

ls

The output is… underwhelming. Desktop Documents Downloads Music Pictures Projects Public Templates Videos

This is fine, I guess. It tells me the names of the directories in my home folder. But that’s it. What are they? I’m assuming they’re directories, but ls doesn’t tell me that. What if Projects was a giant 50GB video file? I’d have no idea.

This is the default, and it’s almost useless. We can do better.

2. ls -l: The “Long” Format (Turning on the Overhead Light)

This is the first major “level-up.” The -l flag stands for “long listing format.” Let’s try it.

ls -l

Suddenly, our terminal is flooded with information:

total 32
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Desktop
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Documents
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Downloads
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Music
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Pictures
drwxr-xr-x 5 murat murat 4096 Nov 11 10:20 Projects
drwxr-xr-x 2 murat murat 4096 Nov 10 13:01 Public
-rw-r--r-- 1 murat murat  890 Nov 11 11:30 my-notes.txt

Whoa. This is the “alien text” I mentioned. This is what scares people away. But let’s break it down, column by column, because this is the whole game.

Let’s use that last line as our example: -rw-r--r-- 1 murat murat 890 Nov 11 11:30 my-notes.txt

  1. -rw-r--r-- (Permissions): This is the most important part.

    • The first character (-): This tells you the file type.
      • - means it’s a regular file.
      • d (like in drwxr-xr-x) means it’s a directory.
      • l means it’s a symlink (a shortcut).
    • The next nine characters (rw-r--r--) are the permissions, broken into three sets of three:
      • rw- (Owner): The Owner (murat) can Read and Write.
      • r-- (Group): The Group (murat) can only Read.
      • r-- (Others): Everyone else can only Read. (Don’t worry, we’ll have a whole week on permissions later. For now, just know this is what “read, write, execute” means.)
  2. 1 (Link Count): The number of “hard links” to this file. For directories, it’s the number of items inside it. You can mostly ignore this for now.

  3. murat (Owner): The user who owns this file.

  4. murat (Group): The group that owns this file.

  5. 890 (Size): The size of the file… in bytes. This is our next problem. 890 is easy. What if it was 548394857? Is that 500MB? 5GB? 50MB? I have no idea. This is not for humans.

  6. Nov 11 11:30 (Timestamp): The last modified time. Incredibly useful.

  7. my-notes.txt (Filename): The name of the file.

Just by using -l, we now know what’s a file, what’s a directory, who owns it, how big it is (sort of), and when it was last touched. This is a massive improvement. But we can fix that ugly size column.

3. ls -lh: The “Human-Readable” Fix

The -h flag stands for “human-readable.” It has one job: to be used with -l to make the file sizes make sense.

ls -lh

Now look at that same output:

total 32K
drwxr-xr-x 2 murat murat 4.0K Nov 10 13:01 Desktop
drwxr-xr-x 2 murat murat 4.0K Nov 10 13:01 Documents
...
drwxr-xr-x 5 murat murat 4.0K Nov 11 10:20 Projects
-rw-r--r-- 1 murat murat  890 Nov 11 11:30 my-notes.txt

4096 instantly becomes 4.0K. 890 stays 890 (since it’s less than a kilobyte). If I had a giant ISO file, 548394857 would now read 523M (for 523 Megabytes).

This is usable. ls -lh is my default “look” command. But… I still feel like I’m missing something. Where are all my configuration files?

4. ls -a: The “X-Ray Goggles”

In the Linux/Unix world, there’s a simple convention: if you want to “hide” a file from a normal ls, just put a dot (.) at the beginning of its name.

This isn’t “security.” It’s just a way to de-clutter your directory. These “dotfiles” are used to store configuration. Think .bashrc, .gitconfig, .vimrc. Your home directory is full of them.

The -a flag stands for “all.” It tells ls to not ignore any file starting with a dot.

ls -a

Suddenly… a FLOOD of files.

.              .bash_history  .config      .local     Public
..             .bash_logout   Desktop      Music      Templates
.bash_profile  .bashrc        Documents    .mozilla   Videos
.cache         .gitconfig     Downloads    Pictures   .zshrc

Look at all that! My .bashrc! My .gitconfig! All my settings! They were here all along, just hidden for my convenience.

You’ll also see two special entries:

  • . (dot): A shortcut that means “this current directory.”
  • .. (dot-dot): A shortcut that means “the parent directory (one level up).” (These are super important, and we’ll use them with cd tomorrow.)

5. ls -lah: The “God Mode” Combination

Now we put it all together. We want a long list, we want to see all (hidden) files, and we want human-readable sizes. The flags can be combined.

ls -lah

The output is… perfect. It’s everything.

total 128K
drwxr-xr-x 15 murat murat 4.0K Nov 11 11:35 .
drwxr-xr-x  3 root  root  4.0K Oct 29 08:15 ..
-rw-------  1 murat murat 5.2K Nov 11 09:45 .bash_history
-rw-r--r--  1 murat murat  220 Oct 29 08:15 .bash_logout
-rw-r--r--  1 murat murat 3.7K Oct 29 08:15 .bash_profile
-rw-r--r--  1 murat murat  807 Oct 29 08:15 .bashrc
drwx------  5 murat murat 4.0K Nov 10 14:20 .cache
drwx------  8 murat murat 4.0K Nov 10 14:22 .config
drwxr-xr-x  2 murat murat 4.0K Nov 10 13:01 Desktop
...
-rw-r--r--  1 murat murat  890 Nov 11 11:30 my-notes.txt
drwxr-xr-x  5 murat murat 4.0K Nov 11 10:20 Projects
-rw-r--r--  1 murat murat  66K Nov  5 17:00 .zshrc

This single command gives me a complete, readable, x-ray vision of my entire current directory. I can see hidden files, I know what’s a file vs. a directory, I know the permissions, I know the size, and I know when it was last touched.

This is the command I, and millions of others, type hundreds of times a day. It is the light switch.


Hitting The Wall 🧱

My “wall” with ls was two-fold and deeply embarrassing.

The first was the “hidden file” problem. I would git clone a repository. I’d cd into the new folder, type ls, and see… README.md and a src folder. I’d think, “Where is the git stuff? How does it know this is a git repo? There’s no git file!” I felt like it was magic. I had no idea there was a hidden .git directory in there that contained the entire repository database. I only found out when I accidentally typed ls -a (I think I was trying to type ls -l and missed) and this .git folder popped up. I felt like I had found a secret room.

The second, and much bigger, wall was the permissions. That drwxr-xr-x string. I ignored it. For at least a year. It was just noise, and I trained my eyes to skip it and just look at the filename.

This burned me, badly. I was trying to run a script someone had sent me. Let’s call it do-thing.sh. I’d type ./do-thing.sh Output: Permission denied

I was furious. “What do you mean, ‘permission denied’?! I own the file! ls -l says murat murat! It’s my file!” I must have tried for 30 minutes. I tried sudo ./do-thing.sh. Don’t do that. It’s a terrible habit. Finally, I asked a senior dev, who just glanced at my screen.

He said, “You told me you own it. Can you run it?” I said, “What?” He said, “Read the permissions.” I looked at the ls -l output: -rw-r--r-- 1 murat murat 120 Nov 11 11:50 do-thing.sh I said, “See? rw-r--r--…” He said, “Exactly. Read. Write. Where’s ‘x’?”

…oh.

x stands for eXecute.


The Breakthrough Moment ✨

The “Aha!” moment was when the x was missing. The dev had me run one command: chmod +x do-thing.sh (we’ll cover chmod later, but it adds the ‘x’ permission).

I ran ls -lh again. Now the output was: -rwx-r--r-- 1 murat murat 120 Nov 11 11:50 do-thing.sh (And it usually turns green!)

I ran ./do-thing.sh. It worked.

That was the click. The ls -l output wasn’t “noise.” It wasn’t “for nerds.” It was the instruction manual for the files. It was telling me exactly what I was allowed to do with them. I just had to learn to read it.

From that day on, ls -lah became my default. I aliased it in my .bashrc so that when I type l, it runs ls -lah. It’s my “turn on the lights and show me the manual” command, and I can’t live without it.


This is going to be a broken record, but it’s the honest truth: “The Linux Command Line: A Complete Introduction” by William Shotts.

If my post was the quick “Aha!” moment on permissions, this book is the full university course. Shotts has multiple chapters dedicated to navigating the file system and especially to “Permissions.” He patiently explains everything I just covered: what r, w, and x mean for both files (Read, Write, Execute) and directories (List, Add/Remove, Enter). He’s the one who taught me what that drwxr-xr-x really means. If you want to go from “guessing” to “knowing,” this is the book. Amazon


Key Takeaways 📚

  1. 💡 ls is your light switch. pwd tells you what room you’re in; ls tells you what’s in that room.
  2. ⚙️ ls -l is the “Long” list. It’s your instruction manual. You must learn to read the 7 columns, especially the d (directory) or - (file) and the rwx (permissions).
  3. 📚 ls -a is your “X-Ray.” It shows “All” files, including the hidden dotfiles (.bashrc, .git) that control your entire environment.
  4. ls -lah is your new default. It combines them all: long format, all files, human-readable sizes. This one command gives you a complete, readable, actionable understanding of your directory. Start using it. Now.

Thanks for Following ☕

☕ If you found this guide helpful, you can Buy Me a Coffee! Medium Etsy LinkedIn Read More

What’s your most-used ls flag (besides -lah)? And what’s the most suprising or “secret” hidden file you’ve ever discovered in a directory?