File permissions in linux is done by chmod command. It allows you to give permissions in a file, directory, etc.. Three main permission r, w, x
chmod command in linux | linux permissions | with pictures and examples
![]() |
chmod command in linux |
Hello, guys welcome to the next session on Linux command line tutorial. In this session, we will see how we can use File permissions in Linux.
And especially I'm going to talk about symbolic permissions.
So let's get started,
First of all, I'm going to change the directory to the desktop.
![]() |
Desktop |
And you can see here I have a file which has a name "file" itself.
So what I want to do is I want to list the long listing of this file. so I will just do "ls -l" and press ENTER.
![]() |
file permissions |
This thing here is the permission for the file.
Now the first minus (-) on the left-hand side you can see. It is the type of file.
If it's minus (-) it means it's a normal file.
If it would be "D" then it will be a directory.
If it would be a character special file then it would be a "C".
If it would be "B" then it would be a binary special file.
Owner / user permissions
![]() |
permission for owner |
The first three-element you can say here is for the owner of the file.
Group permissions
![]() |
permission for group |
The next three is for the group of the file.
Others/everyone's permissions
![]() |
permission for everyone |
And the last three is permission for everybody.
Symbolic Links
![]() |
symbolic links |
The next you can see here is "1" and this "1" stands for the symbolic links of the file. So right now I have only one link.
Name of the owner
![]() |
owner's name |
This name "root", which is the owner of the file.
Name of the group
![]() |
group name |
This is the name of the group.
Main permissions
So let's try to change the permission of the "file". There is a utility called "chmod" which stands for Change Mod to change the permission of the file.
There are 3 main kinds of permission,
- r - read
- w - write
- x - executable
change the permissions for everyone
![]() |
change permission for everyone |
$chmod o+yourPermission filename
I want to allow the other persons to execute this file.
So what I can do is I will just use "chmod" which is the utility to change the permission of the file.
"o" stands for others (or), everyone.
plus (+) or is for adding the permission.
minus (-) is for subtracting the permission.
Now I want to grant the executable permission to the other user.
So just say "chmod o+x file" and press ENTER. The permission is changed.
change the permission in the group
![]() |
Group's permissions |
$chmod g+yourPermission fileName
Now I want to change the permission of the "group".
I want to grant executable permission.
So I will use "chmod g+x file" and just press ENTER.
The "g" denotes group.
Reducing permission
![]() |
Remove permissions |
$chmod g-permissions fileName
Right now group can read, write and execute.
I want to make it just to read.
So I just say "chmod g-wx file" and press ENTER.
As I told you "g" is for the group.
Minus (-) is for reducing permission.
change or overwrite permission multiple users
![]() |
overwrite permissions |
$chmod ug=yourpermission fileName
For example, I want to give permission to the user and group of this file to read, write and execute.
You can use "chmod ug=rwx file" and press ENTER.
Instead of using the plus (+), you can also use equal to (=) for granting the permission.
By using equal to (=) you can overwrite the existing permissions.
Add or Remove all users permissions
![]() |
add or remove all permissions |
$chmod a-yourPermissions fileName
If you want to remove or change the permission to everybody.
For example, I want to remove the permission for the user, group and the others. So that they cannot even read-write or execute.
You just need to say "chmod a-rwx file" and press ENTER.
"a" stands for All. This means it stands for user, group and others.
conclusion
So this is how you can change the permission of a file using symbolic notation.
This is how you can change the permission.
I hope you've enjoyed this tutorial please rate comment and bye for now.
HAVE A NICE DAY💖