Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose if I delete any file using the command prompt (I'm talking about Linux), that file is gone, I can't get back that file.

If I by mistake delete any important file, then that would be a big problem for me.

So I want to create one backup folder. If I delete something it should go to that folder first. From the original location it should be deleted, but that file should moved to backup folder.

I am using CentOS 6.2.

share|improve this question
3  
This is just not "the way". Windows doesn't do this either. If you remove a file from the command line, it will not go into any recycle bin. A recycle bin is a user interface thing, not a system thing. If you want to put things in a recycle bin, then issue a command to put them there. –  David Schwartz Jun 20 '12 at 11:31

3 Answers 3

up vote 2 down vote accepted

Have you tried trash-put from trash-cli package? It sends your files to trash instead of delete them.

share|improve this answer
    
@Devator Aliasing rm is a terribly bad idea. You'll get used to trashing files with it and once you're on another system, where rm works like expected, you suddenly find yourself permanently removing files and not trashing them. –  slhck Jun 20 '12 at 11:55
    
@slhck Fair enough, the comment has been removed. –  Devator Jun 20 '12 at 11:56
    
@criziot thanx man your tip is working fine. thanks a lot... –  max Jun 20 '12 at 12:18

Deleted files are not really gone. Tools like ext3grep can usually bring your data back, if you act immediately and know what you're doing.

Generally speaking, though, command line is the user interface for the people who know what they're doing. (Like C/C++ for programming languages.) Any workarounds you might come up with will be fragile. What if you realize your mistake the second you told the system to empty the trash? Will you install a second trashcan so when you empty the first one everything gets send to the second trashcan?

The "way to go" is to not use rm carelessly. The moment you type rm, cut your typing speed in half and think before you hit that "enter" key.

share|improve this answer
    
You're right but my experience tells me that, at least for me, don't matter how hard I try, I will make a mistake and delete important files. So why is it bad send files to trash instead of delete them? –  criziot Jun 20 '12 at 12:15
1  
@criziot: The trashcan is an illusion. Files in there are not deleted; they still take up space, and show up in backups. The moment you do delete them (empty the trash), they are gone just as if you'd deleted them with rm. If you want to move files into a trashcan, use mv <file> ~/.trash or somesuch, but don't redefine "delete" to mean something different, because sooner or later, that very redefinition will come back to bite you, either because it's there when you really want to delete something, or because it isn't when you came to rely on it. Say what you mean, mean what you say. –  DevSolar Jun 20 '12 at 12:48

This article has all the information you want.

share|improve this answer

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.