Some commands are specific to Debian/Ubuntu distributions.

Copy the contents of a directory

Also copies hidden files.

$ tar cf - -C $source_dir . | tar xpvf - -C $dest_dir

Read a file in bash

exec 3<$file
while read -u 3; do
  ...
done
exec 3<&-

Set the core affinity of a process

$ taskset -c 0 $command

Restore grub

This example asssumes that the /boot directory is located on the third partition of the first hard disk.

Boot a Linux live system and open the shell.

$ grub
root (hd0,2)
setup (hd0)
quit

Then reboot the PC.

Create an audio or mixed mode CD image

$ cdrdao read-cd --datafile image.bin --driver generic-mmc:0x20000\
    --device /dev/cdrom --read-raw image.toc
$ toc2cue image.toc image.cue

Set the default sound card

Show the list of loaded sound card modules:

cat /proc/asound/modules

Add the following lines to /etc/modprobe.d/alsa-base:

options $default-module index=0
options $other-module index=1
...

Manipulate Exif metadata

Set date and time:

exiftool -alldates="2007:08:09 12:34:56" -overwrite_original image.jpg

Set comment:

$ exiv2 -M"set Exif.Photo.UserComment $comment" image.jpg

Show values:

$ exiv2 image.jpg
$ exiv2 -pt image.jpg

Troubleshoot SDL applications (e.g. DOSBox, ScummVM)

Fix missing mouse pointer:

$ export SDL_VIDEO_X11_DGAMOUSE=0

Fix audio issues:

$ export SDL_AUDIODRIVER=alsa

Remove Pulseaudio (outdated)

$ sudo apt-get purge pulseaudio
$ sudo apt-get install esound
$ gnome-sound-properties

Set everything to detect automatically or the Alsa driver of the sound card.

$ gnome-session-properties

Disable the Pulseaudio session manager here. Finally, delete or rename the .asoundrcfile in the home directory and reboot.

Install libdvdcss2 (outdated)

sudo /usr/share/doc/libdvdread3/install-css.sh

CPU frequency control (outdated)

Identify the current CPU frequency governor:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
ondemand

Get a list of all available governors:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors 
powersave userspace ondemand conservative performance

Set a new governor:

$ sudo cpufreq-selector -g performance