What is a SUID?

Set owner User ID upon execution (SUID) is a special type of permission that is given to a file/program in Linux.


What is its Purpose?

In some cases, a user needs to write/execute a file/program which is owned by another user. In such cases, a SUID bit is set on that file/program which gives temporary permission to write/execute that particular file/program.


How to find whether a file has SUID permission?

To check whether a file/program has SUID permission, us the command ls -l <file_name> to see the file/program permissions.

If the file permission of a file/program has the letter s i.e., like this one: -rwsrXXXXX , then it has SUID permissions.

<aside> đź’ˇ Note:

The following letters “-rwsrXXXXX” is the symbolic representation of file permissions which refers to the following permissions:

r : read

w : write

s : SUID with Executable permission

S : SUID without Executable permission

</aside>

For example, take a look at the /etc/passwd file:

Untitled

The /etc/passwd file doesn’t have SUID permission, since it doesn’t have the s letter.

Now take a look at the /usr/bin/passwd file, It has SUID permission, since it has the letter s in its permissions and the file is highlighted in red [ it may or may not be highlighted in your terminal, it completely depends on the shell you are using ].

Untitled


A Practical Scenario where SUID is used

Let’s take the file /usr/bin/passwrd for this example.

Untitled