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 use this command to change my home directory

sudo usermod -d new-path -m myname

But I got this error

usermod: user myname is currently logged in

How could I change my own home directory and move all files into new-path?

Thanks for any suggestions.

EDIT:

This server is a remote VM, and connected with putty (ubuntu 12.04)

share|improve this question
4  
You may able to do it as root from a TTY - see this question –  Wilf Aug 16 at 11:07
    
log out. do control-alt-f1. log in. change it. type "exit". control-alt-f7. log in again. –  Rinzwind Aug 16 at 11:10
    
Thanks for your suggestion. Sorry I forgot to mention this server is a remote VM and I connect with putty. –  Bangyou Aug 16 at 11:12
2  
@Wilf Thanks. Add a temporary user could be the best way to solve my problem. –  Bangyou Aug 16 at 11:14
    
I've never tried anything like this, but I would suspect you could boot from a live CD, move any directories/files, change the entry in /etc/passwd for the new home directory for your user and be good to go. Make backups of everything you intend to modify so you can put things back if it doesn't work as desired. –  Joe Aug 24 at 16:53

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.