Change file or directory permissions.
high risk
stat -c '%a %U:%G %n' <path>Record the current mode/owner.chmod -R u=rwX,g=rX,o= <dir>Capital X sets execute only on directories and already-executable files.chmod modifies read/write/execute permissions for owner, group, and others. Accepts symbolic (u+x) or octal (755) notation. Octal is precise and unambiguous — 755 means owner rwx, group r-x, others r-x. The -R flag applies changes recursively.
| Flag | Meaning |
|---|---|
-R --recursive | Apply changes recursively to directories |
-v --verbose | Print a message for each changed file |
-c --changes | Report only files that are changed |
chmod 600 ~/.ssh/id_ed25519Restrict private key to owner-read only (SSH requirement) · explain & risk-check →chmod 644 /etc/nginx/nginx.confReadable by all, writable only by owner · explain & risk-check →chmod +x deploy.shMake a script executable · explain & risk-check →chmod -R 750 /opt/appSet app directory: owner rwx, group r-x, others none · explain & risk-check →chmod u+s /usr/bin/binarySet SUID bit — runs as file owner · explain & risk-check →Remember '7=rwx, 6=rw-, 5=r-x, 4=r--'. Use 644 for files, 755 for directories as baseline public defaults — and 600/700 for anything private.
Reference text is hand-written and may be incomplete — check man chmod for your version. Test destructive commands on a non-production system first.