CentOS permission system restoration method

Source: Internet
Author: User
Sometimes the handcuffs accidentally to the chmod-R777/, this system is paralyzed ~ What should we do ?? First, you must prepare the same system as the faulty machine. for example, you can install a linux of the same version in the virtual machine to create a waynerQiu in the new system. c program, the content is as follows # include & lt; sy

Sometimes the chmod-R is 777/, and the system is paralyzed ~ What should we do ?? Let's take a look.

First, you must prepare the same system as the faulty machine. for example, you can install a linux

Create a waynerQiu. c program in the new system. the content is as follows:

  # Include # Include Int list (const char * name, const struct stat * status, int type) {if (type = FTW_NS) return 0; printf ("% s 0% 3o \ n ", name, status-> st_mode & 07777); return 0;} int main (int argc, char * argv []) {if (argc = 1) ftw (". ", list, 1); elseftw (argv [1], list, 2); exit (0 );}

 

Compile the file and export the permission information.

  # Compile gcc waynerQiu. c-o waynerQiu.com # run and export the relevant directory permission./waynerQiu.com/> waynerQiu.txt

 

Copy the exported file to the faulty machine and execute the following script.

  #! /Bin/shif [$ #! = 1] thenecho Usage: $0 \ ExitfiPERMFILE = $ 1cat $ PERMFILE | while read LINEdoFILE = 'echo $ LINE | awk' {print $1} ''PERM = 'echo $ LINE | awk' {print $2 }' 'chmod $ PERM $ FILE # echo "chmod $ PERM $ FILE" doneecho "change perm finished! "

 

You can save the script as a shell file, such as mygod. sh.

Then execute

  Mygod. sh waynerQiu.txt

 

After the program runs, restart the system to see if it has been restored?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.