Skip to main content
LESSON 4 of 5//Core Navigation

Listing with ls and flags

The ls command lists the contents of a directory. On its own it shows filenames, but with flags (options) you can reveal much more detail about your files.

Basic listingzsh // interactive
~ls
Desktop Documents Downloads Music Pictures
# Long format — shows permissions, size, dates
~ls -l
drwxr-xr-x 5 dev staff 160 Apr 13 09:00 Desktop
drwxr-xr-x 3 dev staff 96 Apr 13 09:00 Documents
-rw-r--r-- 1 dev staff 2048 Apr 13 09:00 notes.txt

Flags modify how a command behaves. They start with a dash (-) and can be combined. For example, -la combines -l (long format) and -a (show hidden files).

Useful flag combinationszsh // interactive
# Show hidden files (dotfiles)
~ls -a
. .. .zshrc .config Desktop Documents
# Long format + hidden + human-readable sizes
~ls -lah
drwxr-xr-x 12 dev staff 384B Apr 13 09:00 .
drwxr-xr-x 5 dev staff 160B Apr 13 09:00 ..
-rw-r--r-- 1 dev staff 2.0K Apr 13 09:00 .zshrc
# Sort by modification time (newest first)
~ls -lt
!

Hidden files

Files starting with . (dotfiles) are hidden by default. These often contain important configuration — like .zshrc, .gitignore, or .env. Always use -a when you need to see them.

PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: