Linux › Module 3 › Lesson 2
File Permissions (chmod, chown)
Read rwx permissions and change them with chmod and chown
Opening
The ten characters that guard every file
Run ls -l and you see something like: -rw-r--r-- 1 analyst developers 120 Apr 2 notes.txt That string is not decoration—it is the access control list for the file. Learn to read it and you understand half of Linux security.
1. Reading ls -l
First character
- means file, d means directory, l means symlink.
Next nine characters
Three groups of rwx: owner, group, others (everyone else).
r / w / x
Read, write, execute. For folders, x means you can enter (cd into) the directory.
2. chmod — Change Mode
Symbolic (human-friendly): chmod u+x script.sh — add execute for owner chmod go-w secret.txt — remove write for group and others Octal (common in scripts): chmod 644 file.txt — rw-r--r-- chmod 755 script.sh — rwxr-xr-x Digits: 4=read, 2=write, 1=execute. Add them per triplet (owner, group, other).
3. chown — Change Owner
chown changes user and optionally group (usually requires root): sudo chown analyst notes.txt sudo chown analyst:developers project/
Danger: chmod 777
chmod 777 makes a file readable, writable, and executable by everyone. Convenient in lazy tutorials—terrible on real servers. Attackers search for world-writable files.
Knowledge Check
In -rw-r--r--, who can write to the file?
Multiple choice
Knowledge Check
What does chmod 755 on a script typically mean?
Multiple choice
Knowledge Check
For a directory, what does the x (execute) permission allow?
Multiple choice