The setuid
feature enables an executable to be run with the effective UID of the file owner. For example, a binary owned by root (passwd
) can be run by any user (so they can change their password). Normally, simply giving group-level execution rights isn’t enough. Because while you might be able to run passwd
, it will still fail when it tries to modify files not owned by the invoking user.
With setuid
, the running process will appear to be running as the file-owner (hence the term effective UID). This ensures that the program can indeed modify files also belonging to the owner. The best-case use for this (and probably most common) is for root
, when it wants to make binaries and services available to users like the change-password facility that also must make file-system changes to root
owned files.
Command
chmod 4<permissions> <filename>
(the 4
prefix means to apply setuid)