Ask HN: Does root have to be uid 0? Does uid 0 have to be root?
what's so special about root/0? You can have multiple user accounts with UID 0. They will all be priveleged superusers. Back in umpteen-umpty-umph, we used to have multiple accounts like that for different departments each with their own password. So you could track use of superuser accounts by department for some degree of accountability. This was on Solaris 2.something but I don't see why it wouldn't work like that on other UNIX systems. It's the UID of 0 that makes an account a superuser, not the username. My theory: UNIX was developed originally on a DEC PDP-7. I'm not a PDP-7 assembly language expert but there's many instructions that take action if the accumulator is 0. So if a specific UID value has to be special, it's probably easiest and fastest for that value to be 0. https://dn710100.ca.archive.org/0/items/bitsavers_decpdp7PDP... For newer CPUs, though (which I am familar with): Many other CPU architectures have a "Z flag." This is a bit in a status register that's set if the last value encountered is a zero. So you can do something like this: If you want to test if a value is something other than zero, then you have to do this: So it takes more instructions on many CPU architectures if the special value is not zero. This isn't limited to root being UID zero, it's also why "end of string" is zero and zero is a sentinel value in general. The short answer is that it's a very, very longstanding convention that would be a nightmare to change and wouldn't provide any benefits. It's hardcoded into the kernel and who knows what other programs will always assume UID 0 -> root. There's some further reading on Stack Exchange. [1] 1. https://superuser.com/questions/626843/does-the-root-account...
The BRANCH_IF_EQUAL instruction (actually BEQ in a few instruction sets) typically branches if that Z flag in the status register is zero. Some instructions on some CPUs reference the Z flag for what it is directly, like DJNZ on Z80 and I think x86 (Decrement and Jump if Not Zero). LOAD_ACCUMULATOR uid_value
BRANCH_IF_EQUAL somewhere
The COMPARE_ACCUMULATOR instruction (actually CMP in 6502 and similar in other instruction sets) subtracts "something" from the current value of the accumulator, but doesn't save the result, BUT sets the flags, including that important Z flag. LOAD_ACCUMULATOR uid_value
COMPARE_ACCUMULATOR something
BRANCH_IF_EQUAL somewhere