Knowing how to set file permissions is very useful (for a much more thorough primer than I provied here, see this article). Unfortunately, while this is very easy to do, it is even easier to forget the codes used to do so. So here’s how you do it!

The easiest (shortest) way to change permissions is using octal syntax. Octal syntax goes like this:

chmod <owner><group><others> filename

Where <owner>, <group> and <others> stand for the octal numeral pertaining to that user or group. Conveniently, there are eight values these codes can take. Coincidence? I think not!

CodePermissions granted
0No permissions
1Execute only
2Write only
3Write and execute
4Read only
5Read and execute
6Read and write
7Read, write, and execute (full permissions)

For example, this lets anyone do anything they want to the file,

chmod 777 file.txt

this only lets the owner read and write to the file,

chmod 700 file.txt

And this gives the owner full permissions, other users in the same group as the owner read and execute permissions and everyone else only execute permissions:

chmod 751 file.txt

Now go ye forth and modify permissions.