Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I installed a new debian 6 system a few days ago - today I wanted to create a CSR request for a SSL certificate and wanted to delete the CSR file afterwards.

In the root of my server I was typing

rm * /etc/apache2/sslstuff

then I noticed that I cannot use ls or top anymore, did I delete everything?

I thought I needed to do rm -R to delete folders as well.

Now I can't even login using SSL because putty will always close after I type in the password of my login user.

What can I do here? Do I have to re-install the system or is there a more time-saving way? (root login is not allowed, I login with a different user and then use su)


Okay, I used another user to login because I set permitrootlogin to NO for security reasons. When I open Putty to login via SSH then I put in the user name and after I enter the PW putty will close.. So what can I do to at least connect to that server?

FTP still works, website is still up and running, so I guess I only deleted some symbolic links and stuff. What to do now?

share|improve this question

migrated from stackoverflow.com Jul 22 '11 at 12:55

This question came from our site for professional and enthusiast programmers.

    
If you aren't root then you shouldn't have been able to delete from /etc, I'd telephone whoever is root. –  spraff Jul 22 '11 at 12:39
    
ls and top don't live under /etc/apache2/sslstuff –  marto Jul 22 '11 at 12:39
    
I WAS root. I login using a different username because Root login is not allowed due to security reasons. –  Dominik Jul 22 '11 at 12:41
    
I was in the root of the server, where all the folders are like /etc /init.d /dev and all the stuff. I misstyped but I thought FOLDERS can only be deleted when type rm -R –  Dominik Jul 22 '11 at 12:45
1  
Perhaps rm is aliased to rm -r on his system. Stupid default, I know, but some people actually use it. –  Shadur Jul 22 '11 at 15:07

3 Answers 3

The only actual files that your command would have wiped out would be symbolic links to the current kernel, initrd and cdrom device. Again, those are just symbolic links and would not have caused the issue that you describe.

The rm command will not recurse (-r means recursive) unless it is explicitly told to do so, or unless an alias for rm was created in root's .bashrc file stating that 'rm' should be treated as 'rm -r', or 'rm -rf'.

I strongly suspect that you weren't in the directory that you thought you were.

share|improve this answer

If it's possible to boot a rescue kernel image or a livecd-like environment, do that and mount your root fs there. You're right that you'd need to do an rm -r (lowercase 'r' !) to delete directories, I also can't tell why that didn't behave as normal in your case. Probably your hosing provider (is you speak about a "root server") offers a way to do a recovery via SOL (Serial over LAN) over SSH or KVM. If the server stores valuable data, you should consider contacting your hoster.

share|improve this answer
    
GNU rm will accept either the uppercase or lowercase r to recurse. –  Reid Jul 22 '11 at 23:22

rm would only delete files and not directories, yes, so this is a bit puzzling.

If you are still logged in, see if rm was perhaps an alias for something else (alias | grep rm), which might explain this behaviour.

If the files are really gone, you'd have to re-install (or restore a backup if you have one).

Good luck!

Edit:

Regarding your update: are you still logged in with another terminal? In that case, inspect /var/log and see if you can diagnose the problem from there. If you are not logged in anymore it will be hard to fix the system remotely as you probably need to be root...

share|improve this answer
    
Off-topic, but here's a (similar) story about system recovery after accidentally deleting most of the system. –  Tim Jul 22 '11 at 15:38

Your Answer

 
discard

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