- Nikhil Bhaskar
- July 1, 2021
How to give file permissions on directories and regular files on Linux.
Linux is a multi-user operating system & can be accessed by many user.We can provide read ,write & execute permission to a file.There are 2 types of authorization levels.
Unix system have three types of owner:
- User: Who created the file & a user can create, delete, or modify the file.
- Group: All the users related to a group have same access permission for a file.
- Other: Any one who has access to the file other than user and group.Other have not a member of user or group.
Unix system have three types of permissions:
- Read (r) : we can only open and read the content of a file. But we can’t do any editing or modification in the file.
- Write (w) : we can only edit, remove or rename a file.
- Execute (x): we can run the file.
There are 2 type to use the command –
- Absolute mode
- Symbolic mode
|Number||Permission Type||Symbol binary|
|0||No Permission||— 000|
|3||Execute + Write||-wx 011|
|5||Read + Execute||r-x 101|
|6||Read +Write||rw- 110|
|7||Read + Write +Execute||rwx 111|
|+||Adds a permission to a file or directory|
|–||Removes the permission|
|=||Sets the permission|
The owners are represented as –
u : user/owner
chmod <groupName>+<permissionName> <fileName>
Give permission to execute is added to the user owner group.
chmod u+x file-name
Remove write & execute permissions from a user & group.
chmod u-w file-name & chmod g-x file-name
Give write permission for all the groups.
chmod a+w file-name or chmod +w file-name
Give read & write permission for others.
chmod o=rw file-name
Give permissions for all the three groups.
chmod u=rwx,g=rw,o=r file-name
Give Full permission to a folder
chmod 777 folder-name
chgrp group_name file-name
Leave a Reply
You must be logged in to post a comment.