How to make a directory permanently writable?

280,166

Solution 1

Numeric permissions can solve your problem.

sudo chmod 775 'your directory'

if you want to know why only 775 here's your answer

400 read by owner
040 read by group
004 read by anybody
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody

 400
+040
+004
+200
+020
+100
+010
+001
=775

It will give all permission except write by anybody.

Solution 2

I had the same problem then

sudo chmod 777 directory

solved it.

That makes the directory writable, readable and executable by anybody. So doesn't matter what user or group owned it or used Lampp.

However, that isn't recommended if your computer is public access.

Solution 3

Usually the command you used should change the permissions permanently.

Try sudo chmod -R 775 /var/www/ (which basically is the same). If that doesn't work you might need to change the owner [and maybe the group] of the directory via sudo chown <user>[:<group>] /var/www/.

Also, you might consider the 'permission denied error' could be caused by insufficient access rights in your database or elsewhere.

Share:
280,166
potomato
Author by

potomato

Updated on September 18, 2022

Comments

  • potomato
    potomato over 1 year

    I am using LAMP stack for development and I have a problem with making /var/www permanently writable. I use this command:

    sudo chmod -R a+rwX /var/www
    

    This works, but after putting a web app and accessing it through a browser, it show a "permission denied" error. When that happens, I have to the execute the command again.

    How can I make the directory writable, permanently, without having to run the command again?

    Thanks!

    • Anam Ahmed
      Anam Ahmed about 11 years
      create a subfolder in /var/www and change permisson for that directory. That should fix the issue
    • Goran Miskovic
      Goran Miskovic about 11 years
      Actually you should never ever make web root writable. See For security reasons why should /var/www not have chmod 777?
    • precise
      precise over 10 years
      these are some good comments above... considering the security reasons, you should keep permission for /var/www to default rwxr-xr-x and you'd probably move the required files to a sub-directory in /var/www and make changes to your *html files accordingly for the changes you've made to the document root.
  • Weasel
    Weasel about 11 years
    But as @schkovich already mentioned you should not make the web root folder writeable.
  • Marcel
    Marcel over 9 years
    +Rinzwind I used 777 and am patiently waiting your visit.
  • Yarh
    Yarh almost 8 years
    it worked for me if i use it without slashes e.g sudo chmod -R 775 my_folder
  • Dheeraj
    Dheeraj over 7 years
    @Marcel is now dead guys, @ Rinzwind ended him
  • Marcel
    Marcel over 7 years
    @Dheeraj Then who is this...
  • Dheeraj
    Dheeraj over 7 years
    @Marcel how do we know its the real you, what if @ Rinzwind tore marcel's face and wore it.
  • Joe
    Joe over 6 years
    Thanks @Marcel! Using 777 worked for me when 775 and nothing else worked! Now my folder is finally writable! (Sorry @Rinzwind).
  • Sabrina
    Sabrina over 3 years
    it works on macOS.