How to share a folder between two users on the same linux laptop

  1. Ubuntu 20.4 installed with user Marco
  2. created other user Polo by going to |settings > Users > Add User|
  3. created "commonDir" folder in Marco’s home directory. |right click > new folder|
  4. logged out from Marco. |click top right corner > power Off/Log Out > Log Out|
  5. logged into Polo
  6. navigated to Polo’s home directory but "commonDir" folder was not visible.

What should I do in order to make it accessible by both the users.?

(Still working my way through linux commands. That’s why I’m using UI to do all the things)

Asked By: As13


Should the commonDir folder be readable by both or writable by both?

If you want it to be readable by the other user:
Try $ cd ../Marco/commonDir from Polo’s home directory.
With the GUI:
Go to Files, and click Other Locations. Click on home, then Polo, then commonDir.

If you want commonDir to be writeable, try as Marco:

$ sudo groupadd commonDir
$ sudo chgrp commonDir ~marco/commonDir 
$ sudo usermod -a -G commonDir Polo 
$ sudo chmod 775 ~marco/commonDir 

Then as Polo:

$ newgrp commonDir
$ cd ~marco/commonDir
$ gnome-text-editor whatever_is_in_the_folder

Note: You have to do the above every time you want to write to things in the commonDir directory.

Answered By: Lovecodeabc