0

I want to move my home dir. I have read, write and execute access to both the old and new home. Why can't I tell Linux I want my home there instead?

I see usermod -m -d /newhome/username username would do it, but it needs root priviledges. For other settings, there's facilities to do it. For example, chsh has the setuid flag and will modify /etc/passwd. Would it not make sense to have chhome that would similarly let a user change its home directory setting?

I feel there's a good reason for it to not be offered, but I'm missing it. Any ideas?

4
  • 2
    Related: lwn.net/Articles/310528
    – jesse_b
    Apr 13 '18 at 19:49
  • 2
    The system administrator chooses where users' home directories are based on the criteria that are important to the admin. Users should not be able to override that decision. Apr 13 '18 at 21:42
  • @AndyDalton and if you are channeling your inner BOFH then the users should be happy you allow them to use your machine at all... :)
    – ivanivan
    Apr 13 '18 at 23:36
  • There are legitimate uses for this (change your home to a local directory when the NFS server is down), but they're probably outnumbered by users shooting themselves in the foot ("My filesystem was low on space and I saw that /scratch had lots. Where did my files go?"). Apr 14 '18 at 12:19
2

Well to start you can't make this change while currently signed into the user that you want to change the home directory because usermod fails when the same username has other processes running. There are ways to change your home directory through another account on the machine that has root privileges to yours. Letting these changed be done live would also mess up things like bash if not all the necessary files were edited to tell Linux where the new directory is.

This is also probably a feature to prevent users from going around and changing their home directory to whatever they please and in the process possibly permanently losing files or access to their account.

1
  • This is simply a security issue.
    – Bonsi
    Apr 14 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.