1

Hi just installed Apache2 on Ubuntu 20.04. Added myself to www-data group. id prateek

uid=1000(prateek) gid=1000(prateek) groups=1000(prateek),4(adm),24(cdrom),27(sudo),30(dip),33(www-data),46(plugdev),120(lpadmin),131(lxd),132(sambashare)

changed the ownership and permission of /var/www/bihag.moops/public_html.

ls -l /var/www/bihag.moops/ 
total 4 
drwxrwxr-x 3 www-data www-data 4096 Aug 11 07:58 public_html

Folders inside public_html also belongs to the same group.

ls -l /var/www/bihag.moops/public_html/
total 8
-rwxrwxr-x 1 www-data www-data  191 Aug 11 07:54 index.html
drwxrwxr-x 2 www-data www-data 4096 Aug 11 07:59 logs

Still can't write to public_html. Even though I am the member of the same group. Why this discrimination?

touch home.php
touch: cannot touch 'home.php': Permission denied

Note: Even though this is a local machine. I don't want to use 777 permission.

Additionally:

lsattr /var/www/
--------------e----- /var/www/bihag.moops
--------------e----- /var/www/html

And

lsattr /var/
--------------e----- /var/mail
--------------e----- /var/log
--------------e----- /var/www
GunJack
  • 361

1 Answers1

0

You might want to check on the extended attributes of /var/www (and its subdirectories), like so:

$ lsattr /var/www # or /var/www/bihag.moops, or /var/www/bihag.moops/public_html

If the i (immutable) attribute is set, e.g. you see something like:

----i--------------- /var/www

then that could explain why you cannot create a new file in the directory even with the right permissions. In that case, you could remove the i attribute by doing:

$ sudo chattr -i /var/www # or /var/www/bihag.moops, or /var/www/bihag.moops/public_html
  • No immutable attribute. It has an e attribute. I will update my question to reflect the output of these commands. – GunJack Aug 11 '20 at 04:57