Understanding file permission in Linux
Posted By : Vipul Pandey | 21-Sep-2018
Introduction:
This blog will help you with the permission management of the Linux as a user and handling with them effectively and efficiently. Linux stores the data in the filesystem so it is necessary to have the understanding of the file system and management correctly and changing according to our requirement.
Basic Permission File :
In the Linux, each and every file and directory is divided into 3 permission groups
Owner: The owner permission applies to the creator of the file or directory
Group: This permission is applicable to the group that has been given permission to the directory or file
User: This permission applies to all the users of the application.
How to view the permission
In the terminal or terminator(if installed) type
ls -l
Note: if you want to see all the commands of the Linux then you can simply type
man ls ,man whoami etc
The Linux permission shows the output in such a manner
-rw-rw-r-- 1 vipulpandey vipulpandey 16310280 Sep 13 12:04 filePermission.txt
drwxr-xr-x 3 vipulpandey vipulpandey 4096 Aug 28 2017 gradle
In the above
The first character is indicated as
directory or folder in Linux if d has prefixed it a drive.
The next following 3 set of character(
The r indicates read, w indicates write and x indicates execute permission.
Thisvipulpandey
Types of Permission in system
Each folder or file in Linux has 3 basic permission types
Read: This indicates who can read the content of the file
Write: This indicates users who have the permission to write in the file or change its content.
Execute: This permission is required to perform any execution any modification in the system.
Changing the permission or Changing the ownership
To change the permission in
in the above the file owner is
sudo chown ABC:vipulpandey fileName/directoryName
Binary values of permission:
The permissions of files are as
The binary values are written in form
r 4
w 2
x 1
The combined permission is the sum of the above binary values like to add read and write permission so we need to add the values of the above (read 4+write 2) =6
we can use
chmod + 444 file/folder
The three values are applicable for owner group and user.
to add read
permission only to the owner to any file
chmod + 400 file/folder
to add the same permission in character format
chmod +r file/folder
since there are 3 'r' permission in the command, so the first will be applicable to the owner only
to add the whole
permission to any file
chmod 777 file/folder or chmod +rwxrwxrwx
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vipul Pandey
Vipul Pandey is a good team-player & developing application on MEAN and java spring boot. Vipul loves to keep rotating fingers in his keyboard until he creates somethings inspiring.Hobbies are playing cricket ,swimming & photography.