I am using LAMP Apache version 2.2.15 on CentOS 6.6.

I have created a directory /var/www/dropbox which has permissions rwxrwsr-x. I have made the group www-OtagoHarbour the owner where www-OtagoHarbour was created using

sudo groupadd www-OtagoHarbour
sudo usermod -G www-OtagoHarbour apache
sudo usermod -G www-OtagoHarbour OtagoHarbour

I have given apache ownership of the directory using

sudo chown apache /var/www/dropbox

and the group access using

sudo chgrp -R www-OtagoHarbour /var/www/dropbox
sudo chgrp -R www-OtagoHarbour /var/www
sudo chmod -R g+r /var/www/dropbox
sudo chmod -R g+r /var/www

I upload files to that folder using the following html call.

<form action="http://whatever.com/uploadFiles.php" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file[]" multiple="multiple"/></br>
    <input type="submit" name="submit[]" value="submit" />
<input type="hidden" id="LoggedIn" name="LoggedIn" value="<?php echo $_SESSION['LoggedIn'] ?>">
<input type="hidden" id="setName" name="setName" value="<?php echo $setName ?>">
<input type="hidden" id="UserName" name="UserName" value="<?php echo $_SESSION['UserName'] ?>">

uploadFiles.php copies the uploaded files into /var/www/dropbox. Unfortunately, the permissions of the uploaded files are -rw-r--r-- whereas I would like them to be -rw-rw-r--. I tried

sudo find /var/www/dropbox -type d -exec chmod 2775 {} \;

and rebooted the computer but the uploaded files still have permission -rw-r--r--. I know I can change the permissions using

sudo chmod g+w fileName

but I would like this to be done automatically since I have code that processes the files and sends them elsewhere.

  • 1
    Just a side note, files shouldn't be marked executable unless they specifically need to be executable. Hint: very few files need to be executable. Maybe I'm misreading that find command. – killermist Jan 28 '15 at 1:25

I found that I could set the default permissions, for new files created in the folder to -rw-rw----. using

setfacl -dm u::rw,g::rw,o::--- /var/www/dropbox

I then create a "placeholder" file in /var/www/dropbox using

echo "junk" >/var/www/dropbox/file.name

If I then copy a file, file.name, into /var/www/dropbox, it assumes the permissions of the file it is overwriting.

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.