Reading the ls -l Output
Every file and directory in Linux has a set of permissions that control who can read,
write, and execute it. You can see these permissions by running ls -l:
$ ls -l
-rw-r--r-- 1 john staff 4096 Mar 1 10:30 report.txt
drwxr-xr-x 3 john staff 4096 Feb 28 14:00 projects
-rwxr-x--- 1 john staff 512 Feb 25 09:00 backup.sh
That first column of characters is the permission string. Let's break it down piece by piece:
- rwx r-x ---
| | | |
| | | +-- Other (everyone else)
| | +------- Group (members of the file's group)
| +------------ Owner (the user who owns the file)
+---------------- File type (- = file, d = directory, l = symlink)
After the file type character, the remaining 9 characters are always three groups
of three: owner permissions, group permissions, and other (everyone else) permissions.
Each group follows the same rwx pattern.
What r, w, and x Mean
Each permission letter controls a specific type of access. The meaning differs slightly between files and directories:
For Files
cat and less will fail.
For Directories
ls. Without this, you cannot see what is inside.
cd and access files inside it. Without this, the directory is completely inaccessible.
A dash (-) in any position means that permission is not granted. For example:
r-- = read only
rw- = read and write, but not execute
r-x = read and execute, but not write
--- = no access at all
A directory with r-- permissions lets you list file names but not
open or read any of them. You need x to actually enter the directory
and access its contents. This is why directories almost always have x
set for at least the owner.
Owner, Group, and Other
Linux uses a three-tier access model. Every file has an owner (a single user) and a group (a single group). Everyone else falls into "other."
$ ls -l report.txt
-rw-r--r-- 1 john staff 4096 Mar 1 10:30 report.txt
In this example:
- john is the owner -- has
rw-(read and write) - staff is the group -- has
r--(read only) - Everyone else -- has
r--(read only)
When Linux checks permissions, it follows this order: if you are the owner, the owner permissions apply. If you are not the owner but belong to the file's group, the group permissions apply. Otherwise, the "other" permissions apply. Only one set applies -- they do not add together.
Run groups to see which groups your user belongs to. Run
id for a more detailed view including your user ID and all group
IDs. This helps you understand which permission tier applies to you for any file.
Changing Permissions with chmod
The chmod (change mode) command modifies file permissions. There are two
ways to use it: symbolic mode (letters) and numeric mode (numbers).
Symbolic Mode
Symbolic mode uses letters to specify who gets what permissions. The format is:
chmod [who][operator][permissions] file
u = owner, g = group, o = other, a = all three
+ adds a permission, - removes it, = sets it exactly
# Give the owner execute permission
chmod u+x script.sh
# Remove write permission from group and other
chmod go-w report.txt
# Give everyone read permission
chmod a+r public-file.txt
# Set exact permissions: owner=rwx, group=rx, other=nothing
chmod u=rwx,g=rx,o= project-dir
Numeric (Octal) Mode
Numeric mode represents permissions as a three-digit number. Each digit is the sum of its permission values:
Add the values together for each position (owner, group, other):
7 = 4+2+1 = rwx (full access)
6 = 4+2 = rw- (read and write)
5 = 4+1 = r-x (read and execute)
4 = 4 = r-- (read only)
0 = 0 = --- (no access)
# Set permissions to rwxr-xr-x (755)
chmod 755 script.sh
# Set permissions to rw-r--r-- (644)
chmod 644 document.txt
# Set permissions to rwx------ (700)
chmod 700 private-dir
# Set permissions to rw------- (600)
chmod 600 secret-key.pem
Common Permission Patterns
Certain permission numbers appear again and again in Linux. Memorize these and you will be able to handle most situations:
~/.ssh.
SSH private keys (~/.ssh/id_rsa, ~/.ssh/id_ed25519)
must be set to 600. If the permissions are too open, SSH will refuse
to use the key and display a warning: "Permissions are too open." Always run
chmod 600 ~/.ssh/id_* after creating or copying keys.
Summary
In this tutorial, you learned the fundamentals of Linux file permissions:
- How to read the permission string in
ls -loutput - What
r,w, andxmean for files and directories - The three-tier model: owner, group, and other
- How to change permissions with
chmodusing symbolic and numeric modes - Common permission patterns: 755, 644, 700, 600
Understanding permissions is a cornerstone of Linux security. You now know how to read and set permissions to control exactly who can access your files. This knowledge will be essential as you work with system administration, scripting, and server management.