How to Use ls -la in Linux: List Files with Details
Use the
ls -la command in Linux to list all files and directories, including hidden ones, with detailed information like permissions, owner, size, and modification date. The -l option shows details in a list format, and -a includes hidden files starting with a dot.Syntax
The ls -la command combines two options:
-l: Lists files in long format showing details like permissions, owner, size, and modification date.-a: Includes hidden files and directories (those starting with a dot).
Together, ls -la shows a detailed list of all files, including hidden ones.
bash
ls -la
Example
This example runs ls -la in a directory to show all files and folders with details, including hidden files.
bash
ls -la
Output
total 48
drwxr-xr-x 6 user user 4096 Apr 26 10:00 .
drwxr-xr-x 3 user user 4096 Apr 25 09:00 ..
-rw-r--r-- 1 user user 220 Apr 25 09:00 .bash_logout
-rw-r--r-- 1 user user 3771 Apr 25 09:00 .bashrc
drwxr-xr-x 2 user user 4096 Apr 26 09:30 documents
-rw-r--r-- 1 user user 807 Apr 25 09:00 .profile
-rw-r--r-- 1 user user 0 Apr 26 10:00 notes.txt
drwxr-xr-x 2 user user 4096 Apr 26 09:45 pictures
Common Pitfalls
Some common mistakes when using ls -la include:
- Forgetting the dash
-before options, which can cause errors or unexpected behavior. - Not understanding that hidden files start with a dot and are only shown with
-a. - Confusing
ls -l(detailed list without hidden files) withls -la(includes hidden files).
bash
ls la ls -l ls -a
Output
ls: cannot access 'la': No such file or directory
(total list without hidden files)
(list of hidden files only)
Quick Reference
| Option | Description |
|---|---|
| -l | Show detailed list with permissions, owner, size, and date |
| -a | Include hidden files (those starting with a dot) |
| -la | Combine both: detailed list including hidden files |
Key Takeaways
Use
ls -la to see all files including hidden ones with detailed info.The
-l option shows file details; -a shows hidden files.Always include the dash
- before options to avoid errors.Hidden files start with a dot and are not shown without
-a.Use
ls -l to list details without hidden files if needed.