Main menu

SUID and SGID in Linux

What is SUID and SGID in Linux :By default when a user execute some script system inharit it’s permission from his account id or UID. If user don’t have access permission on it he will be denied.

SUID (Set User ID) is a permission can be assign to a file or directory. If this permission is enabled other user can execute that file with it’s owner permission without login into his account.

SGID (Set Group ID) is similar like SUID unlike SUID inherit the permission from owner user SGID inhait it from Group. $chmod u+s myscript.sh

Enabling SUID in myscript.sh script

[zolan@sector19]$chmod u+s myscript.sh

Enabling SGIDin myscript.sh script

[zolan@sector19]$chmod g+s myscript.sh

Enabling sticky bit  in myscript.sh script

[zolan@sector19]$chmod +t myscript.sh

Enabling all bits  in myscript.sh script

[zolan@sector19]$chmod ug+ts myscript.sh
BIT Permission
4 SUID
2 SGID
1 Sticky Bit

Managing permission with numeric values. 

Enabling SUID in myscript.sh script

[zolan@sector19]$chmod 4755 myscript.sh

Enabling SGIDin myscript.sh script

[zolan@sector19]$chmod 2755 myscript.sh

Enabling sticky bit  in myscript.sh script

[zolan@sector19]$chmod 1755 myscript.sh

Enabling all bits  in myscript.sh script

[zolan@sector19]$chmod 7755 myscript.sh

Note: SUID and SGID can be generous on production environment.

FacebookTwitterGoogle+RSS