Rob's HOWTO

Table of contents

  1. Sound files


  2. CD/DVD burning


  3. Debian packages


  4. System


  5. Encryption


  6. Others


Sound files

Convert MP3 files to WAV files
> mpg321 -w file.wav file.mp3

For batch processing of multiple mp3 files use the mp32wav script.
> mp32wav *.mp3

Or the following command line if files have Unix friendly filenames.
> ls -1 *.mp3 | perl -ne '/(.+)\.mp3/ and system "mpg321 -w $1.wav $_";'
Convert WAV files to MP3 files
> toolame file.wav file.mp3

For batch processing of multiple wav files use the wav2mp3 script.
> wav2mp3 *.wav

Or the following command line if files have Unix friendly filenames.
> ls -1 *.wav | perl -ne '/(.+)\.wav/ and system "toolame $_ $1.mp3";'
Normalize a group of WAV files
> normalize-audio -m *.wav

Use normalize-mp3(1) for MP3 files and normalize-ogg(1) for OGG files.
Rip an Audio CD to MP3 files
Use the mp3c(1) application.

CD/DVD burning

Clone an Audio CD
Read from SCSI device 1,0,0 and then write at speed 32x to same device. Change both settings if required.
  1. > cdda2wav dev=1,0,0 -vall -H -B -x -Owav
  2. > cdrecord dev=1,0,0 driveropts=burnfree speed=16 -v -dao -pad *.wav
Create an Audio CD from MP3s
  1. Convert the MP3s
  2. > cdrecord dev=1,0,0 driveropts=burnfree speed=32 -v -dao -pad *.wav

If files are from different sources (i.e. PtP) then normalize them after point 1.
Create a data CD/DVD
  1. > mkisofs -o image.iso -ldots -R -J -v <target> [<target> ...]
  2. > cdrecord dev=1,0,0 driveropts=burnfree speed=4 -v -dao image.iso

In point 1. if <target> is a directory then mkisofs(8) will create an ISO image containing the content of the directory. To include the full directory path or define a fake one then use the -graft-points option.

  1. > mkisofs -o image.iso -ldots -R -J -v -graft-points <dir1>=<dir2> [<dir1>=<dir2> ...]

Where <dir2> is the real relative/absolute directory path and <dir1> is the directory set in the ISO image. <dir1> can even not exist in the filesystem.

For a DVD replace cdrecord(1) command above by dvdrecord(1). (Works with DVD-RW but only the Plextor accept to mount it. The Thoshiba don't want ...) For a DVD-R maybe better burn using growisofs -Z /dev/dvdr=image.iso
Blank a CD-RW/DVD-RW
For a CD-RW
> cdrecord dev=1,0,0 blank=fast

For a DVD-RW replace cdrecord(1) command above by dvdrecord(1).

Debian packages

Resynchronize the package index files from their sources
# apt-get update
Network install of a package
# apt-get install -uV <package>
Network install of a package in testing
# apt-get install -uV -t testing <package>
List selection states
# dpkg --get-selections
Change selection state
Put nedit(1) package on hold
# echo "nedit hold" | dpkg --set-selections
Make a Debian package from a tarball (with alien(1))
  1. Build the sources

  2. > ./configure --prefix=/mnt/auxdisk/sw/usr/local
    > make
    > make install

  3. Make the .tgz

  4. > cd /mnt/auxdisk/sw
    > tar zcf dvdauthor_0.5.4.tgz usr

  5. Generate the temporary alien directory where futur package will be build from.

  6. # alien -s -k dvdauthor_0.5.4.tgz

  7. Edit files in dvdauthor_0.5.4-1/debian/ if required.

    • Change file changelog to contain:

    • dvdauthor (0.5.4-alien1) experimental; urgency=low

    • Change Description, Source and Package in file control.

    • Source: dvdauthor
      Section: alien
      Priority: extra
      Maintainer: Roberto Romano <rob@forkboy>

      Package: dvdauthor
      Architecture: all
      Depends: ${shlibs:Depends}
      Description: Program to generate a DVD
       dvdauthor is a program that will generate a DVD movie from a valid
       mpeg2 stream that should play when you put it in a DVD player.
       .
       (Converted from a tgz package by alien.)

  8. Run the rules script.

  9. # cd dvdauthor_0.5.4-1
    # debian/rules binary
Make a Debian package from a tarball (with checkinstall(1))
  1. Build the sources

  2. > ./configure
    > make

  3. Build the package

  4. # checkinstall -D

System

Update rc.d links
Setup rc.d links for bootemail script
  1. # update-rc.d -f noticemail remove
  2. # update-rc.d noticemail start 99 S . stop 01 0 6 .
List all listening TCP sockets
> netstat -plant | grep LISTEN
Find disk partition bad blocks
Find bad blocks 32 at a time, of size 4096B, on 3 passes
# badblocks -vs -c 32 -b 4096 -o sda1_badblocks -p 3 /dev/sda1

Find bad blocks 32 at a time, of size 4096B, with non-destructive read-write mode
# badblocks -n -vs -c 32 -b 4096 -o sda1_badblocks /dev/sda1
Create a Linux ReiserFS filesystem
The standard way
# mkreiserfs /dev/sda1

Providing a list of bad blocks)
# mkreiserfs -b 4096 -B sda1_badblocks /dev/sda1
Authorize connection to X server
Give root account permission to open display on localhost.
  1. > xhost +
  2. # xauth generate :0 . trusted timeout 0

