Solved

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

Posted on 2014-11-23
8
429 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 12

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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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
 
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 62

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 62

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

695 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