SETUID(1)
π SETUID β bestie edition π
okay so this is the setuid page from the General Commands Manual β the local one, iykyk π
β¨ NAME β¨
setuid β run a command with a different uid π¦
πΈ SYNOPSIS πΈ
setuid username|uid command [ args ]
π DESCRIPTION π
So setuid changes the user id, and then it runs the command you told it to run. That's the whole vibe β¨
And like β unlike some versions of su(1), this program never asks you for a password when it's executed with effective uid=root. no cap, no prompt, nothing π
Another thing: it does not touch the environment. It only changes the uid, and then it uses execvp() to find the command in the path and execute it. periodt.
π little side note bestie: if the command is a script, thenexecvp()passes the command name to/bin/shfor processing. that's just how it goes π«
For example, this:
setuid some_user $SHELL
can be used to start a shell running as another user. slay π
setuid is genuinely so useful inside scripts that are being run by a setuid-root user β like a script invoked with super β so that the script can execute some commands using the uid of the original user, instead of root. the way that works is lowkey iconic π
That means unsafe commands (editors, pagers, the whole chaotic crew π) can be used in a non-root mode inside a super script. for example, an operator with permission to modify a certain protected_file could use a super command that simply does:
cp protected_file temp_file
setuid $ORIG_USER ${EDITOR:-/bin/vi} temp_file
cp temp_file protected_file
π WAIT. don't use this example directly. fr fr. If the temp_file can somehow be replaced by another user β as might be the case if it's kept in a temporary directory β then there will be a race condition in the time between editing the temporary file and copying it back to the protected file. that's a whole jumpscare, pls be careful π«Ά
β AUTHOR β
Will Deich π
and that's a wrap bestie π this page lives in the local section, it's SETUID(1) β go forth and change those uids responsibly, mwah π
β¨
π¦ where this page comes from
- debian bookworm: super 3.30.3-2+b1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- debian trixie: super 3.30.3-2+b2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu jammy: super 3.30.3-2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu noble: super 3.30.3-2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu questing: super 3.30.3-2.1
- ubuntu resolute: super 3.30.3-2.2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu stonking: super 3.30.3-2.2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- Copyright (c) 1995 by William Deich
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms