Listing Files (ls)
The ls command lists files and directories. It's one of the most frequently used commands in Linux.
Basic Usage
Common Options
| Option | Description |
|---|---|
-l | Long format (detailed listing) |
-a | Show all files (including hidden) |
-h | Human-readable sizes (KB, MB, GB) |
-R | Recursive (include subdirectories) |
-t | Sort by modification time |
-S | Sort by size |
-r | Reverse sort order |
Long Format (-l)
The -l option shows detailed information:
-rw-r--r-- 1 user group 4096 Jan 7 10:00 file.txt
Breaking it down:
-rw-r--r--- Permissions1- Number of linksuser- Ownergroup- Group4096- Size in bytesJan 7 10:00- Last modifiedfile.txt- Filename
Hidden Files (-a)
Files starting with . are hidden:
Combining Options
Options can be combined:
ls -la # Long format + all files
ls -lah # Long + all + human-readable
ls -lt # Long format, sorted by time
ls -lS # Long format, sorted by size
Listing Specific Directories
You can list any directory by specifying its path:
ls /etc # List /etc directory
ls ~/documents # List documents in home
ls .. # List parent directory
Exercise: List All Files
Use ls with options to see all files including hidden ones:
Color Output
Most modern systems color-code ls output:
- Blue: Directories
- Green: Executable files
- Cyan: Symbolic links
- Red: Archives
- White: Regular files
Quick Reference
| Command | What it shows |
|---|---|
ls | Files in current directory |
ls -l | Detailed listing |
ls -a | All files including hidden |
ls -la | Detailed listing of all files |
ls -lh | Detailed with readable sizes |
ls path/ | Files in specified directory |
Key Takeaways
lslists directory contents- Use
-lfor detailed information - Use
-ato see hidden files - Combine options like
-lafor both - Colors help identify file types
التالي · الدرس 7 من 40
Changing Directories (cd)
قراءة 2 دقيقة
أنهيت 6 من 40 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

