Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · navigation

ls

what is in here

ls lists a directory. On its own it prints names; with -l it prints one line of facts per entry — what kind of thing it is, who may do what to it, who owns it, how big it is and when it last changed. That long line is the most-read output on any Linux system.

The first ten characters of an ls -l line say what the entry is and who may touch it.

Lists
Directory entries
the current one by default
Everyday flags
-la
long format, hidden files too
Hidden means
Starts with a dot
a naming habit, not a lock
Readable sizes
-h
K, M and G instead of bytes

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashcoreutils
$ ls -la
total 24
1drwxr-xr-x 4 user user 4096 Sep 30 10:12 .
drwxr-xr-x 18 user user 4096 Sep 28 09:40 ..
2-rwxr-xr-x 1 user user 1830 Sep 29 17:03 deploy.sh
3-rw------- 1 user user 412 Sep 30 10:12 .env
drwxr-xr-x 8 user user 4096 Sep 30 09:58 .git
4lrwxrwxrwx 1 user user 12 Sep 29 17:05 logs -> /var/log/app
5-rw-r--r-- 1 user user 2264 Sep 30 10:02 README.md
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
The first character is the type

"d" is a directory, "-" a regular file, "l" a symbolic link. The dot is this directory itself, and the two dots below it are its parent.

2
Then three groups of three

rwx for the owner, r-x for the group, r-x for everyone else. The x on a file means it may be run as a program.

3
Dotfiles only appear with -a

.env is hidden from a plain ls. Its rw------- mode means only the owner can read or write it — right for a file of secrets.

4
The arrow marks a symbolic link

logs is a pointer to /var/log/app. Its own permissions are always shown as rwxrwxrwx; the target's are what count.

5
The rest of the line, left to right

Link count, owner, group, size in bytes, the time the content last changed, and the name.

Switches

A switch changes how the command behaves. These are the ones used day to day; man ls lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-l
Long format: permissions, owner, group, size and date, one entry per line.
-a
All: include the hidden entries whose names begin with a dot.
-h
Human-readable sizes — 4.0K, 12M, 1.3G — when used with -l.
-R
Recursive: list every sub-directory beneath as well.
-t
Sort by modification time, newest first.
-r
Reverse the sort order. With -t, oldest first.
-S
Sort by size, largest first.
-d
List the directory itself rather than its contents.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

ls -lh /var/log

Long listing of another directory with sizes in K, M and G.

ls -lt | head

Newest first — the quickest way to see what just changed.

ls -ld /etc/ssh

Describes the directory itself rather than listing what is inside it.

ls -R src

Lists every subdirectory beneath src as well.

In cybersecurity

An ls -l line is a permission audit of one file. Reading it properly finds most local misconfigurations before an attacker does.

World-writable entries

A "w" in the last group of three lets any user on the system change the file. On a script that root runs, that is a way to become root.

Secrets left readable

Keys, .env files and backups should show rw------- or stricter. An r in the last group publishes them to every local user.

Hidden is not protected

A leading dot only hides a name from a casual listing. Always look with -a, especially in web roots and home directories.

Filed under

Navigation

Read alongside