There are two way to give file/directory permissions using bits and symbolic representation . In this article, let us discuss how to use symbolic representation with chmod.
we are having 3 different roles of symbolic representation user, group and others.The representation given below:
- u is for user,
- g is for group,
- o is for others.
we also have 3 symbolic representation of file/directory permissions. they are :
- r is for read permission,
- w is for write permission,
- x is for execute permission.
And we also have +, – and = symbols :
- + means Add,
- – means Remove,
- = means set the permissions exactly like this.
Following are few examples on how to use the symbolic representation on chmod.
1.Add a permission to file/directory
chmod g+w filename
Changing permission to a single set. + symbol means adding permission. Here we are giving group to write permission. Likewise you can give single permission(r/w/x) for any roles(u/g/o).
2. Remove permission from a file/directory
$ chmod u-x filename
This will remove execute permission from user.
3. Add multiple permission to a file/directory
Use comma to separate the multiple permission sets as shown below.
$ chmod u+r,g+x filename
4.Remove multiple permission from a file/directory
$ chmod u-rx filename
5. Change permission for all roles on a file/directory
$ chmod a+x filename
It will change the permission of all three roles such as user,group and others.
6. Set a permission of a file/directory
$ chmod u=w filename
7.Set multiple permission of a file/directory
$ chmod u=rwx filename
It will set the permission. This will replace the permission with given permission.