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 symlink

Permissions 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!)
NumberBitsMeaning
7rwxRead, write, execute
6rw-Read and write
5r-xRead and execute
4r--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.

Shell basics and navigation Processes, ports and jobs

Last refreshed 2026-09-17.