Risan Bagja

Unix File Permission

Unix File Permission Command Breakdown

$ 0 123 456 789


Execute Permission Effect

Effect of execute permission set to TRUE:

Read/Write Permission Effect on Directory

Change Permission

$ chmod [-R] u=rwx,g=rwx,o=rwx path

For example:

$ chmod u=rwx,g=rw,o=rw test.txt 

# You can combine it like this:
$ chmod u=rwx,go=rw test.txt

If you don’t want to give any permission, leave it empty:

# Other users don't have any permission
$ chmod u=rwx,g=rw,o= test.txt

You may update permission partially:

# Only update group permission, leave the rest as it is
$ chmod g=rwx test.txt

You can also add a permission with (+) or removing it with minus(-):

# Removing execute permission from group, adding read & write permissions for other user
$ chmod g-x,o+rw

You can also change the permission with octal number. You need to calculate the total of each permission:

We can translate this:

$ chmod u=rwx,g=rx,o= test.txt

Into this:

$ chmod 750 test.txt

Change Ownership

$ chown [-R] user path

We can also set along the group with chown command:

$ chown [-R] user:group path

If you want to update only the group you can use:

$ chgrp [-R] group path