Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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.
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
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).
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.
Distribution: Cinnamon Mint 17.3 and 18 at present.
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.
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.
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
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.
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!