Unix permissions control who can read, write, or execute files. Scripts need the execute bit; secrets should not be world-readable.
Reading permissions
ls -l hello.sh
touch sample.txt
chmod u+x hello.sh
chmod go-w sample.txt
ls -l hello.sh sample.txtls -l shows owner/group/other bits (rwx).
Numeric chmod
chmod 755 deploy.sh # rwxr-xr-x
chmod 600 secret.env # rw-------755 is common for scripts; 600 for private config.
Ownership context
You cannot chmod files you do not own unless you use sudo (not covered here). In CI, scripts run as a service user—permissions must allow that user to read inputs and write artifacts.
Important interview questions and answers
- Q: What does chmod +x do?
A: Adds execute permission for the user class you specify (u+x adds user execute). - Q: Why 600 for secrets?
A: Owner read/write only—others cannot read the file.
Self-check
- What does rwx mean for the owner?
- Which chmod makes a script executable for everyone?
Tip: Never chmod 777 on deploy scripts—too open for shared servers.
Interview prep
- chmod 755 typical use?
Executable script readable by group/other.
- Why 600 for secrets?
Owner-only read/write reduces leak risk.