The ls Commands You Will Use Most
ls
ls -l
ls -lah
ls -ltr /var/logWith no argument, ls lists the current directory; give a path to list another one. -l shows details, -a adds hidden files, and -h prints sizes in K, M, and G. -ltr puts the most recently changed files at the bottom, which is the quickest way to see what changed last in a log or upload folder.
Read the ls -l Columns
-rw-r--r-- 1 deploy www-data 4521 Nov 28 09:14 index.html
drwxr-xr-x 3 deploy www-data 4096 Nov 27 18:02 assets
lrwxrwxrwx 1 root root 22 Nov 20 11:40 current -> /var/www/releases/2026| Column | Meaning |
|---|---|
-rw- | Type, then read, write, and execute for owner, group, and others. |
1 | Number of hard links. |
deploy | Owner. |
www- | Group. |
4521 | Size in bytes. |
Nov 28 09:14 | Last modification. |
index. | Name; a link also shows its target. |
The first character gives the type: - is a regular file, d a directory, and l a symbolic link. A dot after the permissions means the file has an SELinux context, which you will see on AlmaLinux and Rocky Linux; a plus sign means it has extra access rules (an ACL). For files changed more than about six months ago, the time is replaced by the year. The size of a directory, often 4096, is the space for its list of names, not the size of its contents. The total line at the top is the disk space used by the listed files, in blocks of 1024 bytes by default.
Show Sizes You Can Read
ls -lh /var/backups-h changes the size column to values such as 4.5K or 1.2G. It does not add up the contents of folders; for that, use du, as shown in how to check disk space in Linux.
Sort by Time or Size
| Option | Sort order |
|---|---|
-t | Newest first. |
-S | Largest first. |
-r | Reverses any order. |
-v | Numbers in names in natural order. |
Combine them: ls -lhS /var/log | head shows the largest files in a folder, and ls -lt | head the most recent ones.
List Hidden Files
Names that start with a dot, such as .bashrc or .ssh, are hidden from a plain ls. ls -a shows them together with the . and .. entries; ls -A shows them without those two.
A Directory Itself, or Everything Below It
ls -ld /var/www
ls -ld */
ls -R /etc/nginx-d lists the directory itself instead of its contents, which is how you check a folder's owner and permissions. ls -ld */ lists only the subdirectories of the current folder. -R lists every folder below the path; on large trees the output gets long, and find is a better tool for searching.
Colors and Other Useful Options
On its own, ls prints no colors. Many distributions set an alias in the default shell setup so that ls runs as ls --color=auto. Directories usually appear in blue, links in cyan, executable files in green, and broken links in red; the exact colors come from the LS_ variable. type ls shows whether an alias is active.
-i: prints the inode number of each file, which shows whether two names are hard links to the same file.-1: one name per line.--group-directories-first: lists folders before files.--time-style=long-iso: prints dates as2026-11-28 09:14.
Common Problems
- Permission denied: your user cannot read that folder. Use
sudo ls -l /path. - No such file or directory: names are case-sensitive, so
Logsandlogsare different folders. - Argument list too long: a pattern such as
ls *.jpgmatched too many files. Use find instead. - Counting files: do not parse ls output in scripts; to count, use wc with find.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations