Why can I create Users with the same UID?
There are actually valid reasons for this. For instance, I used to work in a lab where we each had our own computer but our $HOME
was in a shared drive exported by a server. So, my $HOME
was
/users/terdon
Since the /users
folder was actually not on my local machine but exported over NFS, for any analysis that was heavy on I/O, I would use data stored on my local hard drives so as not to burden the lab's network. To that end I, and everybody else, had two users: one that was system-wide and one that was local to the machine in question. The local user's home was
/home/localuser
However, I needed to have full access to my files whether I was logged in as terdon
or as localuser
and the way our sysadmin had implemented that was by giving both localuser
and terdon
the same UID. That way, I could freely manipulate my local files irrespective of which user I was currently logged in as.
The answer here is that Linux does not protect you from yourself.
If you really want to su root
and go into the /etc files and give all the users the same UID, you can. It's just a text file.
But you really shouldn't and it will have unintended consequences.
Two users can have the same UID because it is just a number in a text file so you can set it to anything you want, including a value that is already used. As you have seen though, doing so is not a good idea.