Michael's Domain

The fact that everything looks different doesn't mean that all has changed

Linux

Disk dumps (dd) over the network (netcat)

On the receiving machine (booted from live CD or similarly inactive partition sda):
netcat -l -p 4778 | dd of=/dev/sda

On the sending machine (booted from live CD or similarly inactive partition sdb):
dd if=/dev/sdb | netcat 192.168.0.4 4778

(-l listen; -p port)


Permanent static route in Ubuntu Karmic Koala (9.10)

To add a permanent static route to a system with one NIC, you need to edit the
/etc/network/interfaces file:

The following section needs to be replaced:

# The primary network interface
auto eth0
#iface eth0 inet dhcp

Modify as follows:

# The primary network interface
auto eth0
iface eth0 inet dhcp
up route add -net 10.8.0.0 netmask 255.255.255.0 gw 192.168.0.3
down route del -net 10.8.0.0 netmask 255.255.255.0 gw 192.168.0.3


How to use jhead to add a time stamp to a jpg image

If the jpg image doesn't have exif header you need to create it first:
jhead -mkexif
Then enter the time stamp data:
jhead -ts2009:08:15-10:30:00


How to join PDF files (gs)

There are dozens of methods how to join PDF files. Here is one of them:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=joined.pdf sample1.pdf sample2.pdf


How to determine and convert text file encoding (file, enca, iconv)

To determine the file type of the file "sample.txt" you just type:
file sample.txt
Usually it'll tell you only that it is a text file. To get to know more about the encoding type:
enca -L none sample.text
The -L switch tells the program what language is used in the file. If you don't know, just use none.
To convert the encoding from ISO-8859-1 (latin1) to UTF-8:
iconv --from-code=ISO-8859-1 --to-code=UTF-8 sample_iso8859-1.txt > sample_utf-8.txt


File permissions on html server (recursive chmod) differentiating between files and directories

I recursively screwed up the file permissions in my html servers root directory. To fix it I needed to deploy some "advanced" chmod settings. Obviously I want to treat directories and files differently. I didn't come up with a better solution than the following:

chmod -R u=rw-x,g=rw-x,o=r-wx *
chmod -R a+X *


youtube to iPod

I was trying to extract the audio file from some youtube videos in order to play it back from my iPod shuffle. I tried various methods (including the otherwise quite versatile VLC Player, but finally settled on the following two step procedure:


My rare use of Latex

I sometimes use Latex. I would like to use it more often, but I guess I belong to the Wysiwyg generation. In fact I use it so rarely that I even forget how to compile a document. The following is therefore just a reminder for myself; the filename is doc.tex:

latex doc
bibtex doc
latex doc
latex doc
dvips -Ppdf doc.dvi
tex4ht doc.tex
mk4ht oolatex doc.tex

This creates a PDF file and an OpenOffice file out of the Latex file.


How to erase hard drives (shred, dd)

You could write zeros to the whole hard drive

dd if=/dev/zero of=/dev/hda

or - better - write a few passes of random noise

shred -vfz -n4 /dev/hda


How to access encrypted volumes from live CDs

Once you have decided to encrypt your hard drive, you might find yourself in the situation where you need to pull off data from it when the regular decryption mechanisms you use are not in place. E.g. when the OS is not booting or the drive has some physical problems. In that case you need to boot from a CD/DVD that supports the encryption technology that you used. In my case I need a live Ubuntu CD/DVD, preferably the same version that was used to encrypt the disk! Otherwise there might be incompatibilities:

sudo apt-get install lvm2 cryptsetup
sudo modprobe dm-crypt


© Michael Jeltsch 2006

Powered by Drupal - Design by Artinet