Listing Files (ls)
ls lists directory contents. The handful of flags that matter daily: -l (long), -a (all incl. dotfiles), -h (human sizes), -t (sort by mtime), -r (reverse), -S (sort by size).
Real ls patterns + modern alternatives
EXAMPLE
# Default — names only ls # Long listing — perms, owner, size, mtime ls -l # All flags I use daily ls -lah # long, all, human-readable ls -ltr # sort by mtime, oldest first → top of output ls -lhS # sort by size descending ls -1 # one entry per line — good for piping # Recurse ls -R src/ # Custom columns + colour ls --color=auto --group-directories-first # What's the LATEST file in a directory? ls -t1 logs/ | head -1 # Combine with find for power find . -name '*.ts' -newer package.json -ls # Modern alternatives — install once, never look back # eza (formerly exa) — colour, git status, tree mode # lsd — colour + icons # broot — interactive # eza recipes eza -lah --git eza --tree --git-ignore --level 3 eza -l --sort=modified # Sort-and-show shortcuts in bashrc / zshrc alias ll='eza -lah --git --group-directories-first' alias lt='eza --tree --git-ignore --level 3'
Why it matters
eza --git annotates the listing with each file’s git status (modified, staged, ignored). Once you have it in your alias, you stop running git status separately for “what did I touch?”.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Exercise
List with long detail + hidden + human sizes.
ls
Four characters; one dash + three flags.
Discussion
Loading…