Encryption

Generate a new asymmetric key pair for use by gpg(1)
> gpg --gen-key
Asymmetric encryption with gpg(1)
Encrypt <file> into <file.gpg> with the <recipient> public key.
> gpg -o <file.gpg> -er <recipient> <file>

Decrypt an encrypted <file.gpg> into <file>. Will prompt for passphrase.
> gpg -o <file> -d <file.gpg>
Symmetric encryption with gpg(1)
Encrypt <file> into <file.gpg> with a passphrase.
> gpg -o <file.gpg> -c <file>

Decrypt an encrypted <file.gpg> into <file>. Will prompt for passphrase.
> gpg -o <file> -d <file.gpg>
Symmetric encryption with aespipe(1)
Create 65 random encryption keys and encrypt those keys using gpg(1). This only need to be done once.
> head -c 2925 /dev/random | uuencode -m - | head -n 66 | tail -n 65 | gpg -c -a > symkey.gpg

Encrypt <file> into <file.aes> using above generated keys.
Will prompt for passphrase.
> aespipe -e AES256 -K symkey.gpg < <file> > <file.aes>

Decrypt an encrypted <file.aes> into <file>. Will prompt for passphrase.
> aespipe -d -e AES256 -K symkey.gpg < <file.aes> > <file>

Others

Replace a string in multiple files
> find . -type f -exec sed -i 's/string1/string2/g' {} \;
Clone a floppy disk
Dump floppy content to HD and copy it back to another floppy.
  1. > dd if=/dev/fd0 of=diskimage bs=18k
  2. > dd if=diskimage of=/dev/fd0 bs=18k
Build the Linux kernel the Debian way
See this article for the full story.

  1. Create the linux symlink in /usr/src

  2. Configure the kernel

  3. /usr/src/linux # make xconfig

  4. Make the kernel and modules images

  5. Make sure gcc 2.95 will be used for the build (change the symlink in /usr/bin if required)

    /usr/src/linux # make-kpkg clean
    /usr/src/linux # make-kpkg --append-to-version='-01' kernel_image modules_image

    Resulting Debian packages are in /usr/src

  6. Install the kernel and nvidia modules packages

  7. /usr/src # dpkg -i kernel-image-2.6.14-01_10.00.Custom_i386.deb
    /usr/src # dpkg -i nvidia-kernel-2.6.14-02_1.0.7174-3+10.00.Custom_i386.deb

  8. Edit /etc/lilo.conf file and don't forget to run lilo(8)

  9. Make a boot disk of the new kernel

  10. # mkboot /boot/vmlinuz-2.6.14-01

  11. Remove the /usr/src/linux symlink

  12. Reboot

Remarks:
  • NVidia drivers modules are build from /usr/src/modules during the kernel build phase above. Details on installation of the nVidia driver modules could be found here.
  • Set KBUILD_VERBOSE to 1 for a verbose build.
Fetch Debian Sarge DVD images
Use the fetch_sarge_dvds script based on Jigsaw Download.
Convert man pages to text
> man <command> | col -b > <command>.txt
Mount an ISO-9660 file
# mount image.iso -r -t iso9660 -o loop /mnt/tmp