Unix file permissions

Aug 17, 2020
  • 4: Read
  • 2: Write
  • 1: Execute

Grant read-only permission to user.

chmod 400 <file>

Grant read and write permissions to user.

chmod 600 <file>

Grant read, write and execute permissions to user.

chmod 700 <file>

Notice that we’re only concerned with the first number in the above examples out of the three numbers. We leave the second and third numbers as 0.

The first number relates to the user permissions, the second to the group and the third to others (anyone who is not part of user or group).

So if we wanted to change the permissions for group, we’d modify the second digit like so:

chmod 740

This would grant all permission to user and read-only permission to group.

Alternatively, we can do the following if we don’t want to touch user or other.

chmod g+r