I have a feeling the
setuid bit, the
nosuid mount option,
su are all related given their names.
But how do they relate to one another?
Are some of them used in conjunction?
If they are not, then why are their names so similar?
setuid: (set user ID upon execution) is a Unix/Linux access rights flag that allow users to run an executable with the permissions of the executable's owner. It is needed for tasks that require higher privileges than those which common users have, such as changing their login password.
suid: (saved user ID) is used when a program running with elevated privileges needs to temporarily do some unprivileged work. It changes its effective user ID from a privileged value (typically root) to some unprivileged one.
nosuid. When mount use this option then the file system doesn't allow set-user-identifier (setuid) or set-group-identifier (setgid) bits to take effect.
sudo: executes a command as another user but only if the original user is allowed to do it. (the user must be allowed previously in /etc/sudoers). It asks the user for their own password, making possible to authorize users to do tasks allowed only to root without revealing root's password.
su: This command allows the user to run a (new) shell / program as another user. The most common use of su is to become root. It asks for the password of the user you want to be, so only knowing that password it accepts the user substitution.
"set user ID" is an important permission feature.
su (and many other programs including
mount) need this feature to work; some programs work partly without this feature (like
mount), others (like
su) do not work at all. This feature is related to files. Files exist in file systems only.
nosuid disables this feature for all files in a file system (which makes especially sense for removable media).