Difference Between User Id Group Id and Sticky Bit

Only the root and Owner of the file can delete that file.
Apart from other user can't delete that file
$rm vidoeuser
rm: remove write-protected regular empty file `vidoeuser'? y
rm: cannot remove `vidoeuser': Operation not permitted

Syntax For Setting The Sticky Bit
Chmod +t filename/directory name
# chmod 1755 stickbit.txt
# ll stickbit.txt
-rwxr-xr-t1 root root 0 Sep 14 20:16 stickbit.txt
t, T symbol  we can confirm that file or directory is set by the Sticky Bit.
t-directory T-file

setuid: chmod 4000 #find / -perm -4000 # process run the user based on owner of a file
setgid: chmod 2000 we can find setgid value by find / -perm -2000 #process run if its member of the same group
sticky bit : chmod 1777

Difference Between SetUID and SetGID in ls -l Command
User ID
Set USER ID (SUID)
Set GROUP ID (SGID)
#chmod 4000 file_name (or)
#chmod u+s file_name
#chmod 2000 Directory_name
#chmod g+s Directory_name
# ll /usr/bin/passwd
-rwsr-xr-x 1 root root 27936 Aug 11 2010 /usr/bin/passwd
# ls -l / | grep share
drwxrwsrwx   4 root john  4096 Aug 22 06:05 share
Execute the Userid(UID) of the File
Instead of Uid of Current user.
Execute the groupid (GID) of file/directory
Instead of gid of current Group.
Example: Standard user run  passwd command. system it will run as root Privilege to update /etc/passwd & /etc/shadow file l
Because owner of this file /usr/bin/passwd is root & has UID.
Example : #chgrp g+s /share
owner of the group is john
#touch /share/file1
# ll /share/file1
-rw-r--r-- 1 root john 0 Oct 12 15:02 /share/file1
so whenever we create the file under the share directory it maintain the permission (owner of the group) is  john even root(or) other standard user is creating the file.

0 comments: