Lesson 2.1

Listing Like a Pro

7 minutes

You already know ls shows you what’s in a directory. But the basic ls only tells you file names. The real power is in the flags you add to it.

ls -l — The Long Format

Try it now: Type cd ~/projects/my-app then ls -l

You’ll see output that looks something like this:

drwxr-xr-x  2 user user  4096 Jan 15 10:30 src
-rw-r--r--  1 user user   512 Jan 15 10:30 README.md
-rw-r--r--  1 user user  1024 Jan 15 10:30 package.json

Each column tells you something specific:

Column Example Meaning
1 drwxr-xr-x File type and permissions
2 2 Number of links
3 user Owner
4 user Group
5 4096 Size in bytes
6-7 Jan 15 10:30 Last modified date
8 src File or directory name

Reading the Permission String

That first column looks intimidating, but it breaks down simply:

d rwx r-x r-x
│ │   │   │
│ │   │   └── Everyone else: read + execute
│ │   └────── Group: read + execute
│ └────────── Owner: read + write + execute
└──────────── Type: d = directory, - = regular file
  • r = read (can view the contents)
  • w = write (can modify)
  • x = execute (can run it, or enter a directory)
  • - = that permission is not granted
Why Permissions Matter for Vibe Coders
When your AI tool creates a script and it won't run, the problem is often permissions. Understanding rwx helps you diagnose issues like "Permission denied" errors instantly.

ls -a — Show Hidden Files

Try it now: Type ls -a

You’ll see files starting with a dot (.) that were hidden before — like .gitignore, .env, or .bashrc. These are called dotfiles.

In any real project, hidden files are everywhere: .git/, .env, .eslintrc, .prettierrc. They contain important configuration that ls alone won’t show you.

ls -la — The Power Combo

Try it now: Type ls -la

This combines both flags: long format and hidden files. This is the command developers use most often, and the one your AI tools run constantly.

You’ll now see the full picture: every file (including hidden ones), with all its details.

ls -R — Recursive Listing

Try it now: Type ls -R ~/projects/my-app/src

The -R flag lists contents of all subdirectories too. It’s like looking through every folder inside a folder.

This is useful for getting a quick overview of a project’s structure, though for larger projects you’ll learn a better tool (tree) in Lesson 2.3.

ls -lh — Human-Readable Sizes

Try it now: Type ls -lh ~/projects/my-app

The -h flag makes file sizes easier to read: instead of 1048576, you’ll see 1.0M. Instead of 4096, you’ll see 4.0K.

You can combine it with other flags: ls -lah gives you the full picture with human-readable sizes.

Summary of ls Flags
ls -l — long format with details
ls -a — show hidden files (dotfiles)
ls -la — both (the most common combo)
ls -R — recursive (show subdirectories)
ls -lh — human-readable file sizes

Practice

Try these commands in the terminal:

  1. ls -la ~/projects/my-app — see everything in the project
  2. ls -la ~/projects/my-app/src — inspect the source directory
  3. ls -lh ~/projects/my-app — check file sizes in a readable format
BlueBox Terminal