File Permissions In Linux
Just like every operating system, Linux comes with a set of permissions that it uses to protect files, directories and devices on the system.
These permissions can be manipulated to allow (or) disallow access to files and directories on different parts of the system.
Basic file permissions
Let’s look at how permissions work first. Linux permissions are implemented through the properties of files and defined by three separate categories.
User: The person who owns the file.
Group: The group that owns the file.
Other: All other users on the system.
Permissions in Linux can be assigned one of two ways. You can use the mnemonic or a single digit to represent the permission level.
|Read||r||4||View file contents.|
|Write||w||2||Write to or change.|
|Execute||x||1||Run the file.|
Default file permissions
Umask: Universal mask is a default value that always gets dedicated from maximum file permission allocated for every file & directory.
For super user umask value is # 022.
For Normal user, umask value is $002
Maximum permission of a file 666-Umask (-)022
Default file permission ------> 644
Maximum permission of a directory 777-Umask (-)022
Default directory permission 755
Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training
For Normal user:
Maximum permission of a file ---- 666----Umask (-)_002---664
Maximum permission of a directory---777 umask---002 (-)775
To see the umask # umask
To change the umask # umask 222
To view umask value from the fiel # vim /etc/ bashrc
+ --->To add a permission.
- --->To remove permission.
= --->To override the permission.
Here are some of the commands you can use to work with permissions:
Chmod:- It is used to change the permission of a file and directory. It can be used by the owner of the file (or) by root.
Syn: Chmod [options] [permission] [file]
R ---> Acts recursively.
V ---> Provides verbose output.
1) # Chmod u+rw,g+r, o+x linux # Chmod 641 linux
2) #chmod ugo =rw backup (or) # chmod 666 backup
3) #chmod U-W, g-r, o-x linux
4) #chmod-R U+W, g+r, o+x linux
5) #chmod-R 777 unix
6) # chmod 755 Unix
Chgrp: à By using this command we can change group of the file.
Syn: Chgrp [options] [group name] [file]
R ---> Recursively
V ---> Verbose
Ex: #ls-l linux #chgrp sales linux
Chown: This command is used to we can change the owner of the file, as well as owner & group at a time.
Syn: Chown [options] [user:group] [file]
#Chown Raju Linux To Change the only owner.
#Chown Raju: sales Linux To Change owner & group
#Chown –R Ramu: colour Unix Recursively to change.
To view the symbolic as well as a numeric mode of permission
# stat Linux
To change the permissions in GUI mode
Assign the permissions in GUI mode:
Right-click on file ----->properties---->permissions.
For an in-depth understanding of Linux click on