Linux – Temporarily Using a Different Home Directory

home

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.

Best Answer

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:

Related Question