How to create a new user with permission exactly same as an existing user in linux.

  • Exactly the same is ambiguous – daisy Apr 19 '13 at 6:29
  • 1
    Do you want a different user with permissions such as granted by the groups the existing user has. Or do you want the new user to be able to access everything as the existing user but have a different login name? Maybe a bit more information on what you try to achieve and why you think 'creating a new user with permissions exactly as an existing user' is a solution makes things more clear. – Anthon Apr 19 '13 at 6:48
  • @Anthon, I want the new user to be able to access everything as the existing user but have a different login name. – Rishi Raj Apr 19 '13 at 6:55

You should create a new user as Hauke is right in indicating that creating two with the same UID is going to be confusing ( you could do that with useradd -u EXISTINGUID ... )

You probably just want to make a new user and make sure they are in the same group and that the group permissions are so that they can work with the data in the same group in the same way. Most installations now seem to make a group per user, so if your existing user is named exus you have a groupname exus in /etc/group as well, note the gid (group id) and all the other groups that exus is a member of (vboxuser, dialout etc -> `gid2, gid3). Create the new user with:

useradd -N -g gid -G gid2,gid3 -m

(You could have them use the same home directory by replacing -m with --home ~exus, not sure if that is what you want)

Make sure that all of the group permissions of the new files created by both users are based on a umask of 002 or 007 and that permissions on existing files owned by the exus have the group permissions the same as the user permissions:

find / -user exus -print0 | xargs -0 chmod g=u
| improve this answer | |

You can (probably not with the tools, though) create a new user with the same UID like an existing user. One of the problems is that only one user will see the correct (his own) user name for file system objects, processes and so on.

Another approach is to keep the system free of references to the username (which will probably not work within $HOME) and instead create a group with just the two users as members and manage all access rights with group rights only.

| improve this answer | |

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.