chmod: Usage, Options & Common CI Errors
chmod sets who can read, write, and execute a file.
chmod fixes two recurring CI problems: scripts that lost their execute bit (often after a checkout or download) and SSH keys that are too permissive for ssh to accept.
What it does
chmod changes the permission bits of files and directories, using either symbolic notation (u+x, go-w) or octal numbers (755, 600). The bits control read (4), write (2), and execute (1) for owner, group, and others.
Common usage
chmod +x deploy.sh # make executable
chmod 755 script.sh # rwxr-xr-x
chmod 600 key.pem # required for SSH private keys
chmod -R u+rwX,go-w ./dir # recursive, X = dirs/already-exec
chmod 644 config.yamlOptions
| Item | What it does |
|---|---|
| +x / u+x | Add execute (all / owner) |
| 755 / 644 / 600 | rwxr-xr-x / rw-r--r-- / rw------- |
| -R | Recurse into directories |
| X (capital) | Execute only if a dir or already executable |
| ugo | User, group, others |
Common errors in CI
"./deploy.sh: Permission denied" means the execute bit is missing - chmod +x it (Git can preserve the bit; downloads and some unzips do not). For SSH, "Permissions 0644 for key are too open" is fatal: chmod 600 the key. On Windows/WSL or certain mounted filesystems chmod is a no-op (mode tracked elsewhere), so the bit may not "stick". Prefer chmod -R ...,go-w over a blanket 777, which fails security scans.