Results 1 to 10 of 11
Hi Gurus,
I've done the most dumbest thing. I did change owner and group on a major directory using chown user:group * command. This directory has a ton of sub-directories ...
- 01-29-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 5
Need immediate help with directory permissions
Hi Gurus,
I've done the most dumbest thing. I did change owner and group on a major directory using chown user:group * command. This directory has a ton of sub-directories and many more subdirectories within each of them with an assortment of user and group permissions on each of them. Is there any way that I can revert to the original existing permissions?
- 01-30-2011 #2Just Joined!
- Join Date
- Aug 2007
- Location
- Florida
- Posts
- 1
This is relatively simple. You repeat the command using the original settings. Did you do this as root?
If you forgot what the settings were, then more information is needed.
- 01-30-2011 #3
If you didn't use "-R" on your chown command, then only the objects (files and directories) in the level you were in were affected, no files or directories below that, which should vastly simplify fixing things. Is there any kind of backup you can look at to see the original settings? Linux doesn't keep any kind of history of ownership on its own.
- 01-30-2011 #4Just Joined!
- Join Date
- Jan 2011
- Posts
- 5
Dear billtouch,
Yes, I did it as root. I do not remember what the original settings were. But we do have another machine with a similar directory structure. I can use that as a reference.
- 01-30-2011 #5Just Joined!
- Join Date
- Jan 2011
- Posts
- 5
Dear Greyhairweenie,
I'm in a much worse situation. Initially I haven't used "-R" on my chown command. As soon as I realized that I've changed the owner permissions incorrectly, I did go to GUI and changed permissions on each of the sub directories of /u01 and applied changes to all the contained sub-directories and files.
- 01-30-2011 #6
If the system is a non-critical desktop system, I'd recommend reinstalling the OS. As a partial solution you may considering investigating the ownership settings of the corresponding directories and files in a different instance of your OS, but this should be very tedious.
- 01-30-2011 #7
OK. This is still somewhat quick and dirty, but tested on a sacrificial lamb. There's probably a way to get one find to do both the dirs and the files, but this way works and is probably good enough. It does only dirs and files, and handles names with spaces in them. If you've managed to create files with metacharacters in the names, it's not going to handle those. I'm going to put a version of it in cron.daily for myself.
Script for "saveperms.sh":
Run this from /u01 on the good system, inspect output for safety, then copy the /tmp/fix* scripts to the hosed system, make executable, and run from /u01. It will fix the stuff that exists on both systems. Make sure you have a backup to get back to where you are now, though. This is in good faith but no warranty.Code:#!/bin/bash #set -x find . -type d|while read file do echo chown `stat -c "%U:%G" "$file"` "$file" echo chmod `stat -c "%a" "$file"` "$file" done > /tmp/fixdirs.sh # find . -type f|while read file do echo chown `stat -c "%U:%G" "$file"` "$file" echo chmod `stat -c "%a" "$file"` "$file" done > /tmp/fixfiles.sh
Last edited by Mudgen; 01-30-2011 at 05:29 PM. Reason: add back usage explanation
- 01-30-2011 #8Just Joined!
- Join Date
- Jan 2011
- Posts
- 5
This worked perfectly for me !!!!
Thanks a ton for your help !!!!
I appreciate it !!!
- 01-30-2011 #9
Glad to be of help. I was bored today, and I figure this is something I can use later.
If you don't mind saying, are these Oracle systems? The "/u01" is OFA compliant, although that's not the only place you see it.
- 01-30-2011 #10Just Joined!
- Join Date
- Jan 2011
- Posts
- 5
yes... Ours is a 3 node RAC environment and I happened to mess up on one of our nodes.


Reply With Quote
