I currently only have 1 user account on my ubuntu server. I would like to change the user name without creating another account. Is there a way to do this? Any help would be greatly appreciated.
1 Answers
You can manually change the contents of /etc/passwd
, /etc/shadow
and /etc/group
. Or you can use usermod
command. Check the manual page for information on how to use them.
Then you need to search and change the name in some configuration files under /etc/
, I usually uses grep
to do that, see manual page about how to use it. Don't forget to check and possible change the mail directory name in /var/spool/mail/
.
Notice that Linux only identify users and groups on the number values. Linux uses /etc/{passwd,shadow,group}
to map between names and id numbers. So if you have two users with same uid
value, the kernel will not be able to make any difference between them. For the kernel the user have two login names. Don't use this, as that is not supposed to work.
Most applications store the user name and not uid
. That is why you might need to change some configuration files with the old login name to use the new login name.

- 1,585
id
for that, and then add those to the new user, seeaddgroup
. Do not add the group name with the same name as the old user account. Then, when all is set up and copied from the old account to the new one, just remove the old one, see man page forusermod
. – Anders May 15 '15 at 09:47