Lesson 01 Review Card - ls
1-Minute Review Card: ls
Must Remember
lslists directory content.-llong format,-aall files,-Aalmost all.-tsort by time,-Ssort by size,-rreverse.-hhuman readable size (for long format)..current directory,..parent directory.
Option Style Rule
-is for short option names:-l,-a,-t.--is for long option names:--color=auto,--help.- This is not about single vs many arguments.
- You can pass many of either style:
ls -lals --color=auto --time-style=iso
-l vs -n
ls -lshows owner/group names (e.g.,root,testuser).ls -nshows numeric owner/group IDs (UID/GID).
Time Sort Reminder
ls -lt-> sort/display bymtime.ls -ltu-> sort/display byatime.ls -ltc-> sort/display byctime.
Size Reminder
-sshows allocated blocks column.-Ssorts entries by size (largest first).- Practical readable combo:
ls -lSh.
Formatting Reminder
ls -1-> one entry per line.ls -m-> comma-separated list (same idea as--format=commas).ls -lQ-> quote file names.--time-style=locale|iso|full-isochanges date display in long listing.
8 Essential Commands
ls
ls -l
ls -a
ls -al
ls -lt
ls -lS
ls -lh
ls --help
Common Mistakes
- Mixing
-sand-S(they are different). - Forgetting hidden files when debugging (
ls -a). - Thinking UID means group (UID is user, GID is group).
Self-check (30 seconds)
- How do I list parent directory?
- How do I show one file per line with quotes?
- How do I print long list with human-readable sizes?
Answers:
ls ..ls -1Qls -lh