frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: Does root have to be uid 0? Does uid 0 have to be root?

4•axismundi•15h ago
what's so special about root/0?

Comments

gryfft•14h ago
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...

RiverCrochet•14h ago
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:

    LOAD_ACCUMULATOR uid_value
    BRANCH_IF_EQUAL somewhere
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).

If you want to test if a value is something other than zero, then you have to do this:

    LOAD_ACCUMULATOR uid_value
    COMPARE_ACCUMULATOR something
    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.

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.

atsaloli•7h ago
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.

Alternatives to HN for "tech outside of AI" discussion?

17•summonerOS•4h ago•6 comments

Tell HN: Google banned Railway's account. Everything down

23•sergiotapia•7h ago•12 comments

Hiring | AI Automation Engineer | Remote

3•saganrec•2h ago•1 comments

Ask HN: How does everyone talk about their work when they've used AI?

3•deku2099•3h ago•2 comments

Ask HN: How to manage AI APIs for SaaS application?

3•sbinnee•3h ago•1 comments

Ask HN: What are Stainless users doing now that Anthropic has killed it?

5•ubutler•3h ago•1 comments

Anthropic is killing stainless, so we built our own SDK/MCP generator

4•iiviie•9h ago•1 comments

Ask HN: How to be SOC2 Type 2 compliant as a solo-entreprenuer?

172•sochix•5d ago•136 comments

Ask HN: Does root have to be uid 0? Does uid 0 have to be root?

4•axismundi•15h ago•3 comments

Ask HN: Antigravity 2.0 installer breaks existing Antigravity IDEs

3•jdw64•10h ago•1 comments

Ask HN: Is grpcurl home page compromised?

4•jicea•11h ago•0 comments

Did moving to new place have intended effect?

9•Jeff2Serve•19h ago•9 comments

Ask HN: How do word docs, slides, excel, and PDFs generate value?

4•FailMore•14h ago•6 comments

Ask HN: Go all in on startup idea, or stay W2

2•Mnexium•17h ago•17 comments

Ask HN: How often do you code the expected way instead of a better one?

4•recycling•19h ago•4 comments

Windows on Mobile Screen

2•tukunjil•20h ago•0 comments

Ask HN: How to enforce engineers to understand the code they are shipping

8•hchua•22h ago•17 comments

Ask HN: How are agentic workflows meant to offset AI debt?

2•l33tbro•10h ago•0 comments

Ask HN: When did computers stop being fun?

73•klez•3d ago•102 comments

Tell HN: Dont use Claude Design, lost access to my projects after unsubscribing

299•pycassa•6d ago•85 comments

Ask HN: Do you know what data your AI coding agent sends to the cloud?

5•lbrauer•1d ago•6 comments

Tell HN: Mindie.dev is scraping emails from profiles to send spam

27•stackghost•3d ago•6 comments

Ask HN: Company is rapidly cutting AI tool spend how to prep team?

8•Snakes3727•1d ago•11 comments

Ask HN: Could free/low cost LLMs be a momentary thing?

5•senda•1d ago•11 comments

SlothDB is an OLAP DB ahead of DuckDB on Clickbench SQL database in C++20

6•souravroy78•2d ago•4 comments

Viable open source Claude Design alternative?

26•splatzone•5d ago•7 comments

Ask HN: What LLM models are you using and why?

10•rubyn00bie•3d ago•13 comments

Which country will be the first to pass laws limiting Meta Ray-Ban glasses?

30•nothrowaways•5d ago•10 comments

You've reached the end!