Solved

linux : how to configure recycle bin feature when I run shell command - $ rm -rf

Posted on 2014-11-23
8
391 Views
Last Modified: 2015-02-21
we would like to configure our Linux servers in such that, if we accidentally  delete any files, those files  automatically move to some preconfigured directory.

example :  $ rm -rf file.txt

$ls -ltr   /recyclebin
output : file.txt

--
please advice the steps to customize the rm -rf command
0
Comment
Question by:mac_g
8 Comments
 
LVL 11

Assisted Solution

by:andreas
andreas earned 84 total points
ID: 40461515
There is no "built in" way of rm to achive this. you might use some shell scripts or software that does this.

You might look into this.

http://www.webupd8.org/2010/02/make-rm-move-files-to-trash-instead-of.html
0
 

Author Comment

by:mac_g
ID: 40461545
any more inputs ?
please
0
 
LVL 19

Accepted Solution

by:
jools earned 84 total points
ID: 40461795
I wouldnt modify the rm command or create an alias for it at all, it will lead to bad habits, if you rely on a recyclebin for the rm command and you go to a different server with it not set up you might have problems.

I was going to suggest creating a recycle command but andreas found a link to something suitable in his post above.
0
 
LVL 4

Assisted Solution

by:popesy
popesy earned 83 total points
ID: 40461802
Hi

Yes, for me too I have not seen a recycle bin implemented in a Unix system, rather a daily backup solution could possibly be an easier option...it works for us; but of course you may have a slightly different need.

The 'rm' command could be aliased to move ('mv/mvdir') files to the /recyclebin file system and (as andreas alludes to) one could use a shell script to achieve this.

Cheers, JP.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 25

Assisted Solution

by:madunix
madunix earned 83 total points
ID: 40462939
Unfortunately,It is not possible to configure recycle bin in Linux/Unix. As said above there is no reliable way to recover a deleted files in Linux/Unix . All the methods are just best effort. The best suggestion is to do regular BACKUP on the important files before it is deleted.
http://www.experts-exchange.com/OS/Unix/Q_27314229.html
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 166 total points
ID: 40468832
alias rm="echo"
0
 

Author Comment

by:mac_g
ID: 40469045
i did not get u
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 166 total points
ID: 40469533
You cannot intercept system calls, but you can replace rm command with mv -d ~/Recycle
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now