LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-18-2011, 05:24 AM   #1
hamd
LQ Newbie
 
Registered: Apr 2011
Posts: 28

Rep: Reputation: 0
I removed everything(rm -R /*)


Hi everyone,
I used windows and I am new in Linux. Un intentionally I executed this command when I was root user on my system:
rm -R /*

I lost eeeeverything, Is there any recovering mode for it?

Thanks
 
Old 05-18-2011, 05:32 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

In short: No. You'll have to restore from backup (I hope you have one), or reinstall your system from scratch. Good luck.

Kind regards,

Eric
 
Old 05-18-2011, 05:34 AM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
It wasn't a very wise thing to do, was it? For that reason when you practise commands try not to be logged in as root. If you don't know what you're doing, you may easily mess up your system (as you've just found out).

As to your question, I don't think there's any way of recovering those files. You might need to reinstall the system.
 
Old 05-18-2011, 07:03 AM   #4
hamd
LQ Newbie
 
Registered: Apr 2011
Posts: 28

Original Poster
Rep: Reputation: 0
I have backup but it is one months ago, However, I was thinking of the structure like windows. Is there any module to do verification before executing this command ?
 
Old 05-18-2011, 07:24 AM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

The first thing you need to realize is that root in a Linux system is 'all powerfull' and there are very few limits to what root can do. There are commands that can be used to 'protect' files and directories from deletion but it would be a lot better to limit working as root to a strict minimum. If you've set up sudo correctly your normal user can perform all necessary tasks to maintain your system and your system itself would be somewhat more protected. Since you're new to Linux you should be able to change the way you do things and adapt to working as a normal user with sudo instead of using root. You could configure aliases for the 'dangerous' commands to always use them in interactive mode, asking for confirmation before actually running the command. Linux is all about how you use it but before jumping in running commands like the one you ran, you should read and practice a lot, for example on virtual machines. It's easy enough to set up, make a snapshot when everything is configured and start practicing. Then if you break something you can revert to the snapshot/backup in an instant and be up and running in a very short time. Also, don't underestimate the importance of a good backup.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-18-2011, 07:38 AM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Hi,

if you have lost important data then have a look at this thread for some recovery options.
If you did not have any important data on the partition then a reinstallation would the far better and faster alternative.

Hope this helps.
 
Old 05-18-2011, 08:07 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by hamd View Post
Is there any module to do verification before executing this command ?
Yes, there is. It is called brain. No offense meant. If you don't know what a command does then don't launch it. Read about it first. You can get information about the commands in the many tutorials out there, or you look at the manpage for the command, in your case the command to look at the manpage would be
Code:
man rm
 
2 members found this post helpful.
Old 05-18-2011, 08:30 AM   #8
hamd
LQ Newbie
 
Registered: Apr 2011
Posts: 28

Original Poster
Rep: Reputation: 0
Smile [Solved]

Thanks you all for your kind advises, I would read brain as well.
 
Old 05-30-2011, 06:29 AM   #9
f10-next
Member
 
Registered: May 2009
Posts: 33
Blog Entries: 1

Rep: Reputation: Disabled
RE: Can you protect yourself?

Yes, you can. I have also similar bad habits of using Bad Engineering Practices (to impose risk to the OS in order to save labor efforts) like you and I also 'have hit the jackpot' in that direction.
However I use $ rm -fR * (to remove the temporary files that are not deleted with the Bleachbit as Administrator).
Nevertheless, you can reduce the risk to the system (even when you do this 'as routine maintenance without paying too much attention') and to avoid whistling the OS by executing $ dir or $ ls command before giving the delete order, to see with the 'peripheral sight' of what you are actually going to delete (and trust me - it is much safer than reading the indication of the directory in the prompt of the terminal).
 
Old 05-31-2011, 01:22 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You could alias rm to rm -i
http://linux.die.net/man/1/rm
Quote:
-i, --interactive
prompt before any removal
iirc, some distros do/did do this, although it may cause issues with scripts etc. For those, you'd either un-alias first, or provide the complete/absolute path to rm.
Ultimately, making this kind of mistake is always possible ... hence backups.
 
Old 05-31-2011, 04:53 AM   #11
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
Quote:
Un intentionally I executed this command when I was root user on my system:
rm -R /*
So what exactly were you trying to do when you "Unintentionately" did this?
This is the first command I was told about when playing with Unix. The one I was told not to use as it blew away the OS. How strange, it's like learning a new language, for some reason you always seem to learn the swear words first. No doubt you managed to recall quite a few when you'd executed the command. Hmmm... "Executed", very apt in this instance.

Play Bonny!
 
Old 06-01-2011, 12:49 AM   #12
f10-next
Member
 
Registered: May 2009
Posts: 33
Blog Entries: 1

Rep: Reputation: Disabled
RE: 'rm -i' does the same thing

No, it is not 'the same'. When you try to execute: $ rm -i * or $ rm -i /*
the system starts complaining 'this is a directory and could not be deleted', 'that is inaccessible and access is denied', etc. and you have to spend half a day answering questions and reading instructions.
Executing: $ rm -fR *
is at least ten times 'cleaner & cooler' ... at the expense of imposing & taking more risk to the system, of course.

Last edited by f10-next; 06-01-2011 at 12:50 AM.
 
Old 06-01-2011, 05:52 AM   #13
bornforlinux
LQ Newbie
 
Registered: May 2011
Posts: 6

Rep: Reputation: Disabled
Always think twice before you executed any dangerous command like rm -rf. Before executing command rm -rf * , check first in which location uou are by pwd command. it will show path in which location you are and always use interactive options like i so it will prompt you before it is executed. And always have a backup and dont use these command in production boxes
 
Old 06-01-2011, 11:43 PM   #14
f10-next
Member
 
Registered: May 2009
Posts: 33
Blog Entries: 1

Rep: Reputation: Disabled
RE: The back-ups

JC, it is not that scary! Sometimes 'to lose' may mean 'to win'.
I personally don't like all these back-ups. The 'Backing-up' is the enemy of creativity and innovation.
I have installed and re-installed Fedora 10 three times and Fedora 11 two times from ground zero (by different reasons), and with every time and in any way the OS gets better & better. The acquired experience and skills in doing so outperform the benefits of the 'lost compilations'. (Of course this should not become a habit.)

I personally am of the opinion that the time lost in making weekly back-ups and restoring the system from back-ups outperforms the efforts of restoring the system when it fails beyond recovery by some random and rare event.

Regards
 
0 members found this post helpful.
Old 06-02-2011, 12:43 AM   #15
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 293Reputation: 293Reputation: 293
Quote:
Originally Posted by hamd View Post
I used windows and I am new in Linux. Un intentionally I executed this command when I was root user on my system:
rm -R /*
Don't sweat it. Sometimes this is the price you pay for an education. I am sure you will be more careful with running commands as root from now on.
Here is a great site for learning basic linux terminal comands: http://linuxcommand.org/learning_the_shell.php
That site is what I learned from when I first started using linux. It covers the basics without being overwhelming for beginners.
If nothing else, at least read: http://linuxcommand.org/lts0050.php#rm especially the part in red!

Last edited by tommcd; 06-02-2011 at 12:44 AM.
 
  


Reply



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
removed vjackcon Linux - Newbie 0 01-28-2011 01:02 AM
Removed accidently removed panel at Suse 11.1? alte_mann SUSE / openSUSE 6 01-29-2009 04:19 AM
Removed URL micheal General 2 11-21-2008 06:58 AM
why was my post removed? chris318 Slackware 3 03-03-2005 12:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:03 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