Knowledgebase

How to Create a Shared Directory for All Users in Linux?

To enable write access to all users on a particular directory (shared directory) in Linux.

 

This calls for setting the appropriate access permissions, and the most effective as well as reliable method to allocating a common group for all the users who will share or have write access to the specific directory.

 

So, start by creating the directory and common group in case it doesn’t already exist on the system as follows:

$ sudo mkdir -p /var/www/reports/
$ sudo groupadd project 

 

Then add an existing user who will have write access to the directory: /var/www/reports/ to the group project as below.

$ sudo usermod -a -G project rootadminz

 

The flags and arguments used in the above command are:

  • -a – which adds the user to the supplementary group.
  • -G – specifies the group name.
  • project – group name.
  • rootadminz – existing username.

 

Afterwards, proceed to configure the appropriate permissions on the directory, where the option -R enables recursive operations into subdirectories:

$ sudo chgrp -R project /var/www/reports/
$ sudo chmod -R 2775 /var/www/reports/

 

Explaining the permissions 2775 in the chmod command above:

  • 2 – turns on the setGID bit, implying–newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set GID bit of the parent directory.
  • 7 – gives rwx permissions for owner.
  • 7 – gives rwx permissions for group.
  • 5 – gives rx permissions for others.

 

You can create more system users and add them to the directory group as follows:

$ sudo useradd -m -c "Vyga V" -s/bin/bash -G project vygav
$ sudo useradd -m -c "Jarvis" -s/bin/bash -G project jarvis
$ sudo useradd -m -c "Anupama" -s/bin/bash -G project anupama

 

  • Create a Shared Directory for All Users
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to upload a file using File Manager in cPanel

Sometimes it's necessary to upload files to your cPanel account. This can be easily accomplished...

How to configure custom name servers

If you have a reseller, you can set up and use custom name servers. For example, if your domain...

How to Create WHM Accounts/Master/Alpha in Zamfoo ??

1. Login to your WHM 2. Click on Add Package 3. Create a Package for Reseller/MasterReseller...

How to add a package in WHM?

How do I add, edit and delete packages in WHM? The following article explains how to add, edit...

How to Configure PayPal in WHMCS

Part 1: Initial Setup in WHMCS    Begin by going to Setup > Payment Gateways in WHMCS....