Change default home dir of user

6,020

I have no idea why usermod doesn't work but it doesn't really matter. You can easily review & edit /etc/passwd and make the necessary change if required. Then move their existing home directory over to /var/www/project/ if desired.

Share:
6,020

Related videos on Youtube

Jonathan Solorzano
Author by

Jonathan Solorzano

Updated on September 18, 2022

Comments

  • Jonathan Solorzano
    Jonathan Solorzano almost 2 years

    I want to change the default home directory of a user from this:

    User: john
    Default home: /home/john
    

    To this:

    User: john
    Home: /var/www/project/new-home
    

    How could i do that?

    What i've tried so far is use usermod:

    usermod -m -d /var/www/project/john john
    

    It worked for one user, but i've got two users, john & sarah, and when i tried the same for sarah it said:

    usermod: no changes
    
    • Jacob Evans
      Jacob Evans over 8 years
      I understand why you might want to do that, but you should just put the website under /home/username/html or public_html, this is how cpanel and interworx (and likely others) separate userspace, also check out SuexecUserGroup
    • Jonathan Solorzano
      Jonathan Solorzano over 8 years
      Oh, no that's not what i want to do, i'm using pure-ftpd and it's configured to chroot users to their home dir, so basically one user is for the frontend files, and the other is for the backend files, i just want the users to navigate through their files, not to be able to navigate upper their dir @JacobEvans