Linux recycle bin [rewrite RM to prevent files from being recovered by mistake]-wklken notes-blog channel-csdn. net

Source: Internet
Author: User

Linux recycle bin [rewrite RM to prevent files from being recovered by mistake]-wklken notes-blog channel-csdn. net

 
Linux recycle bin [rewrite RM to prevent files from being recovered by mistake] Category: 04-linux Read by 2275 Comment (1) Favorites Report Linux script Google Baidu

 

Rm-RF use with caution

The command has been knocked a lot. It often goes by the river, and it is inevitable that the shoes will be wet.

Yesterday, by mistake, I typed the wrong command and gave the folder to RM-RF.

A few days of hard work, relying on, the heart of death

 

Baidu, Google, and fail to get it back.

 

Lessons:

1. Be careful before RM, especially Rm-RF, or simply rewrite the command.

2. Make backup and have convenient backup scripts

3. Make a regular backup. One of our predecessors has a regular script and runs it on a regular basis every day. Even if a mistake is deleted, it will not be so miserable.

 

First, create a recycle bin.

In ~ Add. bashrc or. bash_profile

 

[Python] View plaincopyprint?
    1. mkdir-P ~ /. Trash
    2. alias Rm = trash
    3. alias r = trash
    4. alias RL = 'ls ~ /. Trash '
    5. alias ur = undelfile
    6. undelfile ()
    7. {
    8. MV-I ~ /. Trash/$ @./
    9. }
    10. trash ()
    11. {
    12. MV $ @~ /. Trash/
    13. }
Mkdir-P ~ /. Trashalias Rm = trash alias r = trash alias RL = 'ls ~ /. Trash 'Alias ur = undelfileundelfile () {MV-I ~ /. Trash/$ @./} trash () {MV $ @~ /. Trash /}

This is the execution

 

Rm is equivalent to executing mV.

Note: Rm-RF is already available.

The deleted file will appear in. Trash.

Can be recovered

 

Ur filename

 

This poses a problem. How to delete the items in the recycle bin? This is a useful post-RM here.

 

 

Add a function under. bashrc just now.

 

[Python] View plaincopyprint?
    1. Cleartrash ()
    2. {
    3. Read-P"Clear sure? [N]"Confirm
    4. [$ Confirm ='Y'] | [$ Confirm ='Y'] &/Usr/bin/Rm-RF ~ /. Trash /*
    5. }
 
Cleartrash () {read-P "Clear sure? [N] "Confirm [$ confirm = 'y'] | [$ confirm = 'y'] & amp;/usr/bin/Rm-RF ~ /. Trash /*}

$ .. Bashrc

 

Then, if you want to clear the recycle bin

$ Cleartrash.

 

Backup script in process

Including compress, fast backup, and midnight scheduled backup.

Delete files in Linux and fix them. Currently, I have learned how to delete files.

 

Lessons learned from blood and Prevention

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.