Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On all the Linux systems I've managed, the root account has a GID and UID of 0. Is this guaranteed, or is it possible that the system will give root a different ID?

share|improve this question
ID 0 has all the rights. The actual name (or names -multiple-) can differ. E.g. my server has two uid 0 users. One called 'root', one called 'toor'. – Hennes Aug 1 '13 at 19:20
up vote 45 down vote accepted

There are actually two parts to your question.

Does the superuser account always have uid/gid 0/0 on Linux?

Yes. As is pointed out by Rich Homolka in a comment, there's code in the kernel which explicitly checks for uid 0 when needing to check for the root user, which means that root always has at least uid 0.

Is the name of the user account with uid 0 always root?

No. root is just a name, listed in /etc/passwd or some other authentication store. You could just as well call the account admin, and the OS itself won't care, but some applications might not quite like it because they expect there to exist a privileged account named root. Calling the uid 0 account on a *nix root is a very strongly held convention, but it isn't required by the system.

It's also worth noting that, as pointed out by Simon Richter, on BSDs there often exists a second uid 0 account, by convention named toor (which is "root" spelled backwards). For example, FreeBSD uses it to provide a root user with a customized shell setting, leaving the root user with a default shell which is guaranteed to exist on the system's root partition (useful for recovery purposes).

share|improve this answer
Absolutely correct. – Tonny Aug 1 '13 at 19:21
There's code in the kernel to check for root, uid == 0. Yes, it's hard coded and permanent. – Rich Homolka Aug 1 '13 at 19:25
BSD typically has root and toor, both with UID 0. – Simon Richter Aug 2 '13 at 11:44
@SimonRichter In which case there exists a superuser account with the name root, so no issue there as long as the authentication store libraries don't get confused at the two users with the same UID (in which case the BSDs wouldn't do it that way, or the libraries would get fixed). – Michael Kjörling Aug 2 '13 at 11:46

1) the administrator is always uid == 0. This is coded in the kernel. It would take some coding in the kernel to change this. There's not much point to this, so it's not done. For example, it would be inconsistent for other unixes sharing the same NFS for example.

2) uid 0 does not necessarily map to root. The best example is FreeBSD. It has two uid == 0 accounts, the difference being the shell. root has shell /bin/sh, which is a simple shell, useful for when your disks are bad and you need fsck /usr. toor uses tcsh, which is much more useful in non-emergency situations,since it has things like history, etc.

Another, more personal example; one job I had where they had a root equiv (i.e. uid=0) account over NIS. The password, blank! Because the new sysadmin couldn't remember the root password on the machines. I yelled about this for obvious reasons (NIS passwords by definition can not hide their blankness). I was not happy about this account.

And it really isn't the system that gives uid 0 is root, it's you. You change this my using passwd files, or other naming directories (NIS, ldap) but it's not compiled in. Though you should have at least one uid 0 account in /etc/passwd, since you may not have networking when you really need it.

So root is always uid 0, but uid 0 is not necessarily always root.

share|improve this answer
Oof, the pain of choosing only one accepted answer... – Tanaki Aug 1 '13 at 22:28
@Tanaki Generally, "accept" the answer that helped you the most to answer your question, and upvote all the answers you found useful. There's nothing saying you have to accept the highest-voted or first-written answer. – Michael Kjörling Aug 2 '13 at 11:48

The UID is set a 0 for the Administrators UID typically and the GID can be set at 0 also. Either one of the two can have a different number, but in most cases the Admin account with Linux would be set at 0.

share|improve this answer
Welcome to Super User. The site is a knowledge base, and each answer is intended to add information that is substantially different from what has been contributed already. This answer doesn't really add anything to the in-depth discussions in the two previous answers. Just a heads up that it might attract downvotes on that basis. – fixer1234 May 18 at 21:27
This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill Jun 11 at 11:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.