Lesson 04 · tested on Debian 13
Linux file permissions: read ls -l, fix "Permission denied", and never chmod 777
Learn to read the permission string in ls -l, translate it to numbers like 644 and 755, and fix three real "Permission denied" situations: a script that won't run, a secret file other users can read, and a private folder. Then see live why chmod 777 is a bad fix, and how to find world-writable files.
Video coming soon — @ShellProven
Commands
Exactly as run in the video. Full folder with setup script and log: terminal-tutorials/chmod-permissions.
# Reading ls -l
$ ls -l
total 16
-rw-r--r-- 1 alice web 24 Nov 21 19:15 deploy.sh
-rw-r--r-- 1 alice web 6 Nov 21 19:15 index.html
drwxr-xr-x 2 alice web 4096 Nov 21 19:15 private
-rw-r--r-- 1 alice web 17 Nov 21 19:15 secret.env
# From letters to numbers
$ stat -c '%A %a %U:%G %n' *
-rw-r--r-- 644 alice:web deploy.sh
-rw-r--r-- 644 alice:web index.html
drwxr-xr-x 755 alice:web private
-rw-r--r-- 644 alice:web secret.env
# Problem 1: the script won't run
$ su alice -c ./deploy.sh
sh: 1: ./deploy.sh: Permission denied
$ chmod u+x deploy.sh && su alice -c ./deploy.sh
deployed
$ chmod go-w,g+x deploy.sh && stat -c '%A %a %n' deploy.sh
-rwxr-xr-- 754 deploy.sh
# Problem 2: a secret anyone can read
$ su bob -c 'cat secret.env'
DB_PASSWORD=demo
$ chmod 600 secret.env && su bob -c 'cat secret.env'
cat: secret.env: Permission denied
# Problem 3: a private folder
$ chmod 750 private && su bob -c 'ls private'
ls: cannot open directory 'private': Permission denied
$ ls -ld private
drwxr-x--- 2 alice web 4096 Nov 21 19:15 private
# Why chmod 777 is a bad fix
$ chmod 777 index.html && su bob -c 'echo defaced > index.html' && cat index.html
defaced
$ find . -perm -o=w -type f
./index.html
$ chmod 644 index.html && su bob -c 'echo again > index.html'
sh: 1: cannot create index.html: Permission denied
# Changing the owner with chown
$ chown bob:web index.html && ls -l index.html
-rw-r--r-- 1 bob web 8 Nov 21 19:15 index.html
Quick check
Same two questions as in the video. Checked here, in your browser — nothing is sent anywhere.
Transparency. Script and narration made with AI, human-reviewed. The robot and the dog are AI-generated cartoon characters. The commands and their output are real runs in a container.