How to view and change permissions
Overview
Linux permissions control reading, writing, and executing for the owner, group, and others. Directories need execute permission to be entered.
View and change
ls -l script.sh
chmod u+x script.sh
chmod 644 notes.txt
chmod 755 script.sh
chown user:group file.txt
Modes explained
r,w, andxmean read, write, and executeu,g, andomean user, group, and others644is common for readable, owner-writable files755is common for executable scripts and public directories700keeps access with the owner
Safety
Do not solve permission problems with chmod 777; it grants everyone broad access. Identify which user or group needs which permission.
chown usually needs sudo and changes ownership. Use it only when the desired owner is clear.