Misc console stuff, settings and scripts
Some Unix / FreeBSD specific stuff I need once in a while but which I’m unable to learn by heart ;)
German keyboard layout in X11
Insert the following line into the keyboard (InputDevice) section of xorg.conf:
Option "XkbLayout" "de"
IceWM Desktop with rox & GDeskCal
Insert the following line into your .xsession (and/or your .xinitrc):
icewm-session & rox -p=Desktop & gdeskcal
German language in X11
Insert the following line into your .profile:
export LANG=de_DE.ISO8859-1
Recursively copy the content of directory1 to directory2
Preserving sparse files, permissions, timestamps, symlinks, owner, group, executability:
# rsync -lrSvpogEt directory1/ directory2/ or (long form): # rsync --links --recursive --sparse --verbose --perms --owner --group --executabilty --times directory1/ directory2/ alternatively (very short form which also copies devices and special files): # rsync -aSv directory1/ directory2/
Loop stuff
Mass rename all files with the ending .avi to .mp4
for i in *.avi; do mv $i `basename $i avi`mp4 ; done
Resize all .jpg images in the current folder to 800x600 (with ImageMagick)
for i in `ls *.jpg`; do convert $i -resize 800x600 $i ; done
The usual Unix find madness
Delete all files named "fw*" in the current directory that are older than 30 days
# find . -name "fw*" -mtime +30 -exec rm {} \;
Replace "expression1" by "expression2" in all files in the current directory
# find . -exec perl -pi -e s/expression1/expression2/g {} \;
Hard disk imaging
Create a gzipped image of an NTFS partition with Linux
# ntfsclone --save-image -o - /dev/hda1 | gzip -c > /mnt/nas02/backup_name.img.gz
Restore a gzipped image of an NTFS partition with Linux
# gunzip -c /mnt/usb/backup_name.img.gz | ntfsclone --restore-image --overwrite /dev/hda1
Create an image of the the MBR and boot sector of a hard drive
# dd if=/dev/hda of=mbrboot.img bs=512 count=2
Create an image of the the MBR only
# dd if=/dev/hda of=mbr.img bs=446 count=1
AMIGA Shell section
Applies to AROS, too…
Create an lha archive recursively with subdirs
lha -e -r -a -x a ram:mydir.lha dh0:mydir/