Sharing part of the home folder between two user accounts

Posted on

Problem :

I’m using openSUSE Linux with KDE Plasma.

I’d like to set up two user accounts on the same machine, and have these two share part of the same Home folder.

In particular, I want to set up two user accounts that will be used only be me, a personal one and a work-related one; my concern is not to protect files from an account to the other, but to keep these two scopes separated.

I’d like each of these two accounts to share the basic system and desktop environments files and settings, in order to have a unified working environment, so if I change, I.E. some keyboard shortcuts or customize the way the system behaves, I don’t have to do that twice. The settings that I’d like to be shared include applications related to the DE (Dolphin file manager, the terminal emulator).

I’d like to keep separated all the “user” files and applications that generally speaking don’t fall under the “system” category. So, documents, pictures, etc.. but also the settings of programs like Digikam that don’t natively support multiple user profiles.

I hope that all of this is clear. I can also settle on separate only the personal files and share all the settings (basically only the hidden files on the home folder).

Is it feasible to do so in a reasonable way? Or it will only result in a supreme mess?

Solution :

The simple solution would be to use symbolic links which are set up during log-in after creating both users with the same group and home directory and a umask of 0002.

Then create subdirectories $HOME/home and $HOME/work and create or move there the directories you want to be independent (eg mv $HOME/Documents $HOME/home, mkdir $HOME/work/Documents, etc).

Now in one of your log-in scripts (eg $HOME/.bashrc) check which log-in you are using and make the links:-

if "$(whoami)" == "WorkName"
then ln -sf "$HOME/work/Documents" "$HOME/Documents"
else ln -sf "$HOME/home/Documents" "$HOME/Documents"

That as I said is the simple solution, but its main disadvantage is that if you concurrently log in as the other user (using Ctrl-Alt-Fn, sudo -s, ssh) then it will either upset an existing session if it’s an interactive log-in or access the wrong directories if not.

The only way I see round this is to have separate home directories for each log-in and setting up links for each file and directory that you want shared, but this will involve a lot more links and it will entail constant vigilance as each new shared file or directory is added, eg on the installation of new software packages.

Leave a Reply

Your email address will not be published. Required fields are marked *