The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Big Problem - I accidently chmod 000 a lot of files!

Discussion in 'General Discussion' started by noimad1, Jan 29, 2005.

  1. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I was working in a directory and I accidently put chmod -R 000 .*

    A lot of my root files and subfolders were chmod 0000!

    Anyone know how I could get the regular permissions back, or am I going to have to reload the entire server?
     
  2. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    where were you in / ?

    what directory
     
  3. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I was in a folder that i created called /downloads

    But the -R .* is what I think screwed me. after it did the files in the directory it moved up a directory level and started to do my /
     
  4. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    I see the .* did it.

    what does ls -l / give you
    I can give you what I have for the directories but by no means for the entire drive,

    If you look into /home for instance and see everything 000 bad news.
     
    #4 asmithjr, Jan 29, 2005
    Last edited: Jan 29, 2005
  5. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    The /home directory seems to be ok....but most other directories are 000. I've gone through and tried to match as many of them as I can to another server, but not with much luck....

    Some of the hard ones are like the /dev folder.....well all of the files in that folder.


    I think the main problem isn't the folders themselves, but all of the files inside those folders iwth the different permissions.....

    I think we are screwed....
     
  6. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    I believe you can use the rdist command to copy files and perms over, that is if you can do r type commands from machine to machine.

    either rdist or rsync might do the trick.
    Other than that you need a listing of the perms before.

    I'll keep thinking. but the rsync looks promising

    take a look at the rcync man page.

    Code:
    You use rsync in the same way you use rcp. You must  specify  a  source
           and a destination, one of which may be remote.
    
           Perhaps the best way to explain the syntax is some examples:
    
                  rsync *.c foo:src/
    
           this would transfer all files matching the pattern *.c from the current
           directory to the directory src on the machine foo. If any of the  files
           already  exist on the remote system then the rsync remote-update proto-
           col is used to update the file by sending only the differences. See the
           tech report for details.
    
                  rsync -avz foo:src/bar /data/tmp
    
           this would recursively transfer all files from the directory src/bar on
           the machine foo into the /data/tmp/bar directory on the local  machine.
           The  files  are  transferred in "archive" mode, which ensures that sym-
           bolic links, devices, attributes, permissions, ownerships etc are  pre-
           served  in  the  transfer.   Additionally,  compression will be used to
           reduce the size of data portions of the transfer.
    
                  rsync -avz foo:src/bar/ /data/tmp
    
           a trailing slash on the source changes this behavior  to  transfer  all
           files   from  the  directory  src/bar  on  the  machine  foo  into  the
           /data/tmp/.  A trailing / on a source name means "copy the contents  of
           this  directory".   Without  a trailing slash it means "copy the direc-
           tory". This difference becomes particularly important  when  using  the
           --delete option.
    
           You  can  also  use rsync in local-only mode, where both the source and
           destination don´t have a ´:´ in the name. In this case it behaves  like
           an improved copy command.
    
                  rsync somehost.mydomain.com::
    
           this  would  list all the anonymous rsync modules available on the host
           somehost.mydomain.com.  (See the following section for more details.)
    
     
  7. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Can you help me out on the syntax of that a bit?

    I do have rsync, but can't figure out the exact syntax.

    So if I am on the machine that has the bad files:

    rsync -avz goodserverhostname:dev/ badhostname:dev/

    would that be right?
     
  8. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    I believe it would be,

    From your good server:

    # rsync -avz /dev/ badserver:/dev/

    not sure if you need the goodserver but pretty sure you need the / infront of dev
     
  9. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I think i got it:

    From the good server:

    # rsync -avz -e ssh /dev/ root@badserver:/dev/
     
  10. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    yep that should do it
     
  11. Jemshi

    Jemshi Well-Known Member

    Joined:
    Sep 11, 2003
    Messages:
    210
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    rpm --setperms -a or
    rpm --setugids -a

    sets all the files/folders ownership, permission and modes to their default. Now, for your home directory and any other manually installed stuff, you have to do separately.

    Jemshad O K
    Bobcares
     
  12. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    I really don't think you want to rsync /dev from another box.. That might cause you a problem.

    As posted by The man who cares :) is a good idea.

    You could always try to run /dev/MAKEDEV $options (to rebuild /dev)

    # man MAKEDEV (for more info)
     
    #12 DigitalN, Jan 30, 2005
    Last edited: Jan 30, 2005
  13. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    Thanks guys...yea I had already done some of the rsyncs and that did cause some problems....like I overwrote my mysql database file that holds all of the mysql users and passwords....that is another mess I'm having to clean up.

    I found out the only directory I had left that was causing me problems was the actual ./ directory....took me a long time to find that one....

    Thanks again for the help!
     
  14. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I decided to go ahead and run those commands anyways, but I received these errors:

    rpmdb: /var/lib/rpm/Packages: unsupported hash version: 8
    error: cannot open Packages index using db3 - Invalid argument (22)

    ?
     
  15. Finley Ave

    Finley Ave Active Member

    Joined:
    Feb 28, 2004
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    San Ramon, CA
    Can someone tell me why .* caused it to go up to a higher directory? Does that .* signify root directory? If I try ls . I get a listing for current directory, but if I try ls .* I get a listing for root directory.
     
  16. Jemshi

    Jemshi Well-Known Member

    Joined:
    Sep 11, 2003
    Messages:
    210
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    single dot (.) is your current directory and
    double dot (..) is the parent directory

    so giving .* includes .. also. Better method to include all the files and folders (starting with dot too) is

    chmod -R user.group directory

    from its parent directory. And if you want to spare the directory, revert it back with

    chmod olduser.oldgroup directory

    Or, standing inside the directory,

    find . -exec chmod user.grop {} \; will also give the same result

    HTH
     
  17. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    This is actually a common mistake ... I restored a server just at christmas, Christmas day :( for a client that did this

    < EDIT referred back to ticket - this is what happened in my case with one client >
    # ls -la /tmp
    # rm -rf *

    Only he wasn't in /tmp - he was in /
    </ EDIT>
    Believing that it would delete all files in /tmp that were prefixed with .

    You should really use the full system path to files when using wildcard deletes and chmod's, it's good practice.
     
    #17 DigitalN, Jan 30, 2005
    Last edited: Jan 30, 2005
  18. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16
    I don't know if it was the .* by itself. I'm pretty sure it was the -R (recursive) that killed it. Becuase the .* by itself should only change the directory you are currently in. But the recursive does the directory you are in and then goes above it and does all directories above it and so on....
     
  19. dianaward

    dianaward Well-Known Member

    Joined:
    Dec 9, 2002
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Twitter:
    I thought recursive only went down

    directory-wise???
     
  20. noimad1

    noimad1 Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    627
    Likes Received:
    0
    Trophy Points:
    16

    I believe the .* will actually do the . and the .. - so it will do the current directory and parent directory and anything above it.

    Needless to say I have learned my lesson on this one and will be much more careful when it comes to these types of edits....I just got in a hurry and wasn't paying attention.
     
Loading...

Share This Page