LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Dumb ass newbie mistake...help! (https://www.linuxquestions.org/questions/linux-newbie-8/dumb-ass-newbie-mistake-help-254649/)

craigb 11-14-2004 07:16 AM

Dumb ass newbie mistake...help!
 
Ok, so I guess you've heard of a few stupid things in your time...

I've kinda messed up my system a little and I need some advice on how to get it back. To cut a long story short I accidentally ran

Code:

chmod -R 777 /
while logged in as root.

Needless to say, things started going wrong almost immediately, e.g. sshd won't even start if the files holding the public keys are world readable.

So what's the best way to undo this mess? I am thinking at the moment the best way to avoid future problems is to just reinstall from scratch.

Thanks, and I know I'm stupid.
Craig

OS: Fedora Core 3

SteveK1979 11-14-2004 07:56 AM

Hi craigh,

Well, I guess you learnt the hard way that you've got to be careful what you're doing when you're root, and think before you type!

Anyway, if I didn't have anything special set up that I needed to save, I think I would do a fresh install too. Just to be sure. But if there is stuff that needs to be saved, then you could start by issuing

Code:

chmod -R 755 /
which would make everything readable, writable and executable by root, and readable and executable by everything else.

Then from there move onto specific folders, such as /etc in which pretty much every file has permissions of rw by root, and readable by everyone else

Code:

cd /etc
ls -l | grep -v ^d | cat > files.txt

would give you a list of all the actual files, and not the directories as these need to have different permissions. You could then at least use this file as a reference to know what files you need to change the permissions on, and if you reissue the command every so often, you'll be able to see how far you've got. You should also be able to see the files that should have different permissions, such as shadow and passwd, which should have permissions of 600 (rw by root, nothing for anybody else).

I'm sure there's probably a better way of doing this, but I don't know what it is.

Cheers,

Steve

craigb 11-14-2004 08:12 AM

thanks SteveK1979,

i think you've pretty much confirmed what i was dreading...that there is no easy way out.

ironically, i executed that command from a python script i was writing to perform automatic backup of the system. i guess i now have the golden oppurtunity to test how good my backups are :)

SteveK1979 11-14-2004 08:28 AM

At least you have backups! :cool:

But you're right, reinstalling is going to be the way to go.

J.W. 11-14-2004 12:07 PM

At the risk of repeating what has already been said, your only option is a full reinstallation. The problem with recursive chmod commands is that they will universally reset the permissions to what you currently specify, which in no way necessarily corresponds to what they once might have been. To illustrate, if file "A" originally had permissions 644 and file "B" was 755, the initial "chmod 777" would change both A and B to 777 (obviously) at which point it would then become impossible to recover or even determine what their previous permissions had been.

I congratulate you on running regular backups, however, to be honest the only safe thing to do would be reinstall. I'll also echo SteveK1979's excellent advice about running as root - don't make this a habit. Root should only be used sparingly, and only in limited, specific situations (such as installing new packages, recompiling the kernel, etc). For day to day use, just use a regular user account -- J.W.


All times are GMT -5. The time now is 07:54 AM.