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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a username in unix?

Status
Not open for further replies.

philpe

IS-IT--Management
Apr 24, 2002
21
CA
Haven't been able to really find a how-to on changing a username in unix on the net. I thought of 2 ways of doing this, the first being the easiest, but I wanted to know if anyone has run into problems doing it this way?
First off it's a solaris 8 system using shadow passwords.
I simply change the /etc/passwd file and edit the users name, leaving everything else the same. Then I edit the /etc/shadow file and do the same. Then I check the /etc/group file for memberships and change the username in it. Does anyone see a problem with going it this way?

Thanks for your help.

The other method was to create a new user, give him the same group memberships, then once done, change the /etc/passwd file and give him the same UID as the original user, and the same home dir. Then delete the original user.

If you know of a better way, please let me know.

Phil
 
actually, Solaris has a fairly easy way to change the name of a user, it seems. Using admintool, select the user whose name you want to change and choose Edit Modify. In the username text box, change the name to what you want it to be. You can also change the home directory name, but you will then have to create the directory and move the files from the old name's home dir to the new one. You could also mv the old home dir to the new name.

The ways you describe would work, but sometimes it's dangerous to edit password files -- too easy to fat finger them.
 
You also can do it from the command line with usermod:

usermod -l newlogname oldlogname
 
Thanks for your answers guys, just needed a little guidance that I wasn't doing anything bad by changing the usernames.

Many thanks again

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top