Chapter 6: Bash List (Is)
Bash List (ls) — or as most people say, the ls command.
You wrote “Bash List (Is)” — I think you mean ls (the letter “L” + “S”), because in Bash/Unix/Linux, the command to list files and folders is spelled ls (not “is”).
ls is probably the number 1 most used command in the entire terminal world. Every time you want to know “What’s inside this folder?” — you type ls.
Let me explain it like we’re sitting together in Hyderabad, practicing on your laptop, step-by-step, with real examples, what each part means, common combinations, and pro tips.
What does “ls” actually stand for?
ls = list (or sometimes people joke “list storage”)
It comes from very old Unix days (1970s). It simply lists the names of files and directories in a folder.
Basic Usage — Just type ls
Open terminal → type:
|
0 1 2 3 4 5 6 |
ls |
Example output (yours will be different):
|
0 1 2 3 4 5 6 |
Documents Downloads Music Pictures bash_class hello.sh my_notes.txt |
- It shows non-hidden files and folders in current location
- Folders usually have no special mark (but many terminals color them blue)
- Files are white or default color
Most Important Variations (You will use these every day!)
- ls -l → Long format (shows details — super useful!)
|
0 1 2 3 4 5 6 |
ls -l |
Example output:
|
0 1 2 3 4 5 6 7 8 9 10 |
total 24 drwxr-xr-x 2 webliance webliance 4096 Feb 25 13:10 Documents drwxr-xr-x 2 webliance webliance 4096 Feb 20 09:45 Downloads -rw-r--r-- 1 webliance webliance 456 Feb 25 12:30 hello.sh -rw-rw-r-- 1 webliance webliance 1024 Feb 24 18:20 my_notes.txt |
What each column means (very important!):
| Column | What it shows | Example from above | Meaning |
|---|---|---|---|
| 1 | File type & permissions | drwxr-xr-x | d = directory, – = normal file, rwx = read/write/execute for owner/group/others |
| 2 | Number of hard links | 2 | Usually 1 for files, 2+ for dirs |
| 3 | Owner (user) | webliance | Who owns it |
| 4 | Group | webliance | Group permission |
| 5 | Size in bytes | 4096 or 456 | Folder size is block size, not contents |
| 6-8 | Last modified date/time | Feb 25 13:10 | When changed last |
| 9 | Name | Documents | The file/folder name |
- ls -a → Show All (including hidden files)
Hidden files start with . (dot) — like .bashrc, .git, .ssh
|
0 1 2 3 4 5 6 |
ls -a |
Output example:
|
0 1 2 3 4 5 6 |
. .. .bash_history .bashrc .config Documents Downloads hello.sh |
- . = current folder
- .. = parent folder
- Everything else starting with . is hidden config stuff
- ls -la or ls -al → Long + All (most common combo!)
|
0 1 2 3 4 5 6 |
ls -la |
→ Shows details + hidden files — you’ll type this 50 times a day!
- ls -lh → Long + Human-readable sizes
|
0 1 2 3 4 5 6 |
ls -lh |
Output:
|
0 1 2 3 4 5 6 7 |
-rw-r--r-- 1 webliance webliance 2.3K Feb 25 12:45 report.pdf drwxr-xr-x 3 webliance webliance 4.0K Feb 24 10:20 projects |
→ Sizes in K, M, G instead of raw bytes — much easier to read!
- ls -lah → The ultimate beginner combo (long + all + human)
|
0 1 2 3 4 5 6 |
ls -lah |
Most people alias this to ll in their .bashrc (we’ll learn aliases later)
Sorting & Ordering Tricks
- ls -lt → Sort by time (newest first)
|
0 1 2 3 4 5 6 |
ls -lt |
→ Latest modified file at top — great for finding recent work
- ls -ltr → Reverse time (oldest first)
|
0 1 2 3 4 5 6 |
ls -ltr |
→ Very useful with tail later: ls -ltr | tail -5 = last 5 modified files
- ls -lS → Sort by size (largest first)
|
0 1 2 3 4 5 6 |
ls -lSh # human sizes too |
Other Handy Options
- ls -F → Show type with symbols
|
0 1 2 3 4 5 6 |
ls -F |
→ Adds / after folders, * after executables, @ for links, etc.
Example:
|
0 1 2 3 4 5 6 |
Documents/ hello.sh* my_notes.txt |
- ls -R → Recursive (show subfolders too)
|
0 1 2 3 4 5 6 |
ls -R |
→ Dumps everything deep inside — can be long!
- *ls .txt → Only certain files (pattern matching)
|
0 1 2 3 4 5 6 7 8 |
ls *.sh # all shell scripts ls report* # files starting with report ls file?.txt # ? = single character |
- ls -i → Show inode numbers (advanced, for hard links)
Super Common Combinations Table (Memorize these!)
| You type | What you get | When to use |
|---|---|---|
| ls | Simple names | Quick peek |
| ls -l | Detailed list | Check permissions/size/date |
| ls -a | See hidden files | Looking for .git / .env / .bashrc |
| ls -la / ls -al | Detailed + hidden | Almost every time! |
| ls -lah | Detailed + hidden + nice sizes | Best daily command (alias as ll) |
| ls -ltrh | By time reverse + human sizes | Find newest/big files |
| ls -lSh | By size descending + human | Find space hogs |
| ls -F | With type indicators | See what’s executable/folder |
Practice Right Now (5 minutes!)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
cd ~ mkdir ls_practice cd ls_practice touch file1.txt file2.sh secret.txt mkdir photos backups echo "hidden config" > .secret_config ls ls -a ls -l ls -lah ls -ltrh ls *.txt |
See how the output changes? Play with it!
Teacher tip: Many people add this to ~/.bashrc so ll = ls -lah:
|
0 1 2 3 4 5 6 |
alias ll='ls -lah --color=auto' |
Then just type ll forever — saves typing!
Got it? ls is your eyes in the terminal — master it and you’ll never feel lost.
Any confusion? Want more on permissions (that drwxr-xr-x part)? Or want practice exercises? Or next topic: “Teacher, explain grep” or “pipes with ls” or “how to alias ll”
Keep typing — you’re doing awesome! 🐧🚀 From Hyderabad! 😄
