Please compare the following two lines:

-rws---r-x 1 root root 21872 2009-10-13 21:06 prg1 

-rwx---r-x 1 root root 21872 2009-10-13 21:06 prg2 

Does the setuid bit on prg1, along with the read and execute bits for 'other' mean that any user can run it with root privileges? The prg2 also has read and execute for 'other', but does not have the setuid bit set, so does that mean it can still be run by any user but without root privileges?


2 Answers 2


That is the "setuid" bit, which tells the OS to execute that program with the userid of its owner. This is typically used with files owned by root to allow normal users to execute them as root with no external tools (such as sudo).

You can set the suid bit using chmod, eg chmod 4755 which will give a file give the normal permissions 755 does (rwxr-xr-x) and add the suid bit to give rwsr-xr-x

You can clear the setuid bit by issuing a normal chmod command with a 0 prepended to it. For example, to set permissions back to rwxr-xr-x you would use chmod 0755.

  • 10
    "chmod preserves a directory's set-user-ID and set-group-ID bits unless you explicitly specify otherwise. You can set or clear the bits with symbolic modes like u+s and g-s, and you can set (but not clear) the bits with a numeric mode." - GNU coreutils 8.22 Feb '16
    – Patrick M
    Mar 13, 2018 at 15:57

Precisely the opposite, you don't need to use sudo or switch to root, the executable does it for you.

  • 1
    OK thanks for the reply. So in other words the prg1 will always run as root while prg2 will not?
    – anders
    Mar 9, 2014 at 15:43
  • 3
    Yes. If setuid bit is set, it executes with ITS owner's permissions (usually root's), no matter who calls it. A good example is mount command. It does check who you are, but it CAN mount stuff if fstab says you can.
    – orion
    Mar 9, 2014 at 15:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.