How to Create a Shared Directory for All Users in Linux

As a system administrator, you may have a certain directory that you want to give read/write access to every user on a Linux server. In this guide, we will review how 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 tecmint

Create Common Directory Group

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.

tecmint – existing username.

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

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

12 Responses

What if a user copies or moves a directory tree from his home directory to the shared one?
I don’t think the subdirs will magically change their group, let atone recursivelyy because they are not newly created…

I assume that on your distro Apache has a base directory in /var/www unlike a distro like Fedora that starts in /var/www/html/. This would be good for users that want to build a web site together or share common reports over a web server. Another good option is to use ACL with the facl command.

You should probably highlight that /var/www isn’t a good place to allow ‘regular users’ to store stuff unless you can guarantee it is on a separate filesystem than /var; should a user decide to fill it up system log files no longer can be written