Linux file permissions

Commands:

  • chmod - Changes access permissions to files/directories
  • chown - Changes user and/or group ownership of files/directories
  • chgrp - Changes group ownership of files/directories

Examples:

  • To change the permissions of the directory some-directory to 777:
  • chmod 777 some-directory
  • To change the user ownership of the directory some-directory to user1:
  • chown user1 some-directory
  • To change the group ownership of the directory some-directory to group1:
  • chgrp group1 some-directory

Tips:

  • By adding a colon after the user, chown can be used to change the group and user ownership simultaneously, for example:
  • chown user1:group1 some-directory
  • The above commands can use -R to recursively change any sub-directories and their contents, for example:
  • chmod 777 -R some-directory/

Access permissions:

Permissions are allocated for three separate groups:

User: owner of the file
Group: group owner of the file
Others: other users not in the group

These are then given permissions, e.g:

644:
Owner can: Read and Write
Group can: Read
Others can: Read
775:
Owner can: Read, Write and Execute
Group can: Read, Write and Execute
Others can: Read and Execute
  • See the table below for a full list:
No. Read (r) Write (w) Execute (x)
0 Denied Denied Denied
1 Denied Denied Allowed
2 Denied Allowed Denied
3 Denied Allowed Allowed
4 Allowed Denied Denied
5 Allowed Denied Allowed
6 Allowed Allowed Denied
7 Allowed Allowed Allowed

Go back to the How-to Guides main page.

Search

Starter website

Offering small businesses and individual users the opportunity to have their own website on the internet, our 'starter websites' are available for only £150.

new site offer

To find out more and to see an example of the type of site offered, view our example starter website page.