How do permission bits work with chmod?

Q I'm new to Linux and have been a bit confused as to how the permission 'bits' work with chmod. Can you help?

A Chmod access permissions can be expressed by either three single octal digits or three lots of letters. This trio represents permissions for the file owner, the group and 'world' respectively. Take chmod 755. Each digit is a sum, added up to express the various permissions. Here is each bit with its value:

0 = no permissions (---)
1 = execute only (--x)
2 = write only (-w-)
3 = write and execute (-wx)
4 = read only (r--)

So to set read and execute permission you'd use 5; this is 1 for execute added to 4 for read access. For full access, you'd add 4 for read, 2 for write and 1 for execute, 4+2+1=7. If you set the permissions on a file to be 755, that means the owner has full access (7) and the group for the file has read and execute access (5), as does 'world' ie everyone else. There are other bits you can set for special functions but these are the main ones.

Follow us on or Twitter

Username:   Password: