Score:0

How can one let two users share the same home directory in Xubuntu 20.04

in flag

I want to create two users (e.g. adm1 and adm2), because each of them wants his own password, to which he is used. They shall share the same home directory however, let's call that admx.

Is this possible?

If it is: How does one achieve it?

(of course they both will belong to the same group=admx)

vanadium avatar
cn flag
Some good info here: https://unix.stackexchange.com/questions/90684/can-you-give-a-user-account-multiple-passwords Feasable, but not straightforward. Better educate your users to use a single password for a single account.
Score:3
cn flag
raj

I would not recommend using the same home directory for multiple users, because important config files are located in the home directory. These are read and written by various programs which may cause conflicts between users. Plus some of these files need to be accessible only by one user, otherwise the related program will refuse to work. It's better to create a subdirectory within one user's home directory that will be used by both users, and symlink that subdirectory in other user's home directory. Of course the subdirectory needs to be group writable by group admx and have the setgid bit set, so both users can create files within this directory and they will be automatically assigned to the group.

For convenience, you may put a cd command that changes to this subdirectory in each user's .profile file, so after login both users will start in that subdirectory and not in their home directory.

Score:0
in flag

Despite the warnings in the first solution I have played a bit with symlink after I read this keyword.

One might do it like this:

Suppose both administrators adm1 and adm2 are in the same group admx. Suppose /home/adm1 is the home directory of adm1 and it is properly configured. No work has to be done to provide adm2 with reasonable settings, since his directory will be replaced by a softlink to /home/adm1:

sudo rm -rf /home/adm2                 # remove the original home directory of adm2.
                                       # Note: adm2 must exist before his home directory
                                       # is replaced by a soft link, otherwise owner and 
                                       # group of the pointed to directory would change!
sudo chgrp admx /home                  # intermediate: now /home belongs root:admx
sudo chmod g+ws /home                  # intermediate: set w and SGID-bit to inherit group
sudo ln -s /home/adm1 /home/adm2       # create adm2's home directory as soft link
                                       # due to SGID-bit, root:admx own the link
sudo chmod g-ws /home                  # remove rights granted in step 2 and 3
sudo chgrp root /home                  # back in original state 
sudo chown -R adm1:admx /home/adm1     # make sure that adm2 gets access rights through group admx
sudo chmod -R g+s /home/adm1/          # establish group inheritance in favor of admx
sudo chmod -R g+w /home/adm1/.config/* # there might be programs like x-tile wanting to write there

The last two step are necessary because adm2 is not owner of /home/adm1.

The advantage of this solution - albeit more complicated compared to the solution above - is that it avoids duplicating ./config (not mentioned there) to the other administrator's home directory such that both enjoy the same settings. The second administrator gets all his power through the group admx. The SGID bit set at the end makes sure that subsequently created directories below /home/adm1 also inherit group admx.

raj avatar
cn flag
raj
However this will not work for some config files, especially ssh-related. For example, `/home/adm1/.ssh/config`, `/home/adm1/.ssh/identity` or `/home/adm1/.ssh/id_rsa` **must** be accessible only to one user, who is the owner of the file. So only one of your admins will be able to use ssh. There may be a similar issue for other security-sensitive programs and their config files. Also you did not give the `admx` group write access to other config files and subdirectories that may already exist in `/home/adm1` (for example `.local`), so `adm2` will not be able to modify their configuration.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.