change login name

Karl Auer kauer at biplane.com.au
Fri Jun 20 14:17:30 UTC 2008


On Fri, 2008-06-20 at 10:12 -0300, Derek Broughton wrote:
> > i wanted to chnage the login name of my system
> > 
> > i tried the procedure of going to system -admin- user and groups , but i
> > could only change the password and not the user name

If I understand you correctly, you want your own login (username) to be
different, but you want everything else to stay the same.

In the following instructions "oldname" is your current username and
"newname" is your desired new username.

First edit /etc/passwd. For example, if your favourite text editor is
gedit:

    sudo cp -a /etc/passwd /etc/passwd.old
    sudo gedit /etc/passwd
 
Look for the line of text that starts with your current username. Change
that first field to the desired new username and (further along in the
line) also change the name of your home directory. For example, the
change this:

   oldname:x:1000:1000:Old Name,,,:/home/oldname:/bin/bash

to this:

   newname:x:1000:1000:New Name,,,:/home/newname:/bin/bash

Save the file and exit the text editor.

Then use your favourite text editor and edit /etc/shadow:

   sudo cp -a /etc/shadow /etc/shadow.old
   sudo gedit /etc/shadow

Again, look for the line that has your current username as the first
field. Change this:

   oldname:SomeLongRandomLookingPassword:13711:0:99999:7:::

to this:

   newname:SomeLongRandomLookingPassword:13711:0:99999:7:::

Save the file and exit the text editor.

Then you need to change the group file. Use your favourite text editor
and edit /etc/group:

   sudo cp -a /etc/group /etc/group.old
   sudo gedit /etc/group

Look for the line that starts with your current username. Change this:

   oldname:x:1000:

to this:

   newname:x:1000:

Save the file and exit the text editor.

Then you need to rename your home directory:

   sudo mv /home/oldname /home/newname

Finally log out of everything, exit from X, and log back in with the new
username.

Be sure to use a text editor you are familiar with and proceed
carefully, because if you bollix up any of the three files when you edit
them you may make it difficult for yourself to log in.

You might like to first set up a brand new user and test the above
procedure on that user just to make sure I haven't left something out.
Use different names, obviously! The above is "off the top of my head",
so I do highly recommend a practice run.

I also suggest that you just look at the files first, to make sure the
bits you want to edit are actually there. The above assumes a standard
Ubuntu setup and should be very like what you have, but it pays to be
sure.

When you are sure that everything still works OK with the new username,
you can delete the .old files. Or, if anything goes wrong, copy the .old
files back over the changed files and start again.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)                   +61-2-64957160 (h)
http://www.biplane.com.au/~kauer/                  +61-428-957160 (mob)

GPG fingerprint: DD23 0DF3 2260 3060 7FEC 5CA8 1AF6 D9E3 CFEE 6B28
Public key at  : random.sks.keyserver.penguin.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20080621/3ea63bff/attachment.sig>


More information about the ubuntu-users mailing list