TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Restoring accidentally deleted files on Linux

77 pointsby potus_kushnerabout 6 years ago

6 comments

rnhmjojabout 6 years ago
If you are using ext4 there is extundelete that simplifies the process, it requires to remount the filesystem read-only, though.<p><pre><code> mount -o remount,ro &#x2F;dev&#x2F;sda1 extundelete --restore-all --after $(date -d &quot;-1 hours&quot; +%s) &#x2F;dev&#x2F;sda1 find &#x2F;RECOVERED_FILES -name accidentally_deleted_file mount -o remount,rw &#x2F;dev&#x2F;sda1</code></pre>
theamkabout 6 years ago
Another fast way to search for text in binary files is to use &quot;grep -abo&quot; (treat all files as text &#x2F; print matches only &#x2F; print file offsets).
dustedabout 6 years ago
Anyone checked if that is actually faster than just using grep on the blockdevice? I&#x27;ve used grep the few times I&#x27;ve had a need for it, and just copied the source off the terminal when its found something. (Tell grep to give you some lines before and after a match, and tell it to treat the blockdevice as plain-text).. You usually get some trash before&#x2F;after the matches, those could be terminal control characers, but a those can be trimmed with, drumroll: tr.
评论 #19817880 未加载
rrauenzaabout 6 years ago
Last time I had this happen (thankfully a long time ago) I just used Perl against the block device and used a regex.<p>Forensic tools also work well for this.
auroxabout 6 years ago
Thanks, this will come in handy. Needed it a bunch in the past.
jvanderbotabout 6 years ago
shouldn&#x27;t that be (addr1-addr2+1)? Or does dd copy the first byte <i>plus</i> the count?