3

Accidentally did :

chmod -R 777 /

Now, RHEL 6 is not booting up.

What do I do?
I have a DVD and can go into rescue mode.

Can someone explain how do I reset all the permissions ?

Update Actually it boots, and then reaches to a screen where it displays Redhat logo along with some text localhostXXX. But after that nothing happens. It is not going to the login screen.

user2799508
  • 1,712

2 Answers2

3

You can use the following script:

#!/bin/sh

GDZIE=$PWD

for dir in /bin /sbin /lib /usr /etc /opt /var; do
    echo '#!/bin/sh'>"${GDZIE}${dir}.sh"
    find "$dir" -printf "chown %u:%g %p && chmod  %m %p\n" >>"${GDZIE}${dir}.sh"
done

chmod +x "$GDZIE"/*.sh

Run it on a healthy system first. It will produce some scripts with all the files that exists on that system and also save their permissions. Then you just have to run the scripts on the damaged system.

I'm not sure what's better -- a full reinstall of that system or this solution. But if you want to avoid this kind of situation, save the script and when you're done with a fresh installation of a new system, just do the backup, just in case. :)

Hauke Laging
  • 90,279
2

Someone with a similar system could create a list of the permissions for you. I suggest to do that for each directory separately:

#! /bin/bash
# as root
cd /
shopt -s extglob
for dir in /!(home|proc|sys|lost+found|cgroup); do
    test -d "$dir" || continue
    time getfacl --recursive "$dir" >"$dir.acl"
done

On your system you apply the data with: setfacl --restore=file

Maybe this information can be extracted from the package management, too. I have to think about that first, though.

You need not use ACL for this to work. But the ACL tools must be installed, of course. But I guess they are by default.

Hauke Laging
  • 90,279