ShortList is supported by you, our amazing readers. When you click through the links on our site and make a purchase we may earn a commission. Learn more

Man types the wrong piece of code & accidentally deletes entire company

Undo. Undo. UNDO

Man types the wrong piece of code & accidentally deletes entire company
15 April 2016

We've all done it.

Leaned back after finishing a long essay and promptly kicked out the power lead. Gone to hit the save button and accidentally slid across to hit the x button. Clicked 'no' when we meant 'yes'. Now we think of it, we've probably lost half the work we've ever done over the years.

But at least we never did this.

One unlucky programmer has managed to delete his entire hosting company after mistakenly inputting one piece of code.

Hosting provider Marco Marsala went on to a forum for server experts, Server Fault, to request help for his service - and their responses were not pretty reading.

He used the code "rm -rf". The "rm" instructs the computer to remove, the "r" deletes everything in a given directory and "f" instructs the machine to use force - ie. to ignore any warnings that usually come before the computer deletes anything. In a normal situation, this code would just wipe specific parts of a computer, but because of a bug in the code above the line, it simply deleted everything it could find, including Mr Masarla's customers' websites, as well as all of his backups, due to his recovery drives being mounted to the computer.

Whoops.

He explained, “I run a small hosting provider with more or less 1,535 customers and I use Ansible to automate some operations to be run on all servers. Last night I accidentally ran, on all servers, a Bash script with a rm -rf {foo}/{bar} with those variables undefined due to a bug in the code above this line. All servers got deleted and the offsite backups too because the remote storage was mounted just before by the same script (that is a backup maintenance script).”

A forum user named Sven broke the bad news.

“I feel sorry to say that your company is now essentially dead,” he wrote, while another comforted him with the words, "You might have an extremely slim chance to recover from this if you turn off everything right now and hand your disks over to a reputable data recovery company. This will be extremely expensive and still extremely unlikely to really rescue you, and it will take a lot of time."

Just keep hitting 'Undo' and hope for the best. That's our advice.

(Image: Shutterstock)

[via Independent]