Debian package manager: apt-get / dpkg / aptitude

Show if a package "xbmc" is installed:
andre@nairobi ~ % dpkg -s xbmc | grep -i version
Version: 2:11.0~git20120510.82388d5-1

andre@nairobi ~ % aptitude search xbmc -F "%c %p %d %V" | grep -E "^i"
i xbmc                       XBMC Media Center (arch-independent  2:11.0~git2012
i xbmc-bin                   XBMC Media Center (binary data packa 2:11.0~git2012

andre@nairobi ~ % aptitude versions xbmc | grep -EB1 "^i"
Package xbmc:
i   2:11.0~git20120510.82388d5-1                  stable                    500
--
Package xbmc-bin:
i A 2:11.0~git20120510.82388d5-1+b1               stable                    500

Run a filesystem check manually

Check the partition sda1:
root@sysresccd / % fsck -c -v -f -p /dev/sda1

Read a damaged DVD to image file:

See also ddrescue manual

Using a logfile is important, you may continue the process and even read a broken dvd with multiple drives.
root@nairobi /tmp/ # ddrescue /dev/sr0 image.iso
    ddrescue.log

Mount a cd/dvd iso image on filesystem

root@nairobi /home/andre # mount -o loop -t iso9660 /path/to/dvd.iso /path/to/mountpoint

Merge multiple .VOB files to a single video file:

Without compression or encoding, just concatenate:
andre@nairobi /tmp/video-dvd % avconv -i 'concat:VTS_01_1.VOB|VTS_01_2.VOB|VTS_01_3.VOB|VTS_01_4.VOB|VTS_01_5.VOB' -acodec copy -vcodec copy merged-output.mpeg

List the last modified file in a folder:

Works only with zsh, not bash.
"." stands for files (optional, other qualifiers: "@" - links, "/" - dirs)
"om" means order by modification date
"[1]" selects the first entry from the list
andre@nairobi ~ % ls -l ~/Downloads/*(.om[1])
-rw-r--r-- 1 andre andre 34796931 Jul 29 18:49 /home/andre/Downloads/software-dlan-cockpit-linux-v4-2-3.run

Add an existing group to an existing users supplementary groups

The group vboxsf will be added to tester's suppl. groups:
root@testbox ~ % usermod -a -G vboxsf tester
root@testbox ~ % groups tester
tester: tester cdrom sudo vboxsf

Sort images by exif metadata timestamp

Creates a links for each parseable file of current directory into /tmp/cronolinks.
The link name will be like timestamp + "__" + originalfilename, so you can sort it easily with your file explorer.
# prepare targetdir:
andre@nairobi ~ % mkdir /tmp/cronolinks
andre@nairobi ~ % rm -fr /tmp/cronolinks/* 

# go to the directory with the images and collect metadata to a tempfile:

andre@nairobi /opt/ipad-photos % exiv2 print *(.) | grep -Ei 'Image timestamp' | sed 's/\s*Image timestamp ://g' > /tmp/chronolinks.txt

# /tmp/chronolinks.txt looks like:
DSCN3020.JPG 2014:07:24 14:18:23
GOPR0145.JPG 2014:07:18 21:09:18
DSCN3023.JPG 2014:07:24 14:34:24
IMG_3950.JPG 2014:07:24 14:46:49


# translate output to shell script using sed and let bash execute it.
andre@nairobi /opt/ipad-photos % cat /tmp/chronolinks.txt | sed 's|^\s*\(\S\S*\)\s\s*\(\S\S*\)\s\s*\(\S\S*\)|cp -v "\1" "/tmp/cronolinks/\2_\3__\1"|g' | bash

# bash will execute commands like:
cp -v "DSCN3056.JPG" "/tmp/chronolinks/2014:07:26_13:29:37__DSCN3056.JPG"
cp -v "GOPR0068.JPG" "/tmp/chronolinks/2014:07:13_14:39:03__GOPR0068.JPG"
cp -v "GOPR0294.JPG" "/tmp/chronolinks/2014:07:27_04:51:20__GOPR0294.JPG"
cp -v "IMG_0019.JPG" "/tmp/chronolinks/2014:07:09_11:03:22__IMG_0019.JPG"
cp -v "IMG_0036.JPG" "/tmp/chronolinks/2014:07:09_19:47:14__IMG_0036.JPG"

Or, use my shell script. Allows to apply offsets by camera model, for example when you have forgotten to adjust the watch on the camera in a different time zone.

#!/bin/bash

TARGET="/tmp/chronosort-`date +%F`-$RANDOM"
mkdir "$TARGET"
echo "target directory: $TARGET"


find . -type f | while read PIC; do
    echo PIC: ${PIC}
    if [ -f "$PIC" ]; then # see if PIC is a file
        if [[ "$(file -b --mime-type "$PIC" )" == "image/jpeg" ]]; then
            TIMESTAMP_STRING=$(exiv2 "$PIC" | grep -i timestamp | grep -Eo "[0-9].*[0-9]")
#            echo "timestamp string from exif data: $TIMESTAMP_STRING"

            # convert the exif string to a date:
            DATE="$(
                date -d "$(
                    echo ${TIMESTAMP_STRING} \
                    | sed 's|\([0-9]*\):\([0-9]*\):\([0-9]*\) \([0-9]*\):\([0-9]*\):\([0-9]*\)|\1/\2/\3 \4:\5:\6|g'
                )"
            )"

            # apply offset for specific camera model (optional, uncomment if needed)
#            if ( exiv2 "$PIC" | grep "Camera" | grep -qi "casio" ); then
#                echo modifying time for casio camera...
#                DATE="$( date -d "$DATE -31 minutes" )"
#            fi
            echo "DATE: ${DATE}"


            DATE_FILENAME=$( date -d "$DATE" "+%Y-%m-%d_%H:%M:%S" )
            TARGET_NAME="${DATE_FILENAME}__$(basename "$PIC" )"
            TARGET_FILE="$TARGET/$TARGET_NAME"
#            echo TARGET_FILE: $TARGET_FILE

            # create dir if needed:
            mkdir -pv "$(dirname "$TARGET_FILE" )"

            cp -v "$PIC" "$TARGET_FILE"
        else
            echo "Not a file, skipping $PIC....."
        fi
        echo
    fi
done

Resize image(s)

Resizes the image original.jpeg to a new file resized.jpeg to a maximum of 900x900 pixel size and allow compression to produce small files for web sites.
andre@nairobi ~ % convert -resize '900x900>' -quality 80 -verbose original.jpeg resized.jpeg
I used this in a one-liner like this to bulk-resize a set of folders into a folder WEB_FORMAT:
andre@nairobi ~ % for i in 2014*; do targetdir="./WEB_FORMAT/$i"; mkdir -p "$targetdir"; for f in "$i"/*; do convert -resize '900x900>' -quality 80 -verbose "$f" "$targetdir/$( basename "$f" )"; done; done;