Rename corrupt file like FILE0000.CHK and FILE0001.CHK to the right extention

Last week a friend of me what in a huge stress because he couldn't read the music and photos anymore from his USB-stick / pen-drive.

First make a copy of all file to you localmachine (you never know). Than place this script in the same directory as the file. chmod and run.
That's all!

Create test files of specific size

Sometimes you need file of an exact site for testing purpose like an email attachment.

Here is how you make them in Linux command line:

dd if=/dev/zero of=file_5Mb.txt bs=1k count=5120
dd if=/dev/zero of=file_7Mb.txt bs=1k count=7168
dd if=/dev/zero of=file_8Mb.txt bs=1k count=8192
dd if=/dev/zero of=file_8.8Mb.txt bs=1k count=9011

Backup MySQL Vtiger Database and compress it with zip

Here is a one-liner to backup your VTiger database, give it a timestamp and zip it.

export TMPDATE=$(date +%Y%m%d-%H%M); mysqldump -p vtigercrm50 > $TMPDATE"_vtigercrm50.sql" ; zip $TMPDATE"" $TMPDATE"_vtigercrm50.sql" ; rm $TMPDATE"_vtigercrm50.sql"

Some explanation:


Drupal: Set file permission on filesystem with a shell script

This script is to set all file permissions at once for a Drupal website.

# Script made by David Rush,
# Changes the permissions of the Drupal sites directory to secure after isntallation
# Very Important Put this script in the same directory as your site/ directory

Cheat sheet Screen


Screen Home:

-ctrl a c -> create new window
-ctrl a A -> set window name
-ctrl a w -> show all window
-ctrl a 1|2|3|... -> switch to window n
-ctrl a " -> choose window
-ctrl a ctrl a -> switch between window
-ctrl a d -> detach window
-ctrl a ? -> help

How-To find process ID

To find the process ID from a running process use this command:

echo `ps aux | awk '/pst/ && \!/awk/ {print $2}'`

Replace "pst" with the process name you are looking for

Converte Desktop recording file .ogv to mpeg format


If you make a recording of your desktop using gtk-recordMyDesktop you get a screencast file in .ovg format. With memcoder you can convert that easy to a mpeg format using this command.

mencoder infile.ogv -oac lavc -ovc lavc -lavcopts abitrate=160 -o outfile.mpeg

Log your running torrents



This is a solution for torrent downloaders with btdownloadcurses and the machines has to be rebooted. The script saves all running downloads every X minutes to a file. After reboot you can easily start the torrent-downloads again.


How To Resize images with command line


If you want to resize your photos it's simple to use resize tool in gThumb. Unfortunately gThumb deletes all the EXIF data like date and time the photo was taken.

To keep all EXIF data I use convert (from imagemagic)

find ./ -iname *.JPG" -maxdepth 0 -exec convert {} -resize 50% ./resized/{} \;

How To Adjust Date and/or Time setting in EXIF date from JPG pictures


Sometimes it happend: The clock from your digital camera isn't on the right time. So all your pictures have the wrong date or time in EXIF data. This can be a very big problem if you use more than one camera and want to sort the pictures of a event on the date and time that the picture was taken.