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 would like to know, whow to modify properly the homedir of a user.

I already know about this command

usermod -d /home/peter peter

But know, do I have to create the homedir befor? And what will happen to the old homedir? (I know about the -m option which would move the contents, but I don't want to move/remove the old content).

So for not removing and just leaving the old content, would I just have to use the command, exactly as I mentioned above?

I use Ubuntu 12.04.1 LTS "Server".

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Firstly usermod can not be run as a normal user. You either need to be logged on as root, not recommended, or prefix the command with sudo. The command does not create the folder so you will need to create it first.

    cd /home;
    sudo mkdir peter
    sudo chown peter:peter peter
    sudo usermod -d /home/peter peter

Will do what you want. Any existing home folder will remain unchanged

share|improve this answer
    
What do I do when it says the user is logged in? But for real the user is not logged in. Users just shows myself. –  Peter I Feb 3 '13 at 12:51
    
you can check who you are logged with whoami and everybody logged in with who. –  Warren Hill Feb 4 '13 at 10:21
    
I used users and it just returned my own name. Which was not the username, which I assigned the new home directory to. Seems to me the user was somehow assigned to me, because after re-login it worked well. –  Peter I Feb 4 '13 at 12:38

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.