Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
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 ...
  1. #1
    Just 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?

  2. #2
    Just 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.

  3. #3
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    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.

  4. #4
    Just 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.

  5. #5
    Just 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.

  6. #6
    Linux Newbie unlimitedscolobb's Avatar
    Join Date
    Jan 2008
    Posts
    120
    Quote Originally Posted by mahesh123 View Post
    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.
    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.

  7. #7
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    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":
    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
    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.
    Last edited by Mudgen; 01-30-2011 at 05:29 PM. Reason: add back usage explanation

  8. #8
    Just Joined!
    Join Date
    Jan 2011
    Posts
    5
    This worked perfectly for me !!!!

    Thanks a ton for your help !!!!

    I appreciate it !!!

  9. #9
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    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.

  10. #10
    Just 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.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...