top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of setuid bit in Linux?

+3 votes
278 views
What is the use of setuid bit in Linux?
posted Nov 12, 2013 by Sheetal Chauhan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

SUID (Set owner User ID up on execution) is a special type of file permissions given to a file. Normally in Linux/Unix when a program runs, it inherits access permissions from the logged in user. SUID is defined as giving temporary permissions to a user to run a program/file with the permissions of the file owner rather that the user who runs it. In simple words users will get file owner’s permissions as well as owner UID and GID when executing a file/program/command.

It can be applied in the following way

chmod u+s file.txt

Here owner permission execute bit is set to SUID with +s

or

 chmod 4750 file1.txt

Here in 4750, four indicates SUID bit set, seven for full permissions for owner, five for read and execute permissions for group, and no permissions for others.

Example: passwd command
When we try to change our password we will use passwd command, which is owned by root. This passwd command file will try to edit some system config files such as /etc/passwd, /etc/shadow etc when we try to change our password. Some of these files cannot be opened or viewed by normal user only root user will have permissions. So if we try to remove SUID and give full permissions to this passwd command file it cannot open other files such as /etc/shadow file to update the changes and we will get permission denied error or some other error when tried to execute passwd command. So passwd command is set with SUID to give root user permissions to normal user so that it can update /etc/shadow and other files.

answer Nov 12, 2013 by Luv Kumar
Similar Questions
+2 votes

I am confused with all 32/64 bit architecture for Hardware/OS/Binary, Can someone please help in clarifying this queries?

  1. Of'course 64 bit hardware is faster than 32 bit, still there are people who prefer 32 bit over 64 bit hardware, Why so?
  2. If I have 32 bit Hardware then On that can I run 64 bit OS? (and vice versa)
  3. If I have a 64 bit Hardware and 32 bit OS then what will be the speed of my OS, as per 32 bit or as per 64 bit? (and vice versa)
  4. If I have 32 bit OS then can I run binary of 64 bit on that? (and vice versa)
  5. Is it necessary to compile binary with 32/64 bit both or we can compile with any and use it in both?
  6. Is the speed of the process also depends on type of binary that I have? For example, If I have 64 bit hardware and 64 bit OS but I have a binary which is compiled with 32 bit compiler then what will be the speed difference?

P.S. I know its basic and silly queries but lets clear now before it gets too late. :)

0 votes

I came under a term "address space layout randomization" ? What is the meaning of it ?

Can any one give any example on it how it works and what happens in this feature ?

+7 votes

What is the difference in behavior between mutex in linux and mutex in VxWorks ??

...