I created a user with non unique id passing -o -u 1000 -m option to useradd command. So now I have two users with same id but with different names and different home directories.
I thought that this could be a solution to create a new clean environment (for testing purpose) and preserve the same access permissions to some development directories and files.

Although user creation and login in his own desktop environment was successful, one applications, manually started from terminal, was using home directory of original user. So, starting idea.sh as scantligt_2 was still using home directory of user scantlight.

how is this possible? why this application is still using home directory of original user even if I started it as second use?

here is the content of some environment variables.

$> echo $HOME

$> echo $USER

$> cd ~
$> pwd

and after all tests,
Is it safe to delete the user "scantlight_2" with userdel command or should I do it manually from /etc/shadow file to avoid some conflicts?

EDIT: The idea.sh is the starting script of "IntelliJ IDEA" IDE. I made a quick recursive grep through bin directory content and no usage of getent command was made. Below is the command i used.

grep -r -i "getent|passwd" ./idea_install/bin


  • 1
    You need to show us some of the idea.sh script. My bet is that a program it runs looks up the home dir and username with getent, and finds the first scantlight. users are identified by the uid, the number - the name is really only pretty-printing and convenience. – cas Nov 1 '15 at 14:35
  • 2
    e.g. run id 1000 or getent passwd 1000 and the'll only display the first entry for that uid. – cas Nov 1 '15 at 14:36
  • btw, this means you shouldn't delete that user with deluser or userdel or anything similar. You should edit the passwd manually file with vipw and vipw -s, and the group file with vigr and vigr -s (the -s option on those commands makes them edit /etc/shadow and /etc/gshadow respectively). – cas Nov 1 '15 at 14:47

Most programs that need to care about usernames will do a getent() lookup to find the UID and use that from then on - that's because users are identified by the uid, the number. The name is not much more than pretty-printing and convenience.

For example, run id 1000 or getent passwd 1000 and they will only display the first entry for that uid.

It is not safe to use userdel or deluser or any similar command to delete that second user.

This is because they will most likely delete the first user with uid 1000 that they find.

Instead, you need to edit the passwd and group files manually:

  • vipw and vipw -s to edit /etc/passwd and /etc/shadow
  • vigr and vigr -s to edit /etc/group and /etc/gshadow
  • my initial idea was to remove the second user providing option -r to userdel command to automatically remove home directory of second user. Now I think that is a very bad idea :) ... I don't even want to try it to see what will happen. vipw and vigr are very handy command in this situation. Thankyou. – Scantlight Nov 1 '15 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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