Day-5: Linux Special Permissions

Day-5: Linux Special Permissions

These are special file permissions in Linux used to control access and enhance security.

  1. SUID ( Set User Identification):

    When a file with SUID bit is executed, it runs with file’s owner permission instead of user’s permission who executed it.

    Example: Lets create a file name suidfile and lets check it’s permission.

    Now if we want to add SUID bit with suidfile, it can be done with following:

    chmod 4664 suidfile

    So when we have checked the permissions of suidfile, there is capital S in Owner’s permission which means there is no executable permissions. In order to give it executeable permission, we will use following:

    chmod 4764 suidfile

    So, Now SUID and executable permissions are set to the suidfile and whenever you see that small “s" in permission, that means both execute bit and SUID bit are set.

Another way to do is with command “u+s” as shown below:

  1. GUID (Group ID):

    When we set GUID on a file, it allows the execution of file with group’s owner permission.

    When it is set on directory, sub directories or new files will inherit it from parent director.

    Example: Lets create a file name sguidfile and lets check it’s permission.

    Now if we want to add GUID bit with sguidfile, it can be done with following:

    In order to give it executeable permission, we will use following:

    chmod 2674

    You can see that small “s" in permission, that means both execute bit and GUID bit are set.

    Another way to do this is with command “g+s” as shown below:

  1. Sticky Bit

    When sticky bit is set on a directory, only the file owner, directory owner, or superuser can delete or modify files within the directory.

    Example: We can use “+t” to add sticky bit

Files in stickybitdir can be deleted only by their owner or the superuser, even if others have write permissions.

Summary Table

PermissionSymbolFunctionTypical Usage
SUIDsRun file as the owner's privilegespasswd
GUIDsRun file with group privileges / Inherit group in dirsCollaborative directories
Sticky BittRestrict file deletion to owner/tmp

Thank you for reading and exploring Linux permissions with me! I hope this post was helpful, stay tuned for more insights in future articles!