Getting to Know the ls Command in Linux
If you’re new to Linux, one of the very first commands you’ll come across is ls. Think of it as your “show me what’s here” command. Anytime you’re in a folder (directory), ls helps you see what files and subfolders are inside. It might seem simple at first, but once you get comfortable with its options, it becomes one of the handiest tools you’ll use every day. You can find the actual webpage here
The Basics
Just typing ls by itself will show you what’s in your current folder. For example:
ls
Documents Downloads Music Pictures notes.txtFinding Hidden Files
In Linux, some files start with a dot (.) which makes them hidden. To see those, you can use the -a option:
ls -aSeeing More Details
Want to know more than just the names? Add the -l option (that’s a lowercase “L”):
ls -l
The output will look like this
-rw-r--r-- 1 user user 1024 Sep 11 09:00 notes.txt
drwxr-xr-x 2 user user 4096 Sep 10 20:15 DocumentsHere you can see file permissions, owner, size, and the last time it was updated. It’s like switching from a simple list view to a detailed one.
Making Sizes Easier to Read
File sizes in raw bytes aren’t fun to read. Add the -h option to make them “human-readable”:
ls -lhNow sizes show up as KB, MB, or GB instead of just a long number. Much nicer!
Sorting by Time
If you want to know what’s been changed most recently, try:
ls -ltThis sorts everything by modification time, with the newest at the top. Adding -r flips the order:
ls -ltrGreat for checking what you last worked on.
Looking Inside Subfolders
Sometimes you want to peek inside all folders at once. That’s where -R comes in:
ls -RIt will show the current folder and then keep diving into subfolders.
Mixing Options
Here’s the fun part—you can mix options together. For example:
ls -alhThis shows hidden files (-a), detailed info (-l), and human-friendly sizes (-h) all at once.
A Little Extra
If your terminal has colors, you might notice different colors for files, folders, and executables. If not, try:
ls -F
This adds symbols—like / for directories and * for executables—to help you tell things apart.
Key Takeaways
The ls command is simple, but it’s also one of the most useful tools in Linux. It helps you find files, check their details, and explore your system. Once you get used to its options, you’ll probably use it without even thinking. So go ahead, open your terminal, type ls, and start exploring your Linux world!
ls Command Quick Reference
| Option | What It Does |
| ls | Lists files and folders in the current directory. |
| -a | Shows hidden files (those starting with a dot . ). |
| -l | Displays detailed information (permissions, size, owner, date). |
| -h | Makes file sizes easier to read (KB, MB, GB). |
| -t | Sorts files by modification time (newest first). |
| -r | Reverses the sort order. |
| -R | Lists files in the current directory and all subdirectories. |
| -F | Adds symbols to file names (/ for folders, * for executables, @ for links). |
| -alh | Combines options: hidden files, detailed info, human-readable sizes. |
Please feel free to download this pdf for yourself, it helped me because I kept forgetting commands
