Short and simple chmod reference. Use numbers to set file permissions.
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
Make file readable for owner:
readable (4) owner = 400 => chmod 400 fname
Make file readable and writeable for owner:
readable + writeable (4 + 2) owner = 600 -> chmod 600 fname
Make file readable and writeable for group:
readable + writeable (4 + 2) owner = 60 -> chmod 60 fname
Make file readable and writeable for anybody:
readable + writeable (4 + 2) owner = 6 -> chmod 6 fname
Examples
# Set file permission to-rwxr-xr-x
# Read Owner 400
# Read Group 40
# Read Other 4
# Write Owner 200
# Write Group 100
# Write Other 010
# Exec other 001
# Total = 400+040+004+200+100+010+001 = 755
chmod 755 thefile.cgi
# Read and write by everyone (444 + 222):
chmod 666 file.txt
# Change all directories to rwx by everyone:
find . -type d -exec chmod 777 {} +
# Change all files to rw by everyone:
find . -type f -exec chmod 666 {} +