Open In App

How to create a Shared Folder between two Local User in Linux?

Last Updated : 11 Jul, 2022
Like Article

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

  1. So, start by creating common group using groupadd command.
    $ sudo groupadd projectA

  2. Now, create shared directory and change group for it using chgrp command.
    $ sudo mkdir /home/sharedFolder/
    $ sudo chgrp projectA /home/sharedFolder

  3. 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.

  4. 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 

  5. 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.

Similar Reads

Create a shared Folder between Host OS and Guest OS ( Virtual Box)
How to create a shared folder between host Operating System and Guest Operating system? This is the scenario that you run Windows as your host operating system and Ubuntu in a VirtualBox, and that you want to access a specific Windows folder from Ubuntu. In short- Share a folder between Host OS-> Windows and Guest OS ->Ubuntu(Virtual box) Ste
2 min read
Chat application between two processes using signals and shared memory
Prerequisite: C signal handling, IPC through shared memory A signal is used in the UNIX system to notify a process that a particular event has occurred. A signal may be received either synchronously or asynchronously depending on the source and the reason for the event being signalled. A signal must follow the following pattern - 1. A signal is gen
3 min read
How to create a Folder without any name and icon in Windows OS?
Have you thought about hiding your confidential content or data somewhere that no one else could find out? What if this article tells you that you will be able to do just that, but the data will not be in plain and everyday sights of anyone, but still no one will be able to find it. Have you ever tried not to leave it blank? You must have tried and
2 min read
How to Create a Secure Folder on Your Phone?
Most probably, there is a maximum number of users who have some private documents. Some have provided images or videos that are completely confidential. Users are most likely to create a password or use their biometrics to open their mobiles. However, there is no security to their confidential documents. If a device is stolen by any individual, the
5 min read
Create Directory or Folder with C/C++ Program
Problem: Write a C/C++ program to create a folder in a specific directory path. This task can be accomplished by using the mkdir() function. Directories are created with this function. (There is also a shell command mkdir which does the same thing). The mkdir() function creates a new, empty directory with name filename. // mkdir() function int mkdi
2 min read
POSIX shared-memory API
Several IPC mechanisms are available for POSIX systems, including shared memory and message passing. Here, we explore the POSIX API for shared memory. POSIX shared memory is organized using memory-mapped files, which associate the region of shared memory with a file. A process must first create a shared-memory object using the shm_open() system cal
4 min read
DriveSync Local Files with Google Drive using Linux CLI
In this article, We will see how-to DriveSync local files with Google Drive from Linux CLI. Google Drive is widely used for cloud storage. It allows us to access, upload, or download the documents or files inside our drive from any location or device, provided proper authentication. DriveSync is a command-line interface(CLI) tool that synchronizes
3 min read
Rdiff-backup - A Local and Remote Backup Tool for Linux
The Rdiff-backup(Reverse differential backup tool) is a backup tool that backs up one directory to another, either locally or remotely. It is a powerful tool written in Python, that works best with Linux. It works with Windows and Mac OS X as well. Users have reported that it works well on the cross-platforms like FreeBSD. It works on the protocol
4 min read
How to Compare Local and Remote Files in Linux
In this article, we will discuss how to compare or differentiate between local and remote files in Linux. Programmers and writers often want to know the difference between two files or two copies of the same file when writing program files or regular text files. The discrepancy between the contents of two Linux machine files is referred to as a dif
3 min read
Woof - Easily Exchange Files Over a Local Network in Linux
In order to easily share single files between Linux systems in a home network where we don't need to worry too much about security. Woof is an acronym for Web Offer One File. It is used to share files over a local area network. The recipient need not have any special software installed on his system, The shared file may be downloaded using curl, ge
3 min read
Article Tags :