0

The problem: I can manually delete some sub folders and others not. They are all inside the same folder.

I'm talking about the /var/www/html folder and an application I'm developing inside it.

How it looks:

enter image description here

As you can see, there is one folder that has a padlock icon. It means I cannot rename or remove elements inside. But my web application can.

My web application can remove elements from all these folder. And me, as Ubuntu user I can do it also, except for the "microsite" folder.

NOTE:

LAMP_HTML is the desktop shortcut for /var/www/html

Panel4 is the name of my web application

ubuntu is my username in ubuntu

www-data is the apache group which have permissions to modify and remove elements inside /var/www/html folder

The sub folders inside these in the picture have numbers as folder names, which are the ID of the element of the application, blablabla

I'm an Linux Console noob, I will tell you what I have done when doing research:

Checking folder permissions:

ubuntu@UbuntuPC:~$ ls -la /var/www/html/Panel4/uploads
total 40
drwxrwsr-x 10 www-data www-data 4096 ene 17 19:15 .
drwxrwsrwx 16 www-data www-data 4096 ene 19 17:16 ..
drwxr-sr-x  5 www-data www-data 4096 ene 20 23:20 microsite
drwxrwxr-x  3 www-data www-data 4096 dic 21 14:15 product
drwxrwxr-x  3 www-data www-data 4096 dic 21 14:09 productcategory
drwxrwsr-x  5 www-data www-data 4096 ene 11 13:05 property
drwxrwxr-x  2 www-data www-data 4096 dic 19 20:35 repository
drwxrwxr-x  3 www-data www-data 4096 dic 21 14:07 service
drwxrwxr-x  3 www-data www-data 4096 dic 20 23:14 servicecategory
drwxrwxr-x  2 www-data www-data 4096 dic 19 20:35 slideshow

Checking the "microsite" folder permissions:

ubuntu@UbuntuPC:~$ ls -la /var/www/html/Panel4/uploads/microsite
total 20
drwxr-sr-x  5 www-data www-data 4096 ene 20 23:20 .
drwxrwsr-x 10 www-data www-data 4096 ene 17 19:15 ..
drwxr-sr-x  4 www-data www-data 4096 ene 20 22:06 2
drwxr-sr-x  4 www-data www-data 4096 ene 20 23:05 3
drwxr-sr-x  4 www-data www-data 4096 ene 20 23:20 4

Checking "product" folder permissions (which I can manage with my web app and as ubuntu user)

ubuntu@UbuntuPC:~$ ls -la /var/www/html/Panel4/uploads/product
total 12
drwxrwxr-x  3 www-data www-data 4096 dic 21 14:15 .
drwxrwsr-x 10 www-data www-data 4096 ene 17 19:15 ..
drwxrwxr-x  4 www-data www-data 4096 dic 21 14:15 1

As you can see, the output is the same for both folders. And I can remove stuff from one but not from the other. I'm confused. I need control over all these folders as Ubuntu user and my web application needs it too.

any Ideas?

0

I noticed the s in the permission setting. It did take me a while to finally figure it out. It is actually simple.

sudo adduser myUserName www-data

This function add you to be part of www-data group (so that way you CAN write and edit without the lock). After that function, you will want to standardize everything in the html folder in order for new permission to be in effect by executing these commands.

## reseting folders and standardize everything in /var/www/html
## so apache can serve files
sudo chown -R www-data:www-data /var/www/html  

## so you can write these files owned by apache
chmod -R 775 /var/www/html   ## see EDITED below

EDITED: use chmod -R 775 /var/www/html, not sudo chmod -R 775 /var/www/html

## ensure that everything is checked (using ls is not reliable this is safer)
shopt -s nullglob
files=("/var/www/*");
for f in "${files[@]}"; do sudo umask 002 $f; done   ## fixing files and directories

This also will correct the s issue in permission, just like what you stated.

  • Everything worked... now I need to ensure that the NEW folders that my web app create have the same permissions... they all appear with the padlock after created. How do I do the last part? it says umask command not found... do I do it in the gedit? or where? THANK YOU – JuanBonnett Jan 21 '15 at 16:32
  • Now you have pointed this out - to have it to create same permission on new files/folders as a default - sudo chmod 775 /var/www without -R. It will release the whole html be set to your default. I usually do sudo chmod 775 /var/www/* but uneeded. It's my habit to make sure all of my hidden folders/files are defaulted to my chmod....oh yes, reboot! :) – Faron Jan 21 '15 at 20:44
  • Haven't had success :( Did what you told me and still padlocks on new folders – JuanBonnett Jan 23 '15 at 20:04
  • Doh me. I made a edited input in my answer. You dont use sudo chmod ... after sudo chown ... command but instead, use chmod ... after sudo chown. – Faron Jan 25 '15 at 14:48
1

Folder /var/www/html/Panel4/uploads/microsite has a SGID enabled. The microsite directory, its parent directory and all its sub-directories have SGID enabled and which can be identified with the s bit set in group part of the permission drwxr-sr-x.

As SGID is set any folder that is created within it will have group-id set to that of the parent directory. And if any binary file gets set with SGID then when you execute it the group-id of the user will be changed to the group-id of the binary.

But the SGID is not causing the issue, these folders don't have group write permission set for those directories. And so you cannot delete or create new files/folders inside them. To avoid this run chmod g=rwx <folder-name> to give write permission.

And also add your uername as the member of www-data group.

For more about linux file permission refer this.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.