• About

Bespoke Blog

~ Science! Culture! Computational Engines!

Bespoke Blog

Tag Archives: bash

Data Recovery For The Very Lazy

16 Saturday Jul 2011

Posted by bwkeller in computer science, howto

≈ 2 Comments

Tags

bash, sleuthkit, UNIX

After my friend rm’d a bunch of code yesterday, I offered to help.  I first made a copy of her disk using dd, copying it off of her machine and using ssh to take it to another:


sudo dd if=/dev/sda1 | ssh USER@HOST "dd of=/home/USER/backup.img"

I then grabbed a copy of sleuthkit, and used the fls tool to find the inodes pointing at her old files, and icat to restore them.  I new the files were php code, stored in /var/www so I used grep to select those results from all the files listed by fls.  Using grep, I selected the inode numbers from the output, and piped the results to icat.


for i in `fls -r -d backup.img | grep var/www | grep \.php | grep -o [0-9][0-9]*`

do

icat $i > $i

done

Voila, I had a bunch of files, 6 of which were the missing PHP files!  Super easy, and thank goodness the filesystem was ext2, as ext3 is much harder to recover data from.

rm Is Not Your Friend

16 Saturday Jul 2011

Posted by bwkeller in computer science, howto, research

≈ 4 Comments

Tags

bash, UNIX

This afternoon, about 10 minutes before the end of the day, one of the undergrads working in my lab turned to me and asked what the command to undo an rm command was.  I blinked at her, and told her there was none.  I’m now trying to sift through a disk image dumped from the machine she worked on after typing rm -r * in the wrong terminal.  Now, backups, backups, etc. I know.  But even with regular backups, an rm -r * in your home directory is never fun.  If you want to not experience the joys of watching your files turn to dust, add this to your .bashrc:


alias rm="rm -i"

This won’t save you every time, but it will at least prompt you before you blow away 3 weeks of work.  So don’t ignore the prompt. Please?

May 2022
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Mar    

Ben’s Tweets

  • RT @Alex_T_Young: Fetterman will be such an asset as we transition into the “brawling on the senate floor” phase of democratic decline 1 day ago
  • RT @narsi1ion: TES 6 Vaermina quest leaked theguardian.com/world/2022/may… 2 days ago
  • RT @jerseyphysicist: yeah s*x is cool but have you ever had a long ass expression and every other term cancels except one 3 days ago
  • RT @girlandkat: No rest for construction workers in Yokohama today 🐶 ⛑! https://t.co/fucmj7UiI1 5 days ago
  • @frogs4girls MUDA MUDA MUDA 5 days ago

Nicholas’ Tweet’s

  • RT @michielsdj: Now accepted to @iclr_conf! 🎆 3 months ago
  • @mjskay Yeah, I feel a major point people were missing is that an endless spiral into the drain is actually the perfect visual metaphor. 4 months ago
  • RT @_theopompus: A project I'm extremely excited about! An alternative way to incorporate information from the entire Wikipedia (or any oth… 7 months ago
  • RT @MsdJ29: Happy to share a project I've been working on for a while now (with @_theopompus @nfitz @feishaAI @professorwcohen, at Google R… 7 months ago
  • New paper with @MsdJ29 @_theopompus @feishaAI @professorwcohen at Google Research: Mention Memory… twitter.com/i/web/status/1… 7 months ago

Top Posts

  • Basic Data Plotting with Matplotlib Part 3: Histograms
  • Sunset Time Series
  • Filesystem Organization for Physicists Part 1: The Problem
  • Pedal-Powered Lightshow
  • Science is Aesceticism
  • Accidental Pilish: Unintentionally Constrained Writing in English Literature
  • 400 Word Essay 1: Public Libraries in the Digital Age
  • Proceedings of the Association of Pilish-English Research (PAPER)

Tags

100daychallenge advertising astronomy bash biology blogs BMC books browsers Bulshytt calligraphy canada coding cognitive computers computer science css EEE elvish ereaders ethics evolution experiments facebook google government html humor humour ICP I hate this class iliad internet explorer irex java javascript lego letter libraries marketing materialism matplotlib maze mindstorms mods morality mysql networking neuroscience pens philosophy philsophy php Pilish prime minister programming psychology reading review robots science SENG servers sociology steampunk stupid technology time ubc UNIX url vim web web design writing

Blogs We Read

  • Bad Astronomy
  • Boing Boing
  • Rationally Speaking
  • Terry Project (UBC)

RSS Nicholas’ Terry Posts

  • An error has occurred; the feed is probably down. Try again later.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 163 other followers

Blog at WordPress.com.

  • Follow Following
    • Bespoke Blog
    • Join 163 other followers
    • Already have a WordPress.com account? Log in now.
    • Bespoke Blog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar