LINUX PERMISSIONS
Linux Standard File Permissions
Read r Read the file contents
Write w Write and modify contents
Execute x Execute the file if it is program file
If it is directory user can cd to the directory
Permission groups
1) Owners – for individual
2) Group owners – for group members
3) All others users – for those users who are not owner and not in
--- --- ----
rwx rwx rwx
user group others
Check permissions using
#ls –l
Change ownership of files
#chown <who> <what>
#chown user1 imax
#chown –R user1 Dir1
Change group ownership of files
#chgrp <group> <files>
#chgrp cisco datafile1.txt
Examples:
#groupadd Engg
#chgrp Engg file1.txt file2.txt
#chgrp –R Engg Dir1
Change permissions using Symbolic mode
#chmod <options> <permissions> <file name>
-R It stands for recursive
-V It stands for verbose
#chmod u+x filename
#chmod u+r,g+x filename
#chmod u-rx filename
#chmod a+x filename
#chmod u=rw,go=rw Demo.txt
#chmod o+w *.txt
Set write permission to user with Symbolic mode
#chmod u+w filename
#chmod u+w demofile1.txt
Change permission with numerical method
When we represent Linux permissions using numbers, it is called as
numeric mode. In numeric mode three digit value represents specific file
permissions like 777 , and these values are called as octal values.
First digit is for owner permission, second for group permission and third for
other users permission.
4 stands for "read",
2 stands for "write",
1 stands for "execute"
0 stands for "no permission"
Example
755
Owner : rwx = 4+2+1 = 7
Group : r-x = 4 + 1 = 5
Others: r-x = 4 + 1 = 5
Examples:
#chmod 777 filename
#chmod 755 filename
#chmod 644 filename
#chmod 750 filename
Set all permission to user only with Numerical mode
#chmod 700 filename
Set write permissions to group
#chmod g+w groupname
#chmod g+w userlist.txt
Remove permissions on files for others
#chmod o-rwx filename
#chmod o-rwx demofile
Find result of permissions
#ls -l