1

if i'm not owner

i'm using visual studio editor

i can't change the code in any file in /var/www/html/

because of this command

sudo chown -Rf www-data:www-data /var/www/html/

i need to know how can i be able to change the files

sudo -Rf chown www-data:username /var/www/html/

sudo chmod -Rf 775 /var/www/html/

those lines can help !?

5
  • 1
    Add yourself to a group that this file belongs to , change permissions to 775 , and you should be able to edit it without sudo Aug 7, 2015 at 22:03
  • see edit :) ,,,,,
    – I'm V
    Aug 7, 2015 at 22:41
  • @Serg could you please elaborate that and post it as an answer? Including the usermod command to add the user to the group www-data .
    – Jos
    Aug 7, 2015 at 22:56
  • @Jos I'm on mobile. I can post later or if you wish you can post that yourself. I don't mind Aug 7, 2015 at 23:21
  • possible duplicate of How to avoid using sudo when working in /var/www?
    – muru
    Aug 8, 2015 at 9:26

1 Answer 1

0

The folder /var/www/html is owned by user www-data and group www-data. So, as suggested by @Serg, the solution is to add yourself to the group that owns this file, in this case: the group www-data:

sudo usermod -G www-data username

Then, change permissions of the directory to 775:

chmod -R 775 /var/www/html

and you should be able to edit the file.

2
  • same problem :(
    – I'm V
    Aug 8, 2015 at 17:07
  • 1- sudo gpasswd -a "$USER" www-data 2- sudo chown -R "$USER":www-data /var/www .... these commands solved the problem thanks all :)
    – I'm V
    Aug 8, 2015 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .