Home » Questions » Computers [ Ask a new question ]

How can I give write-access of a folder to all users in linux?

How can I give write-access of a folder to all users in linux?

I installed apache2 on Ubuntu just now, and noticed that the /var/www folder is protected. I can just sudo everything but I would rather just give it write access.

Asked by: Guest | Views: 317
Total answers/comments: 2
Guest [Entry]

"To best share with multiple users who should be able to write in /var/www, it should be assigned a common group. For example the default group for web content on Ubuntu and Debian is www-data. Make sure all the users who need write access to /var/www are in this group.

sudo usermod -a -G www-data <some_user>

Then set the correct permissions on /var/www.

sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www

Additionally, you should make the directory and all directories below it ""set GID"", so that all new files and directories created under /var/www are owned by the www-data group.

sudo find /var/www -type d -exec chmod 2775 {} \;

Find all files in /var/www and add read and write permission for owner and group:

sudo find /var/www -type f -exec chmod ug+rw {} \;

You might have to log out and log back in to be able to make changes if you're editing permission for your own account."
Guest [Entry]

"There's a simpler way to do this, try doing this command.

sudo chmod -R 757 /var/www

Essentially, the chmod command alters permissions and the -R switch affects all users. Then it is simply giving the correct permissions to use."