This article shows how to set-up a shared folder between two local users in Linux. The shared directory/folder will be accessible to both the users, they will be able to read/write each other’s file.
Let us create shared directory /home/shareFolder for user Bob and Alice and add them to a common group named projectA.
Note: You can create the uses Bob and Alice using following commands:
$ sudo useradd Bob $ sudo passwd Bob $ sudo useradd Alice $ sudo passwd Alice
- So, start by creating common group using groupadd command.
$ sudo groupadd projectA
- Now, create shared directory and change group for it using chgrp command.
$ sudo mkdir /home/sharedFolder/ $ sudo chgrp projectA /home/sharedFolder
- After this we need to change appropriate permissions for the shared directory using chmod command.
$ sudo chmod 770 /home/sharedFolder/
Here 770 permission means:
7 – owner has rwx permissions. 7 – directory groups have rwx permissions. 0 – others have no permissions.
- We also need to set the SGID(Set-Group-ID) bit for the sharedFolder directory, now all newly created subdirectories/files under sharedFolder will inherit sharedFolder permissions.
$ sudo chmod +s /home/sharedFolder
- Finally we add users to the common group with whom to share the folder
$ sudo usermod -a -G projectA Bob $ sudo usermod -a -G projectA Alice
Now /home/sharedFolder is accessible to both the user Bob and Alice. But others can’t access this directory. This directory will be accessible to only members of projectA group.
- Create a shared Folder between Host OS and Guest OS ( Virtual Box)
- Chat application between two processes using signals and shared memory
- Create Directory or Folder with C/C++ Program
- How to create a Folder without any name and icon in Windows OS?
- POSIX shared-memory API
- How to rename all files of a folder using Java?
- Linux Operating System | CLI (Command Line Interface) and GUI (Graphic User Interface)
- Configure Passwordless Sudo For A Specific User in Linux
- User Management in Linux
- Anonymity and Privacy For Linux User
- Deleting a User in Linux using Python Script
- Creating a User With an Expiry Date in Linux
- Difference Between Arch Linux and Kali Linux
- Linux Virtualization : Linux Containers (lxc)
- How to Create Reverse Shells with Netcat in Kali Linux?
- TABBY Hack The Box Walkthrough for User Flag
- How to Transparently Overlaid Two Directories Using UnionFS in Linux?
- Difference Between Ubuntu and Kali Linux
- Difference between locate, which and find Command in Linux
- Difference Between Ubuntu and Red Hat Linux
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.