1

I am using Ubuntu 16.04 installed on Virtual box. I have installed LAMP and git successfully. I tried to clone my git repository using terminal but it shows:

fatal: could not create work tree dir 'directory-name': Permission denied

I tried to give directory permission using the following command:

sudo chmod 755 /var/www/html

but it is not working.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Mustafa
  • 339
  • 7
  • 20
  • It seems that this is better posted on SuperUser or AskUbuntu rather than StackOverflow. – Karl Wilbur Apr 17 '17 at 19:39
  • Please elaborate on "it is not working". *What happens* when you run the `chmod` command? – Chris Martin Apr 17 '17 at 20:34
  • When I run the command `chmod`, it says nothing. After run this command I again tried to clone my repository. The result was same. Also I am not able to create directory. It throw the same message: **Permission denied**. – Mustafa Apr 18 '17 at 03:56

1 Answers1

2

It's a fresh install, so the owner of the /var/www/html folder is probably root ? If it is a development environment do the following commands as root, it will probably fix you permissions issue :

groupadd www-data
usermod -a -G www-data yourUsername
chown -R root:www-data /var/www
find /var/www -type d -exec chmod 2775 {} +
find /var/www -type f -exec chmod 0664 {} +
YoannFleuryDev
  • 914
  • 1
  • 12
  • 22
  • When I run the following command: `usermod -a -G www-data myUsername` it shows the following message: `usermod: Permission denied.` `usermod: cannot lock /etc/passwd; try again later.` – Mustafa Apr 18 '17 at 18:09
  • It works. For this I need to run: `sudo su` Then the commands you suggest. Now I can clone my repositories from git though it gives the following error: `error: RPC failed; curl 18 transfer closed with outstanding read data remaining` – Mustafa Apr 18 '17 at 19:28
  • For the second comment, it's another issue you got here. Don't seem to be a permission issue with this output. Maybe you can find something here: http://stackoverflow.com/questions/38618885/error-rpc-failed-curl-transfer-closed-with-outstanding-read-data-remaining – YoannFleuryDev Apr 19 '17 at 08:18
  • got it. Thanks for your help. – Mustafa Apr 19 '17 at 08:34