{"id":71,"date":"2009-06-17T18:58:36","date_gmt":"2009-06-17T22:58:36","guid":{"rendered":"http:\/\/bitc.bme.emory.edu\/~lzhou\/blogs\/?p=71"},"modified":"2009-06-17T19:02:04","modified_gmt":"2009-06-17T23:02:04","slug":"linux-oops-i-deleted-an-improtant-file-can-i-undelete","status":"publish","type":"post","link":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/?p=71","title":{"rendered":"linux Oops: I deleted an improtant file, can I undelete?"},"content":{"rendered":"<p>Linux does not offer a file undelete or unerase mechanism, especially in command line.<\/p>\n<p>To undelete a really deleted file, it take guru&#8217;s work like in<\/p>\n<p>http:\/\/www.cyberciti.biz\/tips\/linuxunix-recover-deleted-files.html<\/p>\n<p>This is the last thing one can do.\u00a0 However, if you take a few precautions, you may save yourself easily.<\/p>\n<p>There is a small package named ptrash, which can be found at http:\/\/pjp.dgplug.org\/tools\/, and has been included in plenty of linux repos.<\/p>\n<p>You can just try<\/p>\n<p>yum install ptrash<\/p>\n<p>to see if it is in your repo.\u00a0 If not, go to the website for a tar ball.<\/p>\n<p>When installed, you may still forget using the nice new command\u00a0 &#8220;ptrash&#8221; for delete.\u00a0 To avoid this, you need to add a line in your ~\/.bashrc as<\/p>\n<p>alias rm=&#8221;echo file will be sent to \\.trash\\, use ptrash -d to purge.; ptrash -iv&#8221;<\/p>\n<p>This will first remind you that your file will be moved to<\/p>\n<p>~\/.trash<\/p>\n<p>folder, instead of being silently deleted.<\/p>\n<p>In case you did it wrong, you can either move them back or use ptrash&#8217;s undelete option.\u00a0 The echo remind you that ptrash is the magic key.<\/p>\n<p>Then log off and log in again to have a try.\u00a0 It also work on folders and wildcards.<\/p>\n<p>For purging the ~\/.trash folder, you can either setting up a cron job or leave it to yourself.<\/p>\n<p>Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux does not offer a file undelete or unerase mechanism, especially in command line. To undelete a really deleted file, it take guru&#8217;s work like in http:\/\/www.cyberciti.biz\/tips\/linuxunix-recover-deleted-files.html This is the last thing one can do.\u00a0 However, if you take a few precautions, you may save yourself easily. There is a small package named ptrash, which [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,3],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-computer-tips","category-mri-technical-support","post-blog"],"_links":{"self":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csic.som.emory.edu\/~lzhou\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}