Files and permissions
Reading rwx bits, chmod usage without magic numbers, ownership, and finding files quickly.
Reading ls -l
-rwxr-xr-- 1 ada dev 4096 Sep 17 10:00 deploy.sh
βββ¬βββ¬βββ¬β
β β β βββ others: r-- (read only)
β β ββββββ group: r-x (read + execute)
β βββββββββ owner: rwx (full)
βββββββββββ file type: - file, d directory, l symlinkPermissions are evaluated in order: owner, then group, then others. The first category you match decides what you get β you do not accumulate permissions.
Changing permissions
chmod +x deploy.sh # add execute for everyone
chmod u+x,g-w file # symbolic: user +x, group -w
chmod 755 script.sh # numeric: owner 7, group 5, others 5
chmod 600 id_rsa # private key: owner read/write only
chmod -R 644 public/ # recursive (careful!)| Number | Bits | Meaning |
|---|---|---|
7 | rwx | Read, write, execute |
6 | rw- | Read and write |
5 | r-x | Read and execute |
4 | r-- | Read only |
0 | --- | No access |
β οΈ
chmod -R 777 is never the fix β it hands write access to every account on the machine. Find the right owner or group instead, and remember directories need the execute bit to be entered.Ownership
chown ada:dev file.txt # owner:group
chown -R www-data:www-data /srv/app
id # who am I, which groups
groups
usermod -aG docker ada # append to a group (needs logout)Finding things
find . -name '*.log' -mtime +7 # older than 7 days
find /var -type f -size +100M
find . -name '*.tmp' -delete # test without -delete first!
locate nginx.conf # uses a cached index
which node # resolved path of a commandπ‘
Run
find without -delete/-exec first and eyeball the list β it is easy to match far more than intended.FAQ
Why can I not delete a file I own?
Deleting requires write permission on the directory, not the file.
Executable script still will not run?
Check the permissions, the shebang line (
#!/usr/bin/env python3), and Windows line endings β CR characters break the interpreter path.Related
Shell basics and navigation Processes, ports and jobs
Last refreshed 2026-09-17.