Why can I create Users with the same UID?
My understanding of UIDs is that is a unique positive integer assigned by a Unix-like operating system to each user. Each user is identified to the system by its UID, and user names are generally used only as an interface for humans.
How can two users have the same UID, isn't this a conflict for my system and packages?
root@kdc:~# id test12
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~# id test13
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~#
I've added two users with same UID and GID: test12 and test13
The output of /etc/passwd:
client@kdc:~$ cat /etc/passwd | grep test12
test12:x:1005:1000::/home/test12:/bin/sh
client@kdc:~$ cat /etc/passwd | grep test13
test13:x:1005:1000::/home/test13:/bin/sh
I added the users by useradd -ou 1005 -g1000 username.
I got confused what is the purpose of this, and can it affect permissions and user logs etc. So now if a user is added with uid=0 and gid=0 will has privileges like a root account?
user-management
|
show 1 more comment
My understanding of UIDs is that is a unique positive integer assigned by a Unix-like operating system to each user. Each user is identified to the system by its UID, and user names are generally used only as an interface for humans.
How can two users have the same UID, isn't this a conflict for my system and packages?
root@kdc:~# id test12
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~# id test13
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~#
I've added two users with same UID and GID: test12 and test13
The output of /etc/passwd:
client@kdc:~$ cat /etc/passwd | grep test12
test12:x:1005:1000::/home/test12:/bin/sh
client@kdc:~$ cat /etc/passwd | grep test13
test13:x:1005:1000::/home/test13:/bin/sh
I added the users by useradd -ou 1005 -g1000 username.
I got confused what is the purpose of this, and can it affect permissions and user logs etc. So now if a user is added with uid=0 and gid=0 will has privileges like a root account?
user-management
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56
|
show 1 more comment
My understanding of UIDs is that is a unique positive integer assigned by a Unix-like operating system to each user. Each user is identified to the system by its UID, and user names are generally used only as an interface for humans.
How can two users have the same UID, isn't this a conflict for my system and packages?
root@kdc:~# id test12
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~# id test13
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~#
I've added two users with same UID and GID: test12 and test13
The output of /etc/passwd:
client@kdc:~$ cat /etc/passwd | grep test12
test12:x:1005:1000::/home/test12:/bin/sh
client@kdc:~$ cat /etc/passwd | grep test13
test13:x:1005:1000::/home/test13:/bin/sh
I added the users by useradd -ou 1005 -g1000 username.
I got confused what is the purpose of this, and can it affect permissions and user logs etc. So now if a user is added with uid=0 and gid=0 will has privileges like a root account?
user-management
My understanding of UIDs is that is a unique positive integer assigned by a Unix-like operating system to each user. Each user is identified to the system by its UID, and user names are generally used only as an interface for humans.
How can two users have the same UID, isn't this a conflict for my system and packages?
root@kdc:~# id test12
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~# id test13
uid=1005(test10) gid=1000(server) groups=1005(test10)
root@kdc:~#
I've added two users with same UID and GID: test12 and test13
The output of /etc/passwd:
client@kdc:~$ cat /etc/passwd | grep test12
test12:x:1005:1000::/home/test12:/bin/sh
client@kdc:~$ cat /etc/passwd | grep test13
test13:x:1005:1000::/home/test13:/bin/sh
I added the users by useradd -ou 1005 -g1000 username.
I got confused what is the purpose of this, and can it affect permissions and user logs etc. So now if a user is added with uid=0 and gid=0 will has privileges like a root account?
user-management
user-management
edited Mar 3 '14 at 20:06
nux
asked Feb 27 '14 at 15:36
nuxnux
22.8k2995117
22.8k2995117
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56
|
show 1 more comment
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56
|
show 1 more comment
9 Answers
9
active
oldest
votes
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.
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
Right, and by usinguseradd -oyou recognize that you're outside of the normadduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.
– Digital Chris
Feb 27 '14 at 16:44
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
|
show 5 more comments
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.
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn'tchmod 666have the same affects?
– Brian
Feb 28 '14 at 19:49
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
add a comment |
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.
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
add a comment |
Unix systems & Linux generally do nothing to prohibit duplicates in the /etc/passwd file. The intent of this file is to associate a UID with a physical name that can be display by command line tools such as ls when user's are listing out files.
$ ls -n | head -5
total 986000
drwxrwxr-x. 3 1000 1000 4096 Feb 13 19:51 1_archive_sansa
-rw-rw-r--. 1 1000 1000 760868 Dec 16 08:21 2.18.x Database Scheme.jpg
-rw-rw-r--. 1 1000 1000 972 Oct 6 20:26 abcdefg
drwxrwxr-x. 2 1000 1000 4096 Feb 11 03:34 advanced_linux_programming
The other intended purpose of this file is to specify what shell a user will get when they login.
$ getent passwd saml
saml:x:1000:1000:saml:/home/saml:/bin/bash
A common attack vector on Unix type systems is to add lines such as these to a system's /etc/passwd file:
$ getent passwd r00t
r00t:x:0:0:root:/root:/bin/bash
$ getent passwd toor
toor:x:0:0:root:/root:/bin/bash
The role of the /etc/passwd file is NOT meant to solely track user accounts. The role of tracking username's and passwords is the responsibility of the /etc/shadow file. Files such as /etc/passwd and /etc/group are really meant to provide a human readable name when your system is listing files from disks.
Remember that your files are written to the disk using UID/GID's not actual names.
$ stat afile
File: ‘afile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 6560621 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-27 15:54:21.852697029 -0500
Modify: 2014-02-27 15:54:21.852697029 -0500
Change: 2014-02-27 15:54:21.852697029 -0500
Birth: -
Notice the Uid: and Gid:, the numbers are what's actually written to the disk!
add a comment |
It's actually fairly common to have two users with the same ID. On FreeBSD, there are usually two users with UID 0: root and toor. Root uses the built-in /bin/sh shell, and toor uses a different shell, usually bash.
add a comment |
In Linux, all users and groups are actually just numbers. That's what the output of the id command you posted shows.
The /etc/passwd file maps user names to user IDs (numbers) and in the example you have provide, you've simply mapped two usernames to the same user ID.
Effectively, you've created one user, test12, ID 1005, who also has a second username test13. However the system will map UID 1005 to the first username it finds, which would be test12
Linux "lets" you do this because there's no system to prevent you from doing this. /etc/passwd is just a text file, usernames are mapped to the UID found for their entry in that file, UIDs are mapped to the first username found in that file.
But what you've created is a confusing situation for other systams administrators; avoid it by changing the UID of test13
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the/etc/passwdfile. But there's no means in place to prevent you from doing this. Does that make sense?
– Josh
Feb 27 '14 at 17:01
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
|
show 1 more comment
The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of ! (because ! was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls could could map user-id => name. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser addgroup, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd and groupadd were introduced, which kept shadow and shadow- updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.
add a comment |
The /etc/passwd file just maps symbolic usernames to the real userID. If you deliberately make two symbolic names that map to one userID then it will let you.
That doesn't mean it is a good idea to actually do it. Some people may have found very specific usage cases where they can take advantage of this feature, but in general you should not do it.
Linux (and other UNIXes) take the opinion that the administrator knows what they are doing. If you tell it to do something stupid then that's your own fault, in much the same way that if you tell your car to drive over a cliff you can't go to the manufacturers and ask why the car allowed you to do this.
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
add a comment |
There are identifiers that the operating system expects to be unique, but they are used for tracking hardware. The knowledge that a particular Universally Unique IDentifier corresponds to a hard drive containing system files may help it to continue operating if the hardware configuration changes. Microsoft calls these Globally Unique IDentifiers and uses them to track all Windows software. Ironically, these acronyms were poorly chosen.
From the perspective of the OS, most user and group identifier changes amount to changing its outside interface. It could function normally despite collisions; mainly what is required of the system users and groups is that they exist. It cannot know what the users require. In situations like this, the Unix philosophy is that the OS should assume the administrators know what they are doing, and should help them do it quickly.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f427107%2fwhy-can-i-create-users-with-the-same-uid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
Right, and by usinguseradd -oyou recognize that you're outside of the normadduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.
– Digital Chris
Feb 27 '14 at 16:44
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
|
show 5 more comments
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.
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
Right, and by usinguseradd -oyou recognize that you're outside of the normadduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.
– Digital Chris
Feb 27 '14 at 16:44
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
|
show 5 more comments
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.
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.
answered Feb 27 '14 at 15:47
Digital ChrisDigital Chris
593410
593410
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
Right, and by usinguseradd -oyou recognize that you're outside of the normadduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.
– Digital Chris
Feb 27 '14 at 16:44
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
|
show 5 more comments
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
Right, and by usinguseradd -oyou recognize that you're outside of the normadduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.
– Digital Chris
Feb 27 '14 at 16:44
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
3
3
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
my question is why the system accept this ?
– nux
Feb 27 '14 at 16:28
46
46
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
What do you mean "accept" it? How would it NOT accept it? this is like being a chef and asking why the soup allowed you to put too much salt in it. In terms of modern computing, you're probably used to an RDBMS mentality, where contraints on important things like IDs keep you from shooting yourself in the foot. Linux user IDs are much more primitive and have no internal checking or correction.
– Digital Chris
Feb 27 '14 at 16:32
5
5
Right, and by using
useradd -o you recognize that you're outside of the norm adduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.– Digital Chris
Feb 27 '14 at 16:44
Right, and by using
useradd -o you recognize that you're outside of the norm adduser. As @psusi mentioned, it creates two logins pointing to the same ID as far as file permissions etc. It probably also creates issues since that is not a normal use case and is no doubt untested with lots of packages.– Digital Chris
Feb 27 '14 at 16:44
2
2
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
Answer: to have 2 logins point to identical filesystem permissions.
– Digital Chris
Feb 27 '14 at 16:50
5
5
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
@Josh of course it is, there are valid reasons to have multiple users with the same UID, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:01
|
show 5 more comments
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.
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn'tchmod 666have the same affects?
– Brian
Feb 28 '14 at 19:49
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
add a comment |
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.
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn'tchmod 666have the same affects?
– Brian
Feb 28 '14 at 19:49
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
add a comment |
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.
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.
edited Feb 28 '14 at 4:08
answered Feb 27 '14 at 22:56
terdon♦terdon
66.4k12138221
66.4k12138221
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn'tchmod 666have the same affects?
– Brian
Feb 28 '14 at 19:49
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
add a comment |
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn'tchmod 666have the same affects?
– Brian
Feb 28 '14 at 19:49
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
6
6
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
In support of this answer, it's worth noting that some setups such as virtual email hosting use this to great effect, i.e. a great number of virtual email accounts sharing a single UID - the documentation for the Dovecot mail server actually suggests this as an optional approach at wiki2.dovecot.org/UserIds#mailusers
– Matt Thomason
Feb 28 '14 at 1:58
wouldn't
chmod 666 have the same affects?– Brian
Feb 28 '14 at 19:49
wouldn't
chmod 666 have the same affects?– Brian
Feb 28 '14 at 19:49
3
3
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
@GIJoe that would allow both users to read/write but it wouldn't preserve ownership which could be a problem. Also, not all files can be set to those permissions (ssh keys for example) and it is not practical to need to play with permissions all the time.
– terdon♦
Mar 1 '14 at 8:07
add a comment |
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.
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
add a comment |
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.
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
add a comment |
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.
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.
answered Feb 27 '14 at 15:45
psusipsusi
31.3k15089
31.3k15089
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
add a comment |
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
how the system deal with users then ? sharing permissions
– nux
Feb 27 '14 at 15:47
12
12
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
@nux, they are both the same user. They can just have a different username/password for the purpose of logging in.
– psusi
Feb 27 '14 at 15:48
4
4
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
@bigbadonk420, the term "supported" is rather nebulous. It certainly is something you have always been able to do on unix systems and it used to be a fairly common backdoor to set up another user that has uid 0 so you can log in and effectively be root, without needing to know or change the password on the normal root user.
– psusi
Feb 27 '14 at 18:13
1
1
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
@bigbadonk420 it is supported, there are cases where this is useful, see my answer for one example.
– terdon♦
Feb 27 '14 at 23:02
add a comment |
Unix systems & Linux generally do nothing to prohibit duplicates in the /etc/passwd file. The intent of this file is to associate a UID with a physical name that can be display by command line tools such as ls when user's are listing out files.
$ ls -n | head -5
total 986000
drwxrwxr-x. 3 1000 1000 4096 Feb 13 19:51 1_archive_sansa
-rw-rw-r--. 1 1000 1000 760868 Dec 16 08:21 2.18.x Database Scheme.jpg
-rw-rw-r--. 1 1000 1000 972 Oct 6 20:26 abcdefg
drwxrwxr-x. 2 1000 1000 4096 Feb 11 03:34 advanced_linux_programming
The other intended purpose of this file is to specify what shell a user will get when they login.
$ getent passwd saml
saml:x:1000:1000:saml:/home/saml:/bin/bash
A common attack vector on Unix type systems is to add lines such as these to a system's /etc/passwd file:
$ getent passwd r00t
r00t:x:0:0:root:/root:/bin/bash
$ getent passwd toor
toor:x:0:0:root:/root:/bin/bash
The role of the /etc/passwd file is NOT meant to solely track user accounts. The role of tracking username's and passwords is the responsibility of the /etc/shadow file. Files such as /etc/passwd and /etc/group are really meant to provide a human readable name when your system is listing files from disks.
Remember that your files are written to the disk using UID/GID's not actual names.
$ stat afile
File: ‘afile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 6560621 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-27 15:54:21.852697029 -0500
Modify: 2014-02-27 15:54:21.852697029 -0500
Change: 2014-02-27 15:54:21.852697029 -0500
Birth: -
Notice the Uid: and Gid:, the numbers are what's actually written to the disk!
add a comment |
Unix systems & Linux generally do nothing to prohibit duplicates in the /etc/passwd file. The intent of this file is to associate a UID with a physical name that can be display by command line tools such as ls when user's are listing out files.
$ ls -n | head -5
total 986000
drwxrwxr-x. 3 1000 1000 4096 Feb 13 19:51 1_archive_sansa
-rw-rw-r--. 1 1000 1000 760868 Dec 16 08:21 2.18.x Database Scheme.jpg
-rw-rw-r--. 1 1000 1000 972 Oct 6 20:26 abcdefg
drwxrwxr-x. 2 1000 1000 4096 Feb 11 03:34 advanced_linux_programming
The other intended purpose of this file is to specify what shell a user will get when they login.
$ getent passwd saml
saml:x:1000:1000:saml:/home/saml:/bin/bash
A common attack vector on Unix type systems is to add lines such as these to a system's /etc/passwd file:
$ getent passwd r00t
r00t:x:0:0:root:/root:/bin/bash
$ getent passwd toor
toor:x:0:0:root:/root:/bin/bash
The role of the /etc/passwd file is NOT meant to solely track user accounts. The role of tracking username's and passwords is the responsibility of the /etc/shadow file. Files such as /etc/passwd and /etc/group are really meant to provide a human readable name when your system is listing files from disks.
Remember that your files are written to the disk using UID/GID's not actual names.
$ stat afile
File: ‘afile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 6560621 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-27 15:54:21.852697029 -0500
Modify: 2014-02-27 15:54:21.852697029 -0500
Change: 2014-02-27 15:54:21.852697029 -0500
Birth: -
Notice the Uid: and Gid:, the numbers are what's actually written to the disk!
add a comment |
Unix systems & Linux generally do nothing to prohibit duplicates in the /etc/passwd file. The intent of this file is to associate a UID with a physical name that can be display by command line tools such as ls when user's are listing out files.
$ ls -n | head -5
total 986000
drwxrwxr-x. 3 1000 1000 4096 Feb 13 19:51 1_archive_sansa
-rw-rw-r--. 1 1000 1000 760868 Dec 16 08:21 2.18.x Database Scheme.jpg
-rw-rw-r--. 1 1000 1000 972 Oct 6 20:26 abcdefg
drwxrwxr-x. 2 1000 1000 4096 Feb 11 03:34 advanced_linux_programming
The other intended purpose of this file is to specify what shell a user will get when they login.
$ getent passwd saml
saml:x:1000:1000:saml:/home/saml:/bin/bash
A common attack vector on Unix type systems is to add lines such as these to a system's /etc/passwd file:
$ getent passwd r00t
r00t:x:0:0:root:/root:/bin/bash
$ getent passwd toor
toor:x:0:0:root:/root:/bin/bash
The role of the /etc/passwd file is NOT meant to solely track user accounts. The role of tracking username's and passwords is the responsibility of the /etc/shadow file. Files such as /etc/passwd and /etc/group are really meant to provide a human readable name when your system is listing files from disks.
Remember that your files are written to the disk using UID/GID's not actual names.
$ stat afile
File: ‘afile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 6560621 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-27 15:54:21.852697029 -0500
Modify: 2014-02-27 15:54:21.852697029 -0500
Change: 2014-02-27 15:54:21.852697029 -0500
Birth: -
Notice the Uid: and Gid:, the numbers are what's actually written to the disk!
Unix systems & Linux generally do nothing to prohibit duplicates in the /etc/passwd file. The intent of this file is to associate a UID with a physical name that can be display by command line tools such as ls when user's are listing out files.
$ ls -n | head -5
total 986000
drwxrwxr-x. 3 1000 1000 4096 Feb 13 19:51 1_archive_sansa
-rw-rw-r--. 1 1000 1000 760868 Dec 16 08:21 2.18.x Database Scheme.jpg
-rw-rw-r--. 1 1000 1000 972 Oct 6 20:26 abcdefg
drwxrwxr-x. 2 1000 1000 4096 Feb 11 03:34 advanced_linux_programming
The other intended purpose of this file is to specify what shell a user will get when they login.
$ getent passwd saml
saml:x:1000:1000:saml:/home/saml:/bin/bash
A common attack vector on Unix type systems is to add lines such as these to a system's /etc/passwd file:
$ getent passwd r00t
r00t:x:0:0:root:/root:/bin/bash
$ getent passwd toor
toor:x:0:0:root:/root:/bin/bash
The role of the /etc/passwd file is NOT meant to solely track user accounts. The role of tracking username's and passwords is the responsibility of the /etc/shadow file. Files such as /etc/passwd and /etc/group are really meant to provide a human readable name when your system is listing files from disks.
Remember that your files are written to the disk using UID/GID's not actual names.
$ stat afile
File: ‘afile’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 6560621 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-27 15:54:21.852697029 -0500
Modify: 2014-02-27 15:54:21.852697029 -0500
Change: 2014-02-27 15:54:21.852697029 -0500
Birth: -
Notice the Uid: and Gid:, the numbers are what's actually written to the disk!
edited Feb 27 '14 at 23:59
answered Feb 27 '14 at 22:25
slmslm
1,76011824
1,76011824
add a comment |
add a comment |
It's actually fairly common to have two users with the same ID. On FreeBSD, there are usually two users with UID 0: root and toor. Root uses the built-in /bin/sh shell, and toor uses a different shell, usually bash.
add a comment |
It's actually fairly common to have two users with the same ID. On FreeBSD, there are usually two users with UID 0: root and toor. Root uses the built-in /bin/sh shell, and toor uses a different shell, usually bash.
add a comment |
It's actually fairly common to have two users with the same ID. On FreeBSD, there are usually two users with UID 0: root and toor. Root uses the built-in /bin/sh shell, and toor uses a different shell, usually bash.
It's actually fairly common to have two users with the same ID. On FreeBSD, there are usually two users with UID 0: root and toor. Root uses the built-in /bin/sh shell, and toor uses a different shell, usually bash.
answered Feb 27 '14 at 23:48
andybalholmandybalholm
20112
20112
add a comment |
add a comment |
In Linux, all users and groups are actually just numbers. That's what the output of the id command you posted shows.
The /etc/passwd file maps user names to user IDs (numbers) and in the example you have provide, you've simply mapped two usernames to the same user ID.
Effectively, you've created one user, test12, ID 1005, who also has a second username test13. However the system will map UID 1005 to the first username it finds, which would be test12
Linux "lets" you do this because there's no system to prevent you from doing this. /etc/passwd is just a text file, usernames are mapped to the UID found for their entry in that file, UIDs are mapped to the first username found in that file.
But what you've created is a confusing situation for other systams administrators; avoid it by changing the UID of test13
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the/etc/passwdfile. But there's no means in place to prevent you from doing this. Does that make sense?
– Josh
Feb 27 '14 at 17:01
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
|
show 1 more comment
In Linux, all users and groups are actually just numbers. That's what the output of the id command you posted shows.
The /etc/passwd file maps user names to user IDs (numbers) and in the example you have provide, you've simply mapped two usernames to the same user ID.
Effectively, you've created one user, test12, ID 1005, who also has a second username test13. However the system will map UID 1005 to the first username it finds, which would be test12
Linux "lets" you do this because there's no system to prevent you from doing this. /etc/passwd is just a text file, usernames are mapped to the UID found for their entry in that file, UIDs are mapped to the first username found in that file.
But what you've created is a confusing situation for other systams administrators; avoid it by changing the UID of test13
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the/etc/passwdfile. But there's no means in place to prevent you from doing this. Does that make sense?
– Josh
Feb 27 '14 at 17:01
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
|
show 1 more comment
In Linux, all users and groups are actually just numbers. That's what the output of the id command you posted shows.
The /etc/passwd file maps user names to user IDs (numbers) and in the example you have provide, you've simply mapped two usernames to the same user ID.
Effectively, you've created one user, test12, ID 1005, who also has a second username test13. However the system will map UID 1005 to the first username it finds, which would be test12
Linux "lets" you do this because there's no system to prevent you from doing this. /etc/passwd is just a text file, usernames are mapped to the UID found for their entry in that file, UIDs are mapped to the first username found in that file.
But what you've created is a confusing situation for other systams administrators; avoid it by changing the UID of test13
In Linux, all users and groups are actually just numbers. That's what the output of the id command you posted shows.
The /etc/passwd file maps user names to user IDs (numbers) and in the example you have provide, you've simply mapped two usernames to the same user ID.
Effectively, you've created one user, test12, ID 1005, who also has a second username test13. However the system will map UID 1005 to the first username it finds, which would be test12
Linux "lets" you do this because there's no system to prevent you from doing this. /etc/passwd is just a text file, usernames are mapped to the UID found for their entry in that file, UIDs are mapped to the first username found in that file.
But what you've created is a confusing situation for other systams administrators; avoid it by changing the UID of test13
answered Feb 27 '14 at 16:48
JoshJosh
295216
295216
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the/etc/passwdfile. But there's no means in place to prevent you from doing this. Does that make sense?
– Josh
Feb 27 '14 at 17:01
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
|
show 1 more comment
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the/etc/passwdfile. But there's no means in place to prevent you from doing this. Does that make sense?
– Josh
Feb 27 '14 at 17:01
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
this is my test virtual machine man , my question is there a purpose to map two users for the same uid
– nux
Feb 27 '14 at 16:52
1
1
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
The only purpose I can think of is to give a UID a second, aliased, username. But this is undefined behavior and not recommended. Really this is an undesirable situation: you're better off with a 1:1 relationship between usernames and UIDs
– Josh
Feb 27 '14 at 16:55
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
thats why i asked this question i needed to know , i felt that it is a confusing way
– nux
Feb 27 '14 at 16:58
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the
/etc/passwd file. But there's no means in place to prevent you from doing this. Does that make sense?– Josh
Feb 27 '14 at 17:01
It is confusing; that's why you shouldn't do it. It doesn't have a "purpose", it's more a misuse of the
/etc/passwd file. But there's no means in place to prevent you from doing this. Does that make sense?– Josh
Feb 27 '14 at 17:01
1
1
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
a user mentioned that the goal is to have 2 logins point to identical filesystem permissions.
– nux
Feb 27 '14 at 17:02
|
show 1 more comment
The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of ! (because ! was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls could could map user-id => name. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser addgroup, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd and groupadd were introduced, which kept shadow and shadow- updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.
add a comment |
The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of ! (because ! was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls could could map user-id => name. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser addgroup, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd and groupadd were introduced, which kept shadow and shadow- updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.
add a comment |
The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of ! (because ! was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls could could map user-id => name. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser addgroup, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd and groupadd were introduced, which kept shadow and shadow- updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.
The reason that this is allowed today, is simply because the system doesn't prevent it.
If this changed, then it would break those systems where admins have had a use for this feature, (see Terdon's example). So it has never been changed, and I don't think it ever will.
Originally there was only the passwd and group files, and they served their purpose. there was no adduser command, no addgroup, the files were edited by root using vi or ed.
There were a few quirks !
In order to remember the next user-id to use, it was common for admins to have a special user as the last line which had a user-name of ! (because ! was an invalid user name) and that entry was used to store the next user-id. Crude, I admit, but It worked! So why bust a gut making it more complicated, akin to agile development today.
There were known flaws. The main being, that it had to be world readable, so that utilities like ls could could map user-id => name. This meant anybody could see everybody's encrypted password, and all the users and id's in the system.
Some Unix systems began introducing a couple of shell scripts adduser addgroup, often these were ignored, because they were a inconsistent between Unixes, so most people just carried on with the manual edit.
It took quite a few years, before the shadow password file was invented, this provided a little more security, by hiding the encrypted passwords. Again, just enough complexity was added, but it was still fairly crude and simple. The utilities useradd and groupadd were introduced, which kept shadow and shadow- updated. To start with, these were often simple shell script wrappers around vendors proprietary adduser/addgroup utilities. Again it was just enough to keep going.
Networks of computers were growing up, people were working on several at a time to get jobs done, so admin of the passwd/group files was becoming a nightmare, especially with NFS, so in comes Yellow Pages also known as NIS to alleviate the burden.
It was becoming obvious by now that something a bit more flexible was needed, and PAM was was invented. So if you were really sophisticated and wanted a centralised, secure, unique-id'ed, all bells and whistles authentication system you would call out to a central server to authenticate, maybe a Radius server, LDAP server or Active directory.
The world had grown up. But the passwd/group/shadow files still remained for us smaller users/developers/labs. We still didn't really require the all bells and whistles. I guess the philosophy had changed a bit by now to, "If you were going to make it better, you wouldn't use it at all", so don't worry about it.
This is why I don't think the simple passwd file will ever change. There's no point any more, and it's just great for those £30 Raspberry Pi's with 2 maybe 3 user's monitoring temperature, and twitter feeds. OK, You just have to be a bit careful with your user-id's if you want them unique, and there's nothing to prevent the enthusiast from wrapping useradd in a script which first selects the next unique id from a database (file) to set a unique id, if that's what you want. It is open source after all.
edited Oct 11 '18 at 6:20
Walf
158211
158211
answered Feb 28 '14 at 2:34
X TianX Tian
21516
21516
add a comment |
add a comment |
The /etc/passwd file just maps symbolic usernames to the real userID. If you deliberately make two symbolic names that map to one userID then it will let you.
That doesn't mean it is a good idea to actually do it. Some people may have found very specific usage cases where they can take advantage of this feature, but in general you should not do it.
Linux (and other UNIXes) take the opinion that the administrator knows what they are doing. If you tell it to do something stupid then that's your own fault, in much the same way that if you tell your car to drive over a cliff you can't go to the manufacturers and ask why the car allowed you to do this.
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
add a comment |
The /etc/passwd file just maps symbolic usernames to the real userID. If you deliberately make two symbolic names that map to one userID then it will let you.
That doesn't mean it is a good idea to actually do it. Some people may have found very specific usage cases where they can take advantage of this feature, but in general you should not do it.
Linux (and other UNIXes) take the opinion that the administrator knows what they are doing. If you tell it to do something stupid then that's your own fault, in much the same way that if you tell your car to drive over a cliff you can't go to the manufacturers and ask why the car allowed you to do this.
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
add a comment |
The /etc/passwd file just maps symbolic usernames to the real userID. If you deliberately make two symbolic names that map to one userID then it will let you.
That doesn't mean it is a good idea to actually do it. Some people may have found very specific usage cases where they can take advantage of this feature, but in general you should not do it.
Linux (and other UNIXes) take the opinion that the administrator knows what they are doing. If you tell it to do something stupid then that's your own fault, in much the same way that if you tell your car to drive over a cliff you can't go to the manufacturers and ask why the car allowed you to do this.
The /etc/passwd file just maps symbolic usernames to the real userID. If you deliberately make two symbolic names that map to one userID then it will let you.
That doesn't mean it is a good idea to actually do it. Some people may have found very specific usage cases where they can take advantage of this feature, but in general you should not do it.
Linux (and other UNIXes) take the opinion that the administrator knows what they are doing. If you tell it to do something stupid then that's your own fault, in much the same way that if you tell your car to drive over a cliff you can't go to the manufacturers and ask why the car allowed you to do this.
edited Feb 28 '14 at 4:05
Seth♦
34.7k27112164
34.7k27112164
answered Feb 28 '14 at 3:33
user253158user253158
1313
1313
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
add a comment |
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
why it was mentioned as a bug ?
– nux
Feb 28 '14 at 3:37
add a comment |
There are identifiers that the operating system expects to be unique, but they are used for tracking hardware. The knowledge that a particular Universally Unique IDentifier corresponds to a hard drive containing system files may help it to continue operating if the hardware configuration changes. Microsoft calls these Globally Unique IDentifiers and uses them to track all Windows software. Ironically, these acronyms were poorly chosen.
From the perspective of the OS, most user and group identifier changes amount to changing its outside interface. It could function normally despite collisions; mainly what is required of the system users and groups is that they exist. It cannot know what the users require. In situations like this, the Unix philosophy is that the OS should assume the administrators know what they are doing, and should help them do it quickly.
add a comment |
There are identifiers that the operating system expects to be unique, but they are used for tracking hardware. The knowledge that a particular Universally Unique IDentifier corresponds to a hard drive containing system files may help it to continue operating if the hardware configuration changes. Microsoft calls these Globally Unique IDentifiers and uses them to track all Windows software. Ironically, these acronyms were poorly chosen.
From the perspective of the OS, most user and group identifier changes amount to changing its outside interface. It could function normally despite collisions; mainly what is required of the system users and groups is that they exist. It cannot know what the users require. In situations like this, the Unix philosophy is that the OS should assume the administrators know what they are doing, and should help them do it quickly.
add a comment |
There are identifiers that the operating system expects to be unique, but they are used for tracking hardware. The knowledge that a particular Universally Unique IDentifier corresponds to a hard drive containing system files may help it to continue operating if the hardware configuration changes. Microsoft calls these Globally Unique IDentifiers and uses them to track all Windows software. Ironically, these acronyms were poorly chosen.
From the perspective of the OS, most user and group identifier changes amount to changing its outside interface. It could function normally despite collisions; mainly what is required of the system users and groups is that they exist. It cannot know what the users require. In situations like this, the Unix philosophy is that the OS should assume the administrators know what they are doing, and should help them do it quickly.
There are identifiers that the operating system expects to be unique, but they are used for tracking hardware. The knowledge that a particular Universally Unique IDentifier corresponds to a hard drive containing system files may help it to continue operating if the hardware configuration changes. Microsoft calls these Globally Unique IDentifiers and uses them to track all Windows software. Ironically, these acronyms were poorly chosen.
From the perspective of the OS, most user and group identifier changes amount to changing its outside interface. It could function normally despite collisions; mainly what is required of the system users and groups is that they exist. It cannot know what the users require. In situations like this, the Unix philosophy is that the OS should assume the administrators know what they are doing, and should help them do it quickly.
answered Feb 28 '14 at 7:59
user130144user130144
1112
1112
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f427107%2fwhy-can-i-create-users-with-the-same-uid%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not sure about it, but I think the output is printing the UID of user "test10" in both commands. Why is doing that, I have no idea, but must be some user you created previously.
– animaletdesequia
Feb 27 '14 at 15:41
as if its saying there is a user that has this id
– nux
Feb 27 '14 at 15:48
OK, I misunderstood the question. I thought that you created the users normally and the system assigned them the same UID.
– animaletdesequia
Feb 27 '14 at 15:52
no man not normally , the question here , how the system accept unique uids
– nux
Feb 27 '14 at 15:54
Got it. Good question then, thanks for the explanation :)
– animaletdesequia
Feb 27 '14 at 15:56