Permissions
. Act to allow someone to do something.
. In Linux, permissions control who can access and
modify files and directories.
. Permission check command = ll & ls –ld
Tyes of permissions
1. Read (syntax=r)
2. Write (syntax=w)
3. Excute(syntax=x)
Commands
chmod
Syntax= chmod ugo (+-) rwx file/dir. Name (alphabetic method)
Example = chmod u+r file/dir. Name
chmod g+w admin (puting write permission on group)
chmod o+r admin (puting write permission on other)
chmod g+w-r admin
chmod u+r,g-w,o+r admin ( appling multiple permissions at once)
Numeric method
Syntax: chmod 777 dir./file name
. Full permission of the directory = 7
. Full permission of the file = 6
Example = chmod 635 admin
Change owner & group owner
Commands
. chown new owner name file/dir. Name (owner change)
Example = chown alexa admin
Change group owner
chgrp new groupname file/dir. Name
Example = chgrp harry manu
Change both at the same time:
Syntax: chown ownername:grupowner file/dir.
Example = chown alexa:harrry admin
Umask
In Linux, umask is a command and a variable that
controls the default file permissions for new files and
directories . When you create a file or directory, the
permissions set by the umask are applied by default.
Umask (0022) by defaults
Set umask command= umask 025 ( Temporary)
Setting a Parmanet Umask for a Particular user:
open .bashrc file and enter the umask
Setting the umask for every user: open vim
/etc/login.defs file and enter the umask
Special Permission
1. Acl
2. Suid
3. Sgid
4. Stickybit
Acl
ACL (Access Control List) in Linux is an extended permission system
that allows defining more precise and flexible permissions for specific
users or groups, in addition to traditional permissions (such as user,
group, and others) . It provides a more granular method for controlling
access to files and directories.
Commands
1.Syntax: setfacl optons u:username:permission file/dir
name ( for user)
Example: setfacl –m u:admin:rwx manu
2. setfacl –m g:harry:rw alexa (for group)
3.getfacl filename = file information
Example = getfacl mannu
4. setfacl –x g:groupname file/dir. Name (deleting a group
or user you added)
Example = setfacl -x g:harry alexa
setfacl -x u:admin mannu
5. setfacl -b file/dir. Name (it will delete all the users
and groups added)
Example = setfacl -b mannu
( note: + sign will apper in the permission)
Suid
When the SUID bit is set on an executable file, that file
runs with the owner’s privileges, no matter who executes
it
Syntax: chmod u+s filename(add suid)
Chmod u-s filename(remove suid)
(note: ‘s’ sign will apper in the owner permission)
Sgid
1. SGID on Executable Files
• When you set the SGID bit on an executable, anyone
running it temporarily assumes the permissions of
the file's group, instead of their own group.
2. SGID on Directories
• When applied to a directory, new files and
subdirectories inherit its group ownership,
regardless of the creator’s primary group.
Synatx: chmod g+s file/dir. Name
Example: chmod g+s manu
(note: ‘s’ sign will apper in the group permission)
Stickybit
Stop unwanted deletion
No one other than root, owner, director owner can delete
the files created in dirctory.
Synatx: chmod o+t dir. Name
Example = chmod o+t sinu
( note: ‘t’ sign will apper in the permission)
ll Command
ls –ld(view permission for only one dir. Or file)
chmod Command
chmod command ( numeric method)
Change Owenr & group Owner ( chown & chgrp
command)
Umask
vim .bashrc ( for a particular user)
vim /etc/login.defs ( set for every users)
ACL ( setfacl command ) (for a user)
setfacl ( for a group)
setfacl -x ( deleting group and user )
setfacl -b ( all deleting group & user)
Suid (will only be applied to executable files)
Sgid
Sticky bit
Complete
Permissions
THANK YOU