4

If it is possible, should be pretty basic, but I am puzzled how to ask Google the right question (or it is impossible).

Lets say we have

/home/user/
...conf
/home/user/candidate/
...conf

We have homedir and some subdir.. programs will use naturally from homedir(*/home/user*)

What I need is to temporarily change home user to */home/user/candidate*, so programs will call */home/user/candidate/conf*, instead */home/user/conf*

Now, I don't need usermod or anything else to change permanently /etc/passwd, i want to temporarily force programs to use my directory, thinking it is home, but on reboot fetch */home/user* and act normal.

Using */home/user/candidate* as home only session long, no usermod stuff.

5

You could use bind mount to make this redirection:

mount --bind /home/user/candidate/ /home/user/

This way, /home/user will show the contents of it´s subdir candidate. After making all you need, umount will destroy the binding:

umount /home/user/

More docs about bind mount:

  • 1
    that would do perfectly if it to do as i think it will. off to another station, will let know of result – Timo Junolainen Apr 25 '14 at 18:50
  • i´ve made a test inside /tmp and it worked as expected. hope it works for you too. Cheers – user34720 Apr 25 '14 at 19:01
  • 1
    seems perfect. as i was thinking, it isnt hard, after you know what to look for.. google answers gave usermod answers, and i can assume i asked wrong questions – Timo Junolainen Apr 25 '14 at 19:01
  • Another option is aufs, that is something like a overlay filesystem to multiple directories into one mountpoint. Could be usefull to make /home/user read-only and /home/user/foo read-write. I just don´t if it will work as mount bind with subdirs. - aufs.sourceforge.net – user34720 Apr 25 '14 at 19:23

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.