Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there and easy way to create a new user that is a copy of another

Status
Not open for further replies.

bobbybobbertson

Programmer
Nov 9, 2001
119
US
I want to make a copy of a user on my system so that the only thing that differs from the origional to the copy is the password. Is there an easy way to do this? Or do I have to create the user and search for all the groups and permissions of the old user, before defining them on the new user.

 
Hi,

The closest you can get (except for group memberships) would be :

/usr/sbin/useradd -g user1 -d /home/user1 user2

That woudl create user2 with the same home directory as user1 and also with the same default group (at least on redhat where default group = username)

Other than that you have to check for group memberships in /etc/gshadow and add them to user2.

Hope this helps

 
You could just edit /etc/passwd and /etc/shadow
duplicating the line of the user you want and
giving the new name instead. Then run passwd for the
new username to change the password.(same editing for
groups)

If all files/directory structure from the original user are desired:
mkdir /home/newuser , cp -r /home/olduser/* /home/newuser
Then write a quick recursive script to chmod and chown for
the newuser.
 
Hi,

To do this you will also need to make sure you edit the uid in /etc/passwd, and it has to be unique.

Cheers,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top