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.

İn my desktop, i have a dir. called exam, and i wanted to remove it from the console and wrote rm * /exam, and apparently it removed some other files from my desktop. Please tell me that there is a way for a recovery.

Edit: i am not even sure which files are removed, so i dont know their file names.

share|improve this question
add comment

3 Answers

Depending on which directory you were in when you ran that command you most likely deleted the files that were there as well. There are a couple of tools that I've used in the past but I think you might be out of luck.

Depending on the types of data one of 2 programs may help.

But installing them could likely overwrite the data you're trying to recover!

If I were you, I'd download SystemRescueCd burn it to a CD or USB thumb drive and boot the system with the files using it. SystemRescueCd includes tools for undeleting files. I'd give that a try.

References

share|improve this answer
    
i ran it on the desktop directory, there are like 6-7 files missing which i can tell from the appearance of my desktop. –  hackio May 6 '13 at 11:50
add comment

Most command line commands take a space separated list of files or folders as input. * means everything, so running rm * /exam means delete everything in the current folder and then delete /exam. In other words, you have deleted all files (not folders) from your Desktop. The only thing you can do is to try recover them using such tools as suggested by @slm.

You should also be aware that even if you had run the command you wanted to run, rm /exam, it would not have worked. By default, rm does not delete directories, only files. In order to use it to delete a directory, it needs the recursive (-r) flag. So, to delete the directory /exam, you would need to run rm -r /exam.

One way of protecting yourself from this sort if error in the future is to make rm an alias to rm -i or rm -I, so you will be asked to confirm file deletions. From the rm man page:

   -i     prompt before every removal

   -I     prompt  once  before removing more than three files, or
          when removing recursively.   Less  intrusive  than  -i,
          while still giving protection against most mistakes

To make rm an alias to rm -i, add this line tou your ~/.bashrc file:

alias rm='rm -i'
share|improve this answer
add comment

Some setups stash deleted files away, check if that is your case (I doubt it). Otherwise, write it up to learning that Unix does exactly as told, it doesn't try to second guess you. Ever.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.