Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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:

share|improve this answer
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 at 18:50
    
i´ve made a test inside /tmp and it worked as expected. hope it works for you too. Cheers –  nwildner Apr 25 at 19:01
    
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 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 –  nwildner Apr 25 at 19:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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