Jump to content


Photo

bash Script file for setting permissions and ownership of directories and files

installation permissions

  • Please log in to reply
4 replies to this topic

#1 Burke

Burke

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts
  • LocationLawrenceville, GA

Posted 20 March 2015 - 06:48 PM

Here is a bash script Attached File  zurmopermissions.zip   1.25KB   403 downloads originally created by  Francis Byrne  that I have modified to add better parameter handling and ownership of directories and files as well.

 

we use this when initially setting up sites  and it makes it easy and reliable to make sure you get the permissions set properly.

 

run the script with only the directory parameter -p  and as the defaults are good for most linux environments

 

 

*****************************************

 

Usage: ./setpermissions.sh PATH -d DIRPERMS -f FILEPERMS -o OWNER -g GROUP

 

Options: 

-p ROOTDIR, path to path to the rootdir directory you wish to modify permissions for

-d DIRPERMS, directory permissions

-f FILEPERMS, file permissions

-g GROUP, Group to assign

-o OWNER, Owner to assign

 

*****************************************

 

 

defaults are 

  • -d 755
  • -f 644
  • -o www-data
  • -g www-data


#2 Administrtr

Administrtr

    Advanced Member

  • Members
  • PipPipPip
  • 174 posts

Posted 20 March 2015 - 10:05 PM

One advice for the novice linux users: please DON'T blindly follow the script!

 

Not all linux distro's use the same user/group suggested in this script. You obviously have to know which user your webserver requires. For sites served with apache on archlinux for example, it's http:http for user:group.

 

Also, if you f*ck up and accidentally use the wrong path, e.g. /, all your files' permissions will change without the possibility of "undo" or restoring, unless you have a backup. :D

 

So please be advised that this solution will only work if you know your specific server environment and you have to know at least some basic things of how linux commandline works.



#3 Burke

Burke

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts
  • LocationLawrenceville, GA

Posted 15 April 2015 - 01:12 AM

One advice for the novice linux users: please DON'T blindly follow the script!

 

Not all linux distro's use the same user/group suggested in this script. You obviously have to know which user your webserver requires. For sites served with apache on archlinux for example, it's http:http for user:group.

 

Also, if you f*ck up and accidentally use the wrong path, e.g. /, all your files' permissions will change without the possibility of "undo" or restoring, unless you have a backup. :D

 

So please be advised that this solution will only work if you know your specific server environment and you have to know at least some basic things of how linux commandline works.

 

 

thanks for the disclaimer, I should have mentioned something to that effect.



#4 oldrose

oldrose

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts
  • LocationAustralia

Posted 16 November 2015 - 04:55 AM

Our servers are configured differently and the script above does not work, probably because the zurmo file owner is not in the apache group. In our case the right settings were:

 

- from the root directory of the Zurmo installation

sudo chown -R [user]:[apache group] * 

sudo chmod -R u=rw,g=r,o= *

sudo chmod -R u=rw,g=rw app/assets           
sudo chmod -R u=rw,g=rw app/protected/runtime
 
This locks write permissions down on directories to the [user] and only opens write access up to the directories the apache user needs access to


#5 MBHaney

MBHaney

    Newbie

  • Members
  • Pip
  • 3 posts
  • LocationUtah, USA

Posted 18 January 2016 - 12:58 AM

The script works great on my opensuse Leaps linux distro. 

I just had to change the owner to wwwrun and group to www as thatis what this distro sets up to run the lamp stac,.

 

Thanks fror sharing the script!







Also tagged with one or more of these keywords: installation, permissions

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users