Copy permissions of files from one dir to another or how to change permissions and ownership of identical dirs.
Posted by valqk on
Have you ever been in the middle of deployment and noticed that the owner and permissions on dev package you have and production one are different?
Very oftern when deploing some sites I have two identical dirs with different owners and permissions - one from a dev web server and another from the production (where everything is tuned and working).
Here is a quick and durty way to change all ownership and permissions from prodution to development dir.
BE VERY CAREFULL. These permissions are not all masks. These are the one I needed!
Don't blind apply this script and run chm.sh after that!!!
FIRST check that you don't have some permissions rules in the chmod!!!
If you have 'chmod rw-r---- FILENAME' you will finish with -------- (0000) permissions!!!
You were warned!
mysite.production is a copy of the production dir somewhere else in the tree (your home for example).
and try to compare some files that have specific perms.
that's all.
I'm SURE there is an easier way, and I'll be glad to share!!!
Very oftern when deploing some sites I have two identical dirs with different owners and permissions - one from a dev web server and another from the production (where everything is tuned and working).
Here is a quick and durty way to change all ownership and permissions from prodution to development dir.
BE VERY CAREFULL. These permissions are not all masks. These are the one I needed!
Don't blind apply this script and run chm.sh after that!!!
FIRST check that you don't have some permissions rules in the chmod!!!
If you have 'chmod rw-r---- FILENAME' you will finish with -------- (0000) permissions!!!
You were warned!
mysite.production is a copy of the production dir somewhere else in the tree (your home for example).
$> find mysite.production/ ! -type l -ls | awk '{print "chmod "$3" "$11 " && chown "$5":"$6" "$11}' | sed -e 's/\.production//g' -e 's/-r--r--r--/044/' -e 's/-rw-rw-rw/0666/' -e 's/-rwxrwxrwx/0777/' -e 's/-rwx------/0700/' -e 's/-rwxr-xr-x/0755/' -e 's/-rwxr-x---/0750/' -e 's/-rw-r--r--/0644/' -e 's/-r-x------/0500/' -e 's/drwxr-xr-x/755/' -e 's/drwxrwxrwx/777/' > chm.sh
$>sh chm.sh
and try to compare some files that have specific perms.
that's all.
I'm SURE there is an easier way, and I'll be glad to share!!!
Trackbacks
Trackback specific URI for this entryThis link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.
No Trackbacks
Comments
Display comments as Linear | ThreadedNo comments