Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have typed a recursive chmod o-rwx command from root in a linux via ssh. After that I can not login as root anymore. It is a huge problem now. Can I do anything to do to resolve this? I can only work via ssh, not locally.

share|improve this question
Can you log in as a normal user even? Do you have sudo installed? – thinice Mar 9 '12 at 6:56
I tried with normal user too. It was not successful. Sudo is okay, before the accident I used to loginned as root. – ald mike Mar 9 '12 at 7:29

This isn't the answer you want to hear, but I'm afraid you've hosed that box. If you can't ssh in now then you will need local hands-and-eyes to try to get some kind of access, and that will probably just be to save what data you can before you reinstall and restore the box from backups.

You do have backups, don't you?

Repermissioning an entire operating system without excellent backups isn't a trivial option even for experts, and doing it remotely is something I'd seriously quake at, even with 20+ years sysadminning under my belt.

I think you have no real choice but to own up to whoever that you've hosed the box, and either get on a plane and go visit it for an extended period of nursing it back to life, or just count it lost and move on; probably whichever is cheapest.

What you can do is learn from this:

  1. If your server matters to you, you need backups. Preferably of the whole machine, but at least enough to restore the important bits. Whatever your backup strategy, it needs to be tested, regularly, or it's not-fit-for-purpose; and by tested I mean "we performed a complete restore as if we'd lost the original box, and all the business systems on this pre-agreed list worked OK".
  2. Don't log in remotely as root. It's insecure at the best of times, and encourages you to do everything as root whether root access is needed or not. SSH in as yourself and use sudo appropriately.
  3. Think really hard before pressing <CR> on every command that's done with privilege. As a sysadmin friend said many years back when his slow typing speed was criticised in his yearly appraisal, "I'm not paid to type fast, I'm paid to hit <ENTER> slowly and thoughtfully".

It seems like the end of the world right now, but most of us have done something boneheaded like this at one point or another. It's a test of character: if you can be honest with everyone else now, and honest with yourself going forwards so you learn from it, then it's not quite as bad a disaster as it seems to be today.

share|improve this answer
Fortunatly a web service is runnable even, there I could download the configurations. However I hope I don't need these, I try to resolve this problem by Live Linux, locally. I will do this or anybody. Thank You! – ald mike Mar 9 '12 at 10:05

Is there anything still running on the box, such as a web service or email service? nmap -A -p- <ip address> can find these for you.

Some services may have the ability to change ownerships for you. cPanel or webmin may still work if you have them installed. I'm not sure how these would be affected by your recursive chmod but it's worth looking.

If you have services running that do not have this functionality, you may still be able to force them into it. This option is not for the faint of heart. I'm talking about hacking your own box here. Find an exploit from somewhere like Exploit DB and use it to gain a shell and fix the necessary permissions. This may not be possible for a bunch of different classes of reasons and it has the potential to make the situation worse.

My vote would still be to get your hosting provider to do it for you with a LiveCD.

share|improve this answer

Ask support to recover setuid bit on /bin/login, /bin/su, sudo That will let you login as root. Local support can boot the server into single-user mode without root password. They have to know boot loader password, if there's one.

When you're logged back, run rpm -Va to check what files where affected and reinstall these packages. That will automatically fix permissions.

share|improve this answer
Good plan, but the OP doesn't say whether he's on an RPM- or APT-based system. – MadHatter Mar 9 '12 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.