Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Xubuntu 11.10 and trying to change a users username. There doesn't seem to be a way to change this through the GUI in Xubuntu, so I am wondering if there is a way to do it without the GUI. Maybe changing the setting in a config file. Any help would be greatly appreciated.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

First open a terminal, become root

sudo -i

Next use the following commands,

change "old" to the old user name, and "new" to the new desired name.

usermod -d /home/new -m old

sed -i -e 's_old_new_g' /etc/passwd

sed -i -e 's_old_new_g' /etc/group

sed -i -e 's_old_new_g' /etc/shadow

The first command moves your home directory, see man usermod

-d, --home HOME_DIR The user's new login directory. If the -m option is given, the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist.

The sed command changes the name in /etc/{passwd,group,shadow}

The system otherwise identifies users by number, not name, so your file ownership and permissions will be fine

To see your numerical id, run the command

id
share|improve this answer
    
I'm relatively new to this, but I still can't believe I forgot the usermod command. Thanks. –  Arthur Feb 25 '12 at 15:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.