SPECIAL PERMISSION ON FILE AND FOLDER:
What
is special file permission?
Three special types of permissions are
available for executable files and public directories. When these permissions
are set, any user who runs that executable file assumes the user ID of the
owner (or group) of the executable file. Thats are following:
I.
SUID (setuid)
II.
SGID (setgid)
III.
Sticky Bit
With the help of “chmod”command we can implement the special permissions on
file and directories.
SUID:
What is SUID (Set Owner User ID)?
When set-user identification (setuid) permission is set on an executable file, it is executed with the file owner’s permissions
(rather than with the permissions of the user who executes it).
For example, the setuid permission on the passwd command makes it possible
for a user to change passwords, assuming the permissions of the root ID:
-r-sr-sr-w 3 root
sys 107680 dec 18 01:02
/usr/bin/passwd
Use chmod command to set
SUID on anshuman.txt:
#chmod
u+s anshuman.txt
How can I check if a file is
set with SUID?
#ls
-l
total 8
-rwsr–r– 1 sara mary 148 Dec 18 03:46 anshuman.txt
total 8
-rwsr–r– 1 sara mary 148 Dec 18 03:46 anshuman.txt
How can I find all the SUID set files in Linux?
# find / -perm +4000
SGID:
What is SGID (Set Group ID)?
SGID is similar to SUID. The difference
between both is that SUID assumes owner of the file permissions and SGID
assumes group’s permissions when executing a file instead of logged in user
inherit permissions.
Use chmod command to set SGID
on anshuman.txt:
#chmod g+s anshuman.txt
How can I check if a file is
set with SGID?
#ls –l
total 8
-rwxr-sr-- 1 sara marry 148 Dec 18 03:46 anshuman.txt
How can I find all the SGID
set files in Linux?
#find / -perm +2000
STICKY BIT:
What Is Sticky bit?
Sticky Bit is
mainly used on folders in order to avoid deletion of a folder and its content
by other users though they having write permissions on the folder contents. if the directory has the sticky bit set, a file can be
deleted only by the owner of the file, the owner of the directory, or by root.
Use chmod command to set Sticky
bit on a folder named /secret:
#chmod +t /secret
How to check a folder is set with Sticky Bit?
#ls -l
total 8
-rwxr-xrwt 1 sara marry 148 Dec 18 03:46 /secret
How
can I find all the Sticky Bit set files in Linux?
#find / -perm +1000
No comments:
Post a Comment