Linux避免用rm誤刪檔案 – 遺失的記憶 – 部落格大巴

來源:互聯網
上載者:User

Linux避免用rm誤刪檔案 - 遺失的記憶 - 部落格大巴

Linux避免用rm誤刪檔案日期:2010-12-11 | 分類:Linux使用

著作權聲明:轉載時請以超連結形式標明文章原始出處和作者資訊及本聲明
http://freakrobot.blogbus.com/logs/88281920.html

因為大部分的的linux髮型套件已經採用了ext3/4檔案系統,又因為rm命令刪除的檔案是不進垃圾箱的,所以用rm誤刪的檔案一般是不能恢複的。

Q: How can I recover (undelete) deleted files from my ext3 partition?

Actually, you can't! This is what one of the developers, Andreas Dilger, said about it:

In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as "deleted" and leaves the block pointers alone.

因此我們要盡量避免檔案被誤刪,我們建立一個新的命令del指令碼來刪除檔案,將下面指令碼儲存在/usr/bin下,以後都用它來刪除檔案:

#!/bin/bashmkdir~/.Trash &> /dev/nullwhile [ ! -z "$1" ]; do    mv "$1" ~/.Trash/    shiftdone

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.