Score:2

Permission denied on /var/www despite adding user to the owner of directory

cn flag

Hi brand new setup here.

ls -ld /var/www
drwxr-xr-x 3 www-data www-data 4096 Feb 25 18:10 /var/www

so above shows that /var/www belongs to www-data

I then add current user to www-data

sudo usermod -a -G www-data ahdee
groups ahdee
ahdee : ahdee sudo www-data

however while in /var/www I tried this and still got permission denied.

echo "hi" > t.txt
mkdir test 

A bit confused because the owner is www-data and ahdee belongs to that group so why can't I write to it?

thanks in advance.

cn flag
Ray
Did you log out and log back in before you tried your test?
us flag
Group write is not enabled on the directory. `chmod 02775 /var/www`.
Ahdee avatar
cn flag
@doneal24 great thanks, as explained below group members have to write access
Score:3
au flag

The first "www-data" is the owner of the file, the second "www-data" is the group.

In the ls -l, the first block shows the access rights:

drwxr-xr-x
d              it's a directory
 rwx           the owner www-data may read, write and enter the directory
    r-x        members of the group www-data (e.g. you) may read and enter,
               but not write in there (e.g. create a new file)
       r-x     others may read and enter, too, but not write.

So, you'd have to change the permissions, so that group members may write: chmod g+w /var/www

Ahdee avatar
cn flag
This is perfect and also helps me understand a bit more, thank you. FYI for others, I had to relog back in to get it to work.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.