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

Enabling SUID in script

[zolan@sector19]$chmod u+s

Enabling SGIDin script

[zolan@sector19]$chmod g+s

Enabling sticky bit  in script

[zolan@sector19]$chmod +t

Enabling all bits  in script

[zolan@sector19]$chmod ug+ts
BIT Permission
1 Sticky Bit

Managing permission with numeric values. 

Enabling SUID in script

[zolan@sector19]$chmod 4755

Enabling SGIDin script

[zolan@sector19]$chmod 2755

Enabling sticky bit  in script

[zolan@sector19]$chmod 1755

Enabling all bits  in script

[zolan@sector19]$chmod 7755

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