Change Superuser name in Ubuntu?

5

1

I mistyped my superuser. It should be "masi" instead of "maasi". I do not want to configure and install all packages again. How can I change it?

Léo Léopold Hertz 준영

Posted 2009-08-09T18:21:24.933

Reputation: 4 828

Answers

9

If you're not talking about UID 0 (which is almost always called root, and probably hardcoded as that name in a few admin applications), then the 'super user' is just a user in the admin group. You can use the method mentioned above (though make sure you also edit /etc/shadow and /etc/gshadow, and use vipw and vigr), but I'd recommend simply creating a new account with the correct name, adding it to the admin group (adduser masi admin), and migrating your data to it (copying the home directory and chown -R masi are probably sufficient). Log in to the new account and confirm that you can run sudo before deleting the old account. This is much less likely to leave you locked out of your system.

brendan

Posted 2009-08-09T18:21:24.933

Reputation: 206

5

You will want to use the usermod command. It will update all files needed for you as well.

You must make note of the caveats though:

CAVEATS:

usermod will not allow you to change the name of a user who is logged in. You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID is being changed. You must change the owner of any crontab files manually. You must change the owner of any at jobs manually. You must make any changes involving NIS on the NIS server.

John T

Posted 2009-08-09T18:21:24.933

Reputation: 149 037

2

Just edit the entry in /etc/password to what you want. You may also need to update /etc/group for consistency. Then rename your home directory (in /home) to match.

All file permissions are done by user/group ID (the number associated with your name) so by updating the name, it should "just work".

Adam Batkin

Posted 2009-08-09T18:21:24.933

Reputation: 914