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 have accidentally typed my name wrong when I created the administrator account. Although I managed to change the user name at the login screen, I am unable to rename the /home/oldusername to /home/newusername. I tried most of the online tutorials, and it failed.

The code I tried was this:

usermod -l newusername -m -d /home/newusername oldusername

But the output is:

cannot lock /etc/passwd; try again later.

How can I fix the issue and change the folder to newusername and expect all the applications to work as before?

share|improve this question
    
Are you running that command as root? –  Seth Dec 13 '12 at 17:07
    
no in a guest account..the name i'm trying to change is the root account i guess. –  Fazlan Dec 13 '12 at 17:15
    
is root and administrator different? I dnt knw –  Fazlan Dec 13 '12 at 17:15
    
hey I don't understand have u access to admin/root account?? –  geoh Dec 13 '12 at 17:18
1  
You cannot use the guest account to do any administrative tasks. –  user68186 Dec 13 '12 at 18:10
show 1 more comment

4 Answers 4

Login as your oldusername, open a terminal and type:

sudo passwd root

Enter a password for the root account, then logout, press Ctrl+Alt+F1 to open a text console, login as root (username: root, password: "the one you typed above") and run:

usermod -l newusername -m -d /home/newusername oldusername
exit

Press Ctrl+Alt+F7 to return to graphic console and login as newusername.

share|improve this answer
    
it says user oldname is currently logged in –  Fazlan Dec 13 '12 at 17:54
    
Answer updated. –  Eric Carvalho Dec 13 '12 at 19:58
add comment

The first simple solution that you can do is to create a new user with the right username that you want and add it to the administrator group: /etc/sudoers

other way, you can do that with your old username (I tested it on fedora):

# usermod -l new-username old-unername
share|improve this answer
1  
You may need to add sudo before that line like sudo usermod -l new-username old-unername, in Ubuntu. –  user68186 Dec 13 '12 at 18:13
    
The username is changed but the folder name is still the old name –  Fazlan Dec 22 '12 at 15:11
    
#: means you have the root permissions, and $: means you're just a simple user. –  Boubakr NOUR Aug 27 '13 at 15:35
add comment

I would create a new account, and copy all of your files across. This is probably the most idiot-proof method.

share|improve this answer
add comment

You need to do this from recovery mode.

Reboot, choose recovery mode, and then drop to a root console and type the command there. Then reboot again as normal.

share|improve this answer
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.