LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-23-2010, 12:22 PM   #1
Dbronk
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
system files delete by typo, /bin/ gone. How to recover?


Hey guys,

I had some bad luck today when I was trying to fix an account that had trouble with FTP. I decided to remove the user and add him again and reset all configuration. Anyhow, to make things short, I accidently typed rm /* -R -f and without looking hit the enter button, as soon as I realised what I wrote I hit ctrl+c. Too bad the /bin/ folder was gone by this time and standard commands like ls didn't execute anymore.

My question is if there is any way to recover these files by a system repair or something? The server is used to host a heavy loaded site which can't afford any downtime, and silly me didn't make a backup of the whole HDD, just the important folders (not the system files).

Currently I don't have the balls to restart the server as I know this will probably turn into a dissaster. I also don't have straight access to this server since it is located in a datacenter (I can go there if absolutely necessary but I rather don't).

Anyone has some advice? I'd be glad to hear if there's a command to repair/redownload system files!

Kind regards,
Dennis Bronk.

P.S. sorry if the post is a little hard to read, I am dutch.
 
Old 01-23-2010, 12:40 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
What distribution+release? If it has proper and mature package management can you list or verify package contents to see which are affected?
 
Old 01-23-2010, 01:34 PM   #3
Dbronk
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
I am running CentOS 5.

Currently the situation has gotten worse, I was having dinner and when I returned my SSH connection was closed and WinSCP too. I can't connect to any of these anymore, the server just abrupetly closes the connection.

Websites are still up though.

Through some workarounds I can still have limited control over the server. I am running DirectAdmin which enables me to edit files, and I could also execute CGI scripts.

This is bad ...

edit:
I think this requires a reinstall of linux, I am waiting for a few hours until most customers won't order anything and I'll make a backup of MySQL database and the website, put it offline immediatly afterwards and temporarily host it on a Dell Poweredge R200 that I use for testing purposes.

If anyone has some advice though, or knows a solution I'd be glad to hear since I really don't want to go through this kind of trouble. I am probably able to run executables through scripts and have full control over configuration files, so I still have a little control.

Last edited by Dbronk; 01-23-2010 at 01:50 PM.
 
Old 01-23-2010, 01:51 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Usually you would be able to list packages from the RPMDB that have items in /bin, but since 'rpm' resides in /bin as well you would need to copy /var/lib/rpm over to another machine to read it with something like 'rpm -qa --dump|awk '/^\/bin/ {print $1}'|xargs -iX rpm -qf 'X'|sort -u'. The resulting core packages should be a list like "ash bash coreutils cpio dbus ed filesystem (fuse) gawk gettext grep gzip initscripts iputils kbd keyutils mailx mktemp net-tools procps redhat-lsb rpm sed setserial SysVinit tar util-linux vim-minimal". Since /bin/rpm is gone you'll have to curl/wget these packages from the std repo to your staging/rescue Centos machine, unpack each with 'cd /tmp; rpm2cpio "${packagename}" | cpio -idmv', then copy the ./bin parts over to the victim system.
 
Old 01-23-2010, 02:05 PM   #5
Dbronk
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Ok, that doesn't sound like a hard job. Somewhere on the internet I saw an advice on copy'ing /usr/bin to /bin/ as a backup replacement. But I can't imagine those folders are the same ....

I am lucky only my bin got deleted (atleast, that's what I hope, no other folders dissappeared but some files may have been deleted).

Such a small typo, such a great mess it caused heh. I currently don't have a backup linux distro running, but I'll get one up ASAP using dual boot and a spare harddisk I have for my own PC.

Meanwhile I'll get the important files and I'll try to find out if I can write to / using scripts. I think that's going to be a though one too. SFTP is not working anymore, though normal FTP is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete files from user recycle bin 7ser23 Linux - Newbie 4 10-19-2008 10:14 PM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 04:43 PM
does linux have recyle bin like windows to recover lost files fhameed Linux - Newbie 4 07-23-2007 03:26 AM
How to delete installed *.bin files Akwete Linux - General 5 03-09-2007 02:19 AM
Delete repeat files in /usr/bin? rickronn Fedora 3 04-03-2006 12:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration