Avatar of tzk
tzk
 asked on

How to use 'usermod' command to add user's login directory

hi, everybody:
    When I created a new user account with useradd command, I found the user directory was not created, because I didn't use any options in the useradd command. Now, I want to add the new user's login directory with 'usermod' command. But it doesn't work, look:

   sudo usermod -d /home/newuser newuser
   sudo usermod -d -m /home/newuser newuser
 
   The commands above don't work, The directory wasn't created. How should I do?
Linux

Avatar of undefined
Last Comment
frashii

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
frashii

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
tzk

ASKER
frashii:
    Thank you very much! And do you mean that the 'usermod' doesn't complete the tasks you said above? I want to know if 'usermod' can do it.
frashii

Very odd.. I would have expected both of those commands to work!

What version of Linux is it ? Ubuntu ? Redhat? Debian ?
tzk

ASKER
I use Ubuntu.

I thought the 'usermod -d -m' command should create the user's login directory and environment. I just don't understand this.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
frashii

Does /home exist already ? ie. are you trying to create 2 levels of directories ?

You are entirely correct, that should work EXACTLY like that