7

I have a user account provided by client with unrestricted sudo access, but this user has no home directory. I want to create one, but I'm not sure how to go about it.

I tried logging in as my normal user and sudo suing into root, then running

 usermod -d /home/user  -m user

But it gaves the message usermod: no changes. I assume because my user is already logged in?

Other solutions seem to involve removing and re-creating my user account with a home directory, but again as user would be already logged in I think there may be problems with that approach.

Is there a way to create my user's home directory with the access I have, or do I need to inform my client/provider to recreate my account?

voretaq7
  • 79,345
  • 17
  • 128
  • 213
kuldeep.kamboj
  • 183
  • 1
  • 2
  • 9

2 Answers2

16

Just create a home directory for them and grant them permissions.
mkdir /home/$user and then chown $user:$user /home/$user.

Take note to replace the group in the chown command with something else if required.

voretaq7
  • 79,345
  • 17
  • 128
  • 213
Peter
  • 1,450
  • 2
  • 15
  • 26
  • I checked it on my local test instance and it work fine. profile also created automatically. – kuldeep.kamboj Feb 18 '14 at 07:23
  • 11
    For future reference, the normal procedure for creating the home directory and setting up a clean environment is to copy the `/etc/skel` home directory template to the new users home directory i.e. `cp -ar /etc/skel/ /home/$user && chown -R $user:$user /home/$user` which is what adduser does too when creating a new user account. – HBruijn Feb 18 '14 at 07:31
  • @HBruijn, Yes three files .bashrc, .bash_logout, .profile is not created until you manually copy from /etc/skel – kuldeep.kamboj Feb 21 '14 at 11:13
0

In addition to what @HBruijn wrote, you also need to apply proper chmod of directory i.e.:

cp -ar /etc/skel/ /home/$user && chown -R $user:$user /home/$user && chmod 700 /home/$user
Sam
  • 101