1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3 <title>grml.org - grml Tips</title>
4 <meta name="Title" content="grml.org - grml Tips" />
5 <meta name="Author" content="the grml team [www.grml.org/team/]" />
6 <meta name="Keywords" content="grml.org, grml" />
7 <meta name="Description" content="grml Tips" />
8 <meta name="Abstract" content="grml, just another linux-distribution" />
9 <meta name="Robots" content="index,follow" />
10 <meta name="Language" content="english" />
11 <meta name="identifier-url" content="https://grml.org/" />
12 <meta name="MSSmartTagsPreventParsing" content="true" />
13 <meta http-equiv="imagetoolbar" content="no" />
14 <link rel="home" href="/" title="grml.org" />
15 <link rel="help" href="/features/" title="About" />
16 <link rel="author" href="/team/" title="Team" />
17 <link rel="icon" href="/favicon.png" type="image/png" />
18 <link rel="stylesheet" href="/style.css" type="text/css" />
24 Install grml to harddisk:
28 Notice: You can pre-select the partition for the partition selector
29 and mbr dialogs inside grml2hd using:
30 # grml2hd /dev/hda1 -mbr /dev/hda
32 See: man grml2hd + http://grml.org/grml2hd/
34 Tags: grml2hd, installation
36 <a name="1"></a><hr />
38 Install grml on software RAID level 1:
40 Create /dev/md0 (and some more /dev/md* devices) first of all:
41 # cd /dev && MAKEDEV dev
44 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdc1
46 Finally install grml on it:
47 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
49 See: man grml2hd + http://grml.org/grml2hd/
51 Tags: grml2hd, installation, mdadm, raid
53 <a name="2"></a><hr />
55 Install grml in non interactive mode with grml2hd:
57 Adjust configuration as needed:
58 # vim /etc/grml2hd/config
62 # GRML2HD_NONINTERACTIVE=yes grml2hd
68 Use with care and only if you really know what you are doing!
70 See: man grml2hd + http://grml.org/grml2hd/
72 Tags: grml2hd, installation
74 <a name="3"></a><hr />
80 Tags: configuration, network
82 <a name="4"></a><hr />
84 Deactivate error correction of zsh:
88 Run zsh-help for more information regarding zsh.
90 Tags: zsh, configuration
92 <a name="5"></a><hr />
94 Disable automatic setting of title in GNU screen:
98 Set it manually e.g. via:
100 % screen -X title foobar
102 Run zsh-help for more information regarding zsh.
104 Tags: zsh, configuration
106 <a name="6"></a><hr />
108 Do not use menu completion in zsh:
112 Run zsh-help for more information regarding zsh.
114 Tags: zsh, configuration
116 <a name="7"></a><hr />
118 Run GNU screen with grml-configuration:
124 % screen -c /etc/grml/screenrc
126 Tags: screen, configuration
128 <a name="8"></a><hr />
130 Print out grml-version:
136 <a name="9"></a><hr />
144 <a name="10"></a><hr />
146 Configure mutt-ng / muttng:
152 <a name="11"></a><hr />
154 Set up Inode-PPTP connection:
158 # grml-pptp-xdsl-students
160 Tags: pptp, inode, xdsl
162 <a name="12"></a><hr />
164 Set up VPN / WLAN connection at TUG (TU Graz):
166 Set ESSID and request for ip-address via DHCP:
167 # iwconfig $DEVICE essid tug
170 Now run the main script:
173 After running the script an init script is available:
175 # /etc/init.d/vpnctug [start|stop]
179 <a name="13"></a><hr />
181 Set up PPTP connection at VCG (Virtual Campus Graz):
187 <a name="14"></a><hr />
191 # grml-vpn <options>
195 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
199 Tags: grml, vpn, network
201 <a name="15"></a><hr />
203 Use encrypted files / partitions:
205 # grml-crypt <options>
211 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
212 # cp big_file /mnt/test
213 # grml-crypt stop /mnt/test
217 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
218 # grml-crypt stop /mnt/test
222 Tags: crypto, grml-crypt, dmcrypt, luks
224 <a name="16"></a><hr />
226 Change resolution of X:
228 % xrandr -s '1024x768'
230 Tags: x11, xorg, resolution
232 <a name="17"></a><hr />
234 Change resolution of framebuffer:
240 <a name="18"></a><hr />
242 Configure newsreader slrn:
248 <a name="19"></a><hr />
250 Configure grml system:
254 Or directly run scripts:
259 Tags: grml, configuration
261 <a name="20"></a><hr />
263 Lock screen (X / console):
267 Press ctrl-alt-x to lock a GNU screen session.
269 Tags: grml, lock, grml-lock, screen
271 <a name="21"></a><hr />
273 Change wallpaper in X:
275 % grml-wallpaper <press-tab>
277 Tags: grml, wallpaper
279 <a name="22"></a><hr />
281 Start X window system (XFree86 / Xorg / X.org):
283 % grml-x $WINDOWMANAGER
288 % grml-x -mode '1024x768' wmii
289 % grml-x -nosync wm-ng
291 Tags: grml-x, x11, xorg, graphic
293 <a name="23"></a><hr />
295 Collect hardware information:
299 or run as root to collect some more information:
303 will generate a file named info.tar.bz2.
305 Tags: grml, hardware, hwinfo, collect
307 <a name="24"></a><hr />
309 Configure hardware detection features of harddisk installation:
313 or manually edit /etc/grml/autoconfig[.small]
315 See: man grml-autoconfig
317 Tags: grml, installation, configuration
319 <a name="25"></a><hr />
321 Bootoptions / cheatcodes / bootparams for booting grml:
323 On the grml-ISO if not running grml:
324 % less /cdrom/GRML/grml-cheatcodes.txt
327 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
329 Tags: grml, cheatcodes, boot, bootoptions, bootparam
331 <a name="26"></a><hr />
333 Report bugs to Debian's Bug Tracking System (BTS):
335 % reportbug --bts debian
337 or adjust /etc/reportbug.conf to your needs.
341 http://grml.org/bugs/
342 http://www.debian.org/Bugs/
344 Tags: bug, reportbug, bts, debian
346 <a name="27"></a><hr />
348 Offline documentation:
352 Online documentation:
355 http://grml.org/docs/
356 http://wiki.grml.org/doku.php
358 Tags: info, grml, grml-info, documentation
360 <a name="28"></a><hr />
362 Mount NTFS partition (read-write):
364 # mount.ntfs-3g /dev/sda1 /mnt/sda1
368 <a name="29"></a><hr />
370 Overwrite specific file on an NTFS partition:
372 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
374 <a name="30"></a><hr />
376 Resize an NTFS partition:
382 ntfsresize -n -s 10G /dev/hda1 # testcase
383 ntfsresize -s 10G /dev/hda1 # testing was successfull, now really resize partition
384 cfdisk /dev/hda # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
386 Tags: ntfs, resize, ntfsresize
388 <a name="31"></a><hr />
390 Modify resolution for intel graphic chipsets:
396 # 915resolution 4d 1400 1050
398 <a name="32"></a><hr />
400 Connect bluetooth mouse:
404 ... and press 'connect' button on your bluetooth device.
406 <a name="33"></a><hr />
408 Connect bluetooth headset:
412 ... and press 'connect' button on your bluetooth device.
414 <a name="34"></a><hr />
416 Secure delete file / directory / partition:
422 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
424 Tags: delete, secure, wipe, shred
426 <a name="35"></a><hr />
428 Use grml on Samsung X20 laptop:
430 # apt-get install grml-samsung-x20
432 See: http://www.michael-prokop.at/computer/samsung_x20.html
434 <a name="36"></a><hr />
436 Development information regarding grml:
438 http://blog.grml.org/
440 Tags: blog, grml, developmnet
442 <a name="37"></a><hr />
446 #grml on irc.oftc.net - https://grml.org/irc/
447 http://grml.org/contact/
449 Tags: contact, irc, oftc, email
451 <a name="38"></a><hr />
453 Join the grml mailinglist:
455 http://grml.org/mailinglist/
457 Tags: grml, mailinglist
459 <a name="39"></a><hr />
463 http://grml.org/donations/
467 <a name="40"></a><hr />
469 Commercial support / system administration / adjusted live-cds:
471 grml-solutions: http://grml.org/solutions/
473 Tags: grml, commercial, customize
475 <a name="41"></a><hr />
477 Information regarding the kernel provided by grml:
479 http://grml.org/kernel/
481 Tags: documentation, grml, kernel
483 <a name="42"></a><hr />
485 SMTP command-line test tool:
487 % swaks <options>
491 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
495 Tags: swak, smtp, test
497 <a name="43"></a><hr />
499 NTFS related packages:
507 <a name="44"></a><hr />
509 Modify service through init script:
516 # /etc/init.d/lvm start
518 Tags: init, script, start, stop
520 <a name="45"></a><hr />
524 # jstest /dev/input/js0
526 <a name="46"></a><hr />
530 % mplayer /path/to/movie
534 <a name="47"></a><hr />
536 Use webcam with mplayer:
538 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
540 Tags: webcam, mplayer
542 <a name="48"></a><hr />
544 Powerful network discovery tool:
548 Tags: network, python, tool
550 <a name="49"></a><hr />
552 Grab an entire CD and compress it to Ogg/Vorbis,
553 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
557 Tags: rip, abcde, mp3, transcode, audio
559 <a name="50"></a><hr />
561 Show a console session in several terminals:
565 <a name="51"></a><hr />
567 Switch behaviour of caps lock key:
571 <a name="52"></a><hr />
573 grep with Perl-compatible regular expressions:
577 <a name="53"></a><hr />
579 ncp: a fast file copy tool for LANs
584 Remote (receive file):
587 Tags: copy, file, network
589 <a name="54"></a><hr />
591 utility for sorting records in complex ways:
595 <a name="55"></a><hr />
597 a smaller, cheaper, faster SED implementation:
601 <a name="56"></a><hr />
607 See: http://grml.org/zsh/
609 <a name="57"></a><hr />
611 zsh reference card for grml system:
614 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
616 <a name="58"></a><hr />
620 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
622 % prename 's/foo/bar/' foo*
624 % zmv 'foo(*)' 'bar$1'
626 <a name="59"></a><hr />
628 Test TFT / LCD display:
632 <a name="60"></a><hr />
638 <a name="61"></a><hr />
640 Improved grep version:
644 <a name="62"></a><hr />
646 Grep with highlighting:
648 % grep --color=auto ...
651 Tags: grep, color, highlight
653 <a name="63"></a><hr />
655 Extract matches when grepping:
658 % ifconfig | grepc 'inet addr:(.*?)s'
659 % ifconfig | glark --extract-matches 'inet addr:(.*?)s'
661 <a name="64"></a><hr />
663 Output text as sound:
666 % xsay # when running X and text selected via mouse
668 <a name="65"></a><hr />
670 Adjust a grml harddisk (grml2hd) installation:
674 Tags: grml2hd, configuration, installation
676 <a name="66"></a><hr />
678 Get information on movie files:
680 % tcprobe -i file.avi
682 <a name="67"></a><hr />
684 Get an overview of your image files:
686 % convert 'vid:*.jpg' thumbnails.jpg
688 <a name="68"></a><hr />
690 List all standard defines:
692 % gcc -dM -E - < /dev/null
694 <a name="69"></a><hr />
696 Send a mail as reminder:
698 echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
700 <a name="70"></a><hr />
702 ncurses-based presentation tool:
706 See: man tpp and /usr/share/doc/tpp/examples/
708 <a name="71"></a><hr />
710 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
714 <a name="72"></a><hr />
716 Use IRC on command line:
720 <a name="73"></a><hr />
724 % vimdiff file1 file2
730 Moving between diffs:
740 <a name="74"></a><hr />
742 Hardware monitoring without kernel dependencies:
746 <a name="75"></a><hr />
748 Install grml-iso to usb-stick:
750 % grml2usb grml.iso /mount/point
752 Tags: usbpen, usbstick, installation, grml2usb
754 <a name="76"></a><hr />
756 Use mplayer on framebuffer console:
758 % mplayer -vo fbdev ...
760 <a name="77"></a><hr />
762 Use links2 on framebuffer console:
764 % links2 -driver fb ...
766 <a name="78"></a><hr />
768 Switch language / keyboard:
770 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
771 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
772 Usage example: 'grml lang=us keyboard=de xkeyboard=de'
774 Or run one of the following commands:
778 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
781 Tags: language, keyboard, configuration
783 <a name="79"></a><hr />
785 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
789 <a name="80"></a><hr />
791 Mount usb device / usb stick:
793 % mount /mnt/external1 # corresponds to /dev/sda1
795 % mount /mnt/external # corresponds to /dev/sda
797 <a name="81"></a><hr />
799 Install Sun Java packages:
801 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
803 # apt-get install java-package
804 # fakeroot make-jpkg j2re-*.bin
805 # dpkg -i sun-j2re*.deb
806 # update-alternatives --config java
808 <a name="82"></a><hr />
812 ddrescue is an improved version of dd which tries to read and
813 if it fails it will go on with the next sectors, where tools
820 <a name="83"></a><hr />
822 How to make an audio file (e.g. Musepack format) out of a DVD track:
824 % mkfifo /tmp/fifo.wav
825 % mppenc /tmp/fifo.wav track06.mpc &
826 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
828 Adjust the mppenc line with the encoder you would like to use,
829 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
833 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
834 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
836 Usage example for getting a PCM/wave file from audio channel 128:
837 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
839 <a name="84"></a><hr />
841 Create simple chroot:
843 # make_chroot_jail $USERNAME
845 <a name="85"></a><hr />
847 Convert DOS formated file to unix format:
849 sed 's/.$//' dosfile > unixfile # assumes that all lines end with CR/LF
850 sed 's/^M$//' dosfile > unixfile # in bash/tcsh, press Ctrl-V then Ctrl-M
851 sed 's/x0D$//' dosfile > unixfile # gsed 3.02.80, but top script is easier
852 awk '{sub(/r$/,"");print}' # assumes EACH line ends with Ctrl-M
853 gawk -v BINMODE="w" '1' infile >outfile # in DOS environment; cannot be done with
854 # DOS versions of awk, other than gawk
855 tr -d r < dosfile > unixfile # GNU tr version 1.22 or higher
856 tr -d '015' < dosfile > unixfile # use octal value for "r" (see man ascii)
857 tr -d '[015032]' < dosfile > unixfile # sometimes ^Z is appended to DOS-files
858 vim -c ":set ff=unix" -c ":wq" file # convert using vim
859 vim -c "se ff=dos|x" file # ... and even shorter ;)
860 recode ibmpc..lat1 file # convert using recode
861 echo -e "s/r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
863 Tags: windows, line, convert, recode, tr, line end,
865 <a name="86"></a><hr />
867 Save live audio stream to file:
869 % mplayer -ao pcm:file=$FILE $URL
871 <a name="87"></a><hr />
873 Save live stream to file:
875 % mplayer -dumpfile $FILE -dumpstream $STREAM
879 % mencoder mms://$URL -o $FILE -ovc copy -oac copy
883 % mimms mms://file.wmv
885 <a name="88"></a><hr />
891 % avimerge -i *.avi -o blub.avi
895 % cat *.mpg > blub.mpg
899 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
900 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
901 % avimerge -i file1.avi file2.avi -o blub.avi
903 <a name="89"></a><hr />
905 Display MS-Word file:
907 % strings file.doc | fmt | less
913 <a name="90"></a><hr />
915 Convert MS-Word file to postscript:
917 % antiword -p a4 file.doc > file.ps
919 <a name="91"></a><hr />
921 Convert manual to postscript:
923 % zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
925 % man -t zsh > zsh.ps
927 <a name="92"></a><hr />
931 % dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
933 <a name="93"></a><hr />
935 Read HTTP via netcat:
937 echo -e "GET / HTTP/1.1rnHost: $DOMAINrnrn" | netcat $DOMAIN 80
939 <a name="94"></a><hr />
941 Get X ressources for specific program:
943 % xrdb -q |grep -i xterm
945 <a name="95"></a><hr />
947 Get windowid of specific X-window:
949 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
951 <a name="96"></a><hr />
953 Get titel of specific X-window:
957 <a name="97"></a><hr />
959 check locale - LC_MESSAGES:
961 % locale -ck LC_MESSAGES
963 <a name="98"></a><hr />
965 Create random password:
969 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
971 <a name="99"></a><hr />
973 Get tarballs of various Linux Kernel trees:
976 to get the current stable 2.6 release
979 to get a list of all supported trees
981 <a name="100"></a><hr />
983 Transfer your SSH public key to another host:
985 % ssh-keygen # ssh-keygen / ssh-key-gen: if you don't have a key yet
987 % ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
989 % cat $HOME/.ssh/id_rsa.pub | ssh user@remote-system 'cat >> .ssh/authorized_keys'
991 Tags: ssh, ssh key, public key, ssh-copy-id, ssh-keygen
993 <a name="101"></a><hr />
995 Update /etc/fstab entries:
999 See "man grml-rebuildfstab" for more details about
1000 generation of /etc/fstab (including stuff like
1001 fs LABELs / UUIDs,...).
1003 <a name="102"></a><hr />
1005 Fetch and potentially change SCSI device parameters:
1011 <a name="103"></a><hr />
1013 reclaim disk space by linking identical files together:
1017 <a name="104"></a><hr />
1019 Find and remove duplicate files:
1023 <a name="105"></a><hr />
1025 Perform layer 2 attacks:
1029 Tags: network, attack, security
1031 <a name="106"></a><hr />
1035 <a name="107"></a><hr />
1037 Guess PC-type hard disk partitions / partition table:
1039 # gpart <options>
1041 Perform a standard scan:
1044 Write back the guessed table:
1045 # gpart -W /dev/ice /dev/ice
1047 Tags: partition, recovery, disk
1049 <a name="108"></a><hr />
1051 Develop, test and use exploit code with the Metasploit Framework:
1054 wget http://spool.metasploit.com/releases/framework-3.2.tar.gz
1055 unp framework-3.2.tar.gz
1059 <a name="109"></a><hr />
1061 Useful documentation:
1063 % w3m /usr/share/doc/Debian/reference/reference.en.html
1065 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
1067 http://grml.org/docs/ grml Documentation
1068 http://wiki.grml.org/ grml Wiki
1069 http://www.debian.org/doc/ Debian Documentation
1070 http://wiki.debian.org/ Debian Wiki
1071 http://www.gentoo.org/doc/en/ Gentoo Documentation
1072 http://gentoo-wiki.com/ Gentoo Wiki
1073 http://www.tldp.org/ The Linux Documentation Project
1077 % fortune debian-hints
1081 <a name="110"></a><hr />
1085 % fortune debian-hints
1086 % dpkg -L funny-manpages
1088 <a name="111"></a><hr />
1090 Backup master boot record (MBR):
1092 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
1096 <a name="112"></a><hr />
1098 Backup partition table:
1100 # sfdisk -d /dev/hda > hda.out
1102 Restore partition table:
1104 # sfdisk /dev/hda < hda.out
1106 Tags: backup, partition, sfdisk, recovery
1108 <a name="113"></a><hr />
1110 Clone disk via network using netcat:
1113 # nc -vlp 30000 > hda1.img
1115 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
1117 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
1120 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
1122 Tags: network, backup, dd, netcat
1124 <a name="114"></a><hr />
1126 Backup specific directories via cpio and ssh:
1128 # for f in directory_list; do find $f >> backup.list done
1129 # cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
1133 <a name="115"></a><hr />
1137 This one uses CPU cycles on the remote server to compare the files:
1138 # ssh target_address cat remotefile | diff - localfile
1139 # cat localfile | ssh target_address diff - remotefile
1141 This one uses CPU cycles on the local server to compare the files:
1142 # ssh target_address cat <localfile "|" diff - remotefile
1144 Tags: network, backup, ssh
1146 <a name="116"></a><hr />
1148 Useful tools for cloning / backups:
1150 * dd: convert and copy a file
1151 * dd_rescue: copies data from one file (or block device) to another
1152 * pcopy: a replacement for dd
1153 * partimage: back up and restore disk partitions
1154 * dirvish: Disk based virtual image network backup system
1155 * devclone: in-place filesystem conversion -- device cloning
1156 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
1157 * dump: ext2/3 filesystem backup
1158 * udpcast: multicast file transfer tool
1159 * cpio: copy files to and from archives
1160 * pax: read and write file archives and copy directory hierarchies
1161 * netcat / ssh / tar / gzip / bzip2: additional helper tools
1163 Tags: network, backup, ssh, udp, rescue, recovery
1165 <a name="117"></a><hr />
1167 Use grml as a rescue system:
1171 * dd: convert and copy a file
1172 * ddrescue: copies data from one file or block device to another
1173 * partimage: Linux/UNIX utility to save partitions in a compressed image file
1174 * cfdisk: Partition a hard drive
1175 * nparted: Newt and GNU Parted based disk partition table manipulator
1176 * parted-bf: The GNU Parted disk partition resizing program, small version
1177 * testdisk: Partition scanner and disk recovery tool
1178 * gpart: Guess PC disk partition table, find lost partitions
1182 * e2fsprogs: ext2 file system utilities and libraries
1183 * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
1184 * e2undel: Undelete utility for the ext2 file system
1185 * ext2resize: an ext2 filesystem resizer
1186 * recover: Undelete files on ext2 partitions
1190 * reiser4progs: administration utilities for the Reiser4 filesystem
1191 * reiserfsprogs: User-level tools for ReiserFS filesystems
1195 * xfsdump: Administrative utilities for the XFS filesystem
1196 * xfsprogs: Utilities for managing the XFS filesystem
1200 * jfsutils: utilities for managing the JFS filesystem
1204 * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
1205 * salvage-ntfs: free NTFS data recovery tools
1206 * scrounge-ntfs: data recovery program for NTFS file systems
1207 * ntfsresize: resize ntfs partitions
1209 Tags: ntfs, jfs, xfs, ext3, rescue, recovery, backup, filesystem, tools
1211 <a name="118"></a><hr />
1213 Get ASCII value of a character with zsh:
1215 % char=N ; print $((#char))
1217 <a name="119"></a><hr />
1219 Convert a collection of mp3 files to wave or cdr using zsh:
1221 % for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
1223 <a name="120"></a><hr />
1225 Convert images (foo.gif to foo.png) using zsh:
1227 % for i in **/*.gif; convert $i $i:r.png
1229 <a name="121"></a><hr />
1231 Remove all "non txt" files using zsh:
1235 <a name="122"></a><hr />
1237 Remote Shell Using SSH:
1240 % ssh -NR 3333:localhost:22 user@yourhost
1243 % ssh user@localhost -p 3333
1245 Tags: port forwarding, ssh, remote port, network
1247 <a name="123"></a><hr />
1249 Reverse Shell with Netcat:
1252 % netcat -v -l -p 3333 -e /bin/sh
1255 % netcat 192.168.0.1 3333
1257 TagS: port forwarding, ssh, remote, network
1259 <a name="124"></a><hr />
1261 Reverse Shell via SSH:
1263 local host (inside the network):
1264 % ssh -NR 1234:localhost:22 remote_host
1266 remote host (outside the network):
1267 % ssh localhost -p 1234
1269 Tags: port forwarding, ssh, remote port, network
1271 <a name="125"></a><hr />
1273 Remove empty directories with zsh:
1275 % rmdir ./**/*(/od) 2> /dev/null
1277 <a name="126"></a><hr />
1279 Find all the empty directories in a tree with zsh:
1283 <a name="127"></a><hr />
1285 Find all files without a valid owner and change ownership with zsh:
1287 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
1289 <a name="128"></a><hr />
1291 Display the 5-10 last modified files with zsh:
1293 % print -rl -- /path/to/dir/**/*(D.om[5,10])
1295 <a name="129"></a><hr />
1297 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
1299 % print -rl -- **/*(Dom[1,10])
1301 <a name="130"></a><hr />
1303 Find most recent file in a directory with zsh:
1305 % setopt dotglob ; print directory/**/*(om[1])
1307 <a name="131"></a><hr />
1309 Tunnel all traffic through an external server:
1311 % ssh -ND 3333 username@external.machine
1313 Then set the SOCKS4/5 proxy to localhost:3333.
1314 Check whether it's working by surfing e.g. to checkip.dyndns.org
1316 Tags: ssh, network, proxy, socks, tunnel
1318 <a name="132"></a><hr />
1320 Tunnel everything through SSH via tsocks:
1322 set up the SSH proxy on the client side:
1324 % ssh -ND 3333 user@remote.host.example.com
1326 Adjust /etc/tsocks.conf afterwards (delete all other lines):
1331 For programs who natively support proxying connections (e.g. Mozilla
1332 Firefox) you can now set the proxy address to localhost port 3333.
1334 All other programs which's connections you want to tunnel through your
1335 external host are prefixed with tsocks, e.g.:
1337 % tsocks netcat example.com 80
1338 % tsocks irssi -c irc.quakenet.eu.org -p 6667
1340 If you call tsocks without parameters it executes a shell witht the
1341 LD_PRELOAD environment variable already set and exported.
1343 Tags: ssh, network, proxy, socks, tunnel, tsocks
1345 <a name="133"></a><hr />
1347 smartctl - control and monitor utility for harddisks using Self-Monitoring,
1348 Analysis and Reporting Technology (SMART):
1350 # smartctl --all /dev/ice
1352 If you want to use smartctl on S-ATA (sata) disks use:
1354 # smartctl -d ata --all /dev/sda
1357 # smartctl -t offline /dev/ice
1360 # smartctl -t short /dev/ice
1362 Display results of test:
1363 # smartctl -l selftest /dev/ice
1365 Query device information:
1366 # smartctl -i /dev/ice
1368 Tags: smart, s.m.a.r.t, info, test, hardware
1370 <a name="134"></a><hr />
1372 Mount a BSD / Solaris partition:
1374 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
1376 Use ufstype 44bsd for FreeBSD, NetBSD, OpenBSD (read-write).
1377 Use ufstype ufs2 for >= FreeBSD 5.x (read-only).
1378 Use ufstype sun for SunOS (Solaris) (read-write).
1379 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
1381 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
1384 Tags: ufs, bsd, mount, solaris
1386 <a name="135"></a><hr />
1388 Read BIOS (and or BIOS) password:
1390 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
1392 <a name="136"></a><hr />
1394 Clone one of the kernel trees via git:
1396 git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
1397 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1398 This path defines the tree. See http://kernel.org/git/ for an overview.
1400 <a name="137"></a><hr />
1402 Mount filesystems over ssh protocol:
1404 % sshfs user@host:/remote_dir /mnt/test
1408 % fusermount -u /mnt/test
1410 (Notice: requires fuse kernel module)
1412 Tags: ssh, sshfs, network, mount, directory, remote, fuse
1414 <a name="138"></a><hr />
1416 Install Gentoo using grml:
1418 See http://www.gentoo.org/doc/en/altinstall.xml
1420 <a name="139"></a><hr />
1422 Install (plain) Debian (sarge release) via grml:
1424 Assuming you want to install Debian to sda1:
1426 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1427 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1428 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1429 chroot /mnt/test /bin/bash # let's chroot into the new system
1430 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
1431 mount -t proc none /proc # make sure we also have a mounted /proc
1432 base-config # now configure some main settings
1433 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
1434 cd /dev ; ./MAKEDEV generic # make sure we have all necessary devices for lilo
1435 apt-get install lilo linux-image-2.6.12-1-386 # install lilo and a kernel which fits your needs
1436 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
1437 vi /etc/lilo.conf && lilo # adjust the file for your needs and run lilo afterwards
1438 umount /proc ; umount /dev/pts # we do not need them any more
1439 exit # now leave chroot
1440 cp /etc/hosts /etc/fstab /mnt/test/etc/ # you might want to take the existing files...
1441 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
1442 umount /mnt/test && reboot # unmount partition and reboot...
1444 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1445 Avoid all of the above steps - use grml-debootstrap(8) instead!
1447 Tags: manual, installation, debian, debootstrap
1449 <a name="140"></a><hr />
1451 Install (plain) Debian (etch release) via grml
1453 Assuming you want to install Debian to sda1:
1455 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1456 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1457 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1458 chroot /mnt/test /bin/bash # let's chroot into the new system
1459 mount -t proc none /proc # make sure we have a mounted /proc
1460 apt-get install locales console-data # install locales
1461 dpkg-reconfigure locales console-data # adjust locales to your needs
1462 apt-get install vim most zsh screen less initrd-tools file grub usbutils pciutils bzip2 sysfsutils dhcp3-client resolvconf strace lsof w3m # install useful software
1463 apt-get install linux-headers-2.6-686 linux-image-686 # install current kernel
1465 echo "127.0.0.1 localhost" > /etc/hosts # adjust /etc/hosts and network:
1466 cat >> /etc/network/interfaces << EOF
1467 iface lo inet loopback
1468 iface eth0 inet dhcp
1473 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1474 cat >> /etc/fstab << EOF
1475 sysfs /sys sysfs auto 0 0
1476 proc /proc proc defaults 0 0
1477 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1
1478 /dev/sda2 none swap sw 0 0
1479 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
1481 passwd # set password of user root
1483 mkdir /boot/grub # setup grub
1484 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1485 cat >> /boot/grub/menu.lst << EOF
1486 title Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1488 kernel /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1489 initrd /boot/initrd.img-2.6.18-3-686
1491 vim /boot/grub/menu.lst # adjust grub configuration to your needs
1492 cd /dev && MAKEDEV generic # create default devices
1493 cp -i /usr/lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1494 grub install # now install grub, run in grub-cmdline following commands:
1498 umount -a # unmount all filesystems in chroot and finally:
1499 exit # exit the chroot and:
1502 If you want to use lilo instead of grub take a look at
1503 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1505 cat > /etc/lilo.conf << EOF
1506 # This allows booting from any partition on disks with more than 1024 cylinders.
1509 # Specifies the boot device
1512 # Specifies the device that should be mounted as root.
1515 # use Debian on software raid:
1516 # raid-extra-boot=mbr-only
1524 image=/boot/vmlinuz-2.6.18-grml
1528 initrd=/boot/initrd.img-2.6.18-grml
1531 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1532 Avoid all of the above steps - use grml-debootstrap(8) instead!
1534 Tags: manual, installation, debian, debootstrap, howto
1536 <a name="141"></a><hr />
1538 Convert files from Unicode / UTF-8 to ISO:
1540 % iconv -c -f utf8 -t iso-8859-15 < utffile > isofile
1544 % iconv -f iso-8859-15 -t utf8 < isofile > utffile
1546 Tags: utf-8, iso, unicode, utf8
1548 <a name="142"></a><hr />
1550 Assign static setup for network cards (NICs) via udev:
1552 Retrieve information for address (corresponding to MAC address):
1554 # udevadm info -a -p /sys/class/net/eth0/ | grep -i 'ATTR{address}'
1556 Execute /lib/udev/write_net_rules with according values (INTERFACE
1557 is old NIC name, INTERFACE_NAME is new NIC name and MATCHADDR
1558 is the MAC address retrieved with udevadm info command):
1560 # INTERFACE=eth0 INTERFACE_NAME=lan0 MATCHADDR=00:00:00:00:00:01 /lib/udev/write_net_rules
1562 This will generate file /etc/udev/rules.d/70-persistent-net.rules with content:
1564 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:01", KERNEL=="eth*", NAME="lan0"
1566 Finally take down the interface (ifdown/ifconfig) and execute:
1568 # udevadm trigger --action=add --subsystem-match=net
1570 so the interface will be renamed. (Rebooting or
1571 unloading drivers/restart udev/loading drivers again
1572 works as well of course.)
1574 Tags: udev, configuration, name, eth0, howto
1576 <a name="143"></a><hr />
1578 Change the suffix from *.sh to *.pl using zsh:
1581 % zmv -W '*.sh' '*.pl'
1583 <a name="144"></a><hr />
1585 Generate SSL certificate:
1587 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1588 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1591 # openssl x509 -in certfile -text
1593 Verify against CA certificate:
1594 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1596 Generate 2048bit RSA-key:
1597 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1599 As before but add request to existing key pub-sec-key.pem:
1600 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1602 Show request request.pem:
1603 # openssl req -text -noout -in request.pem
1605 Verify signature of request request.pem:
1606 # openssl req -verify -noout -in request.pem
1608 Generate SHA1 fingerprint (modulo key) of request.pem:
1609 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1611 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1612 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1614 As before but create self signed certificate based on existing key pub-sec-key.pem:
1615 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1617 Generate new request out of existing self signed certificate:
1618 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1620 Display certificate self-signed-certificate.pem in plaintext:
1621 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1623 Check self signed certificate:
1624 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1626 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1627 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1629 Generate ssl-certificate for use with apache2:
1631 export RANDFILE=/dev/random
1632 mkdir /etc/apache2/ssl/
1633 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
1634 chmod 600 /etc/apache2/ssl/apache.pem
1636 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1638 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1640 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1642 Tags: openssl, howto
1644 <a name="145"></a><hr />
1646 Change Windows NT password(s):
1648 # mount -o rw /mnt/hda1
1649 # cd /mnt/hda1/WINDOWS/system32/config/
1650 # chntpw SAM SECURITY system
1652 Notice: if mounting the partition read-write did not work (check syslog!)
1653 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1655 (Be careful with deactivating syskey!)
1657 Tags: password, windows, recovery, chntpw, howto
1659 <a name="146"></a><hr />
1661 glark - replacement for grep written in Ruby:
1663 A replacement for (or supplement to) the grep family, glark offers:
1664 Perl compatible regular expressions, highlighting of matches,
1665 context around matches, complex expressions and automatic exclusion
1670 % glark -y keyword file # display only the region that matched, not the entire line
1671 % glark -o format print *.h # search for either "printf" or "format"
1673 More information: man glark
1675 <a name="147"></a><hr />
1677 Find CD burning device(s):
1679 General information on CD-ROM:
1680 % cat /proc/sys/dev/cdrom/info
1682 Scan using ATA Packet specific SCSI transport:
1683 # cdrecord -dev=ATA -scanbus
1684 # cdrecord-prodvd -s -scanbus dev=ATA
1686 Get specific information for /dev/ice:
1687 # cdrecord dev=/dev/ice -scanbus
1689 Tags: hardware, info, cd burn
1691 <a name="148"></a><hr />
1693 Create devices in /dev on udev:
1695 For example create md devices (/dev/md0, /dev/md1,...):
1696 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1700 <a name="149"></a><hr />
1702 Identify network device (NIC):
1704 # ethtool -i $DEVICE
1706 Show NIC statistics:
1708 # ethtool -S $DEVICE
1710 If your NIC shows some aging signs, you may want to be sure:
1712 # ethtool -t $DEVICE
1714 Disable TCP/UDP checksums:
1716 # ethtool -K $DEVICE tx off
1718 Tags: configuration, network, device
1720 <a name="150"></a><hr />
1722 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1724 Switch to tty12 and take a look at the syslog. If you see something like:
1726 SQUASHFS error: zlib_fs returned unexpected result 0x........
1727 SQUASHFS error: Unable to read cache block [.....]
1728 SQUASHFS error: Unable to read inode [.....]
1730 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1731 Check your CD low-level via running:
1733 # readcd -c2scan dev=/dev/cdrom
1735 If the medium really is ok and it still fails try to boot with deactivated DMA
1736 via using grml nodma at the bootprompt.
1738 Tags: grml2hd, installation, verify, squashfs, error
1740 <a name="151"></a><hr />
1742 Write a Microsoft compatible boot record (MBR) using ms-sys
1744 Write a Windows 2000/XP/2003 MBR to a device:
1746 # ms-sys -m /dev/ice
1748 Notice: grab ms-sys from http://ms-sys.sourceforge.net/ - demo:
1750 wget http://surfnet.dl.sourceforge.net/sourceforge/ms-sys/ms-sys-2.1.3.tgz
1751 unp ms-sys-2.1.3.tgz
1756 Tags: mbr, windows, ms-sys, recovery
1758 <a name="152"></a><hr />
1760 Use a Vodafone 3G Datacard (UMTS) with Linux:
1762 Plug in your vodafone card and check in syslog whether the appropriate
1763 (probably /dev/ttyUSB0 or /dev/noz0) has been created. If so run:
1766 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1769 # comgt -d /dev/ttyUSB0
1770 # wvdial --config /etc/wvdial.conf.umts a1usb
1772 # comgt -d /dev/noz0
1773 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1775 # comgt -d /dev/noz0
1776 # wvdial --config /etc/wvdial.conf.umts dreiusb
1778 # comgt -d /dev/ttyACM0
1779 # wvdial --config /etc/wvdial.conf.umts yesss
1781 If you receive invalid DNS nameservers when connecting, like:
1784 --> primary DNS address 10.11.12.13
1785 --> secondary DNS address 10.11.12.14
1787 just provide a working nameserver to resolvconf via:
1789 # echo "nameserver 80.120.17.70" | resolvconf -a ppp0
1791 Notice: some vodafone cards require the nozomi driver (run 'modprobe nozomi' on
1792 your grml system), some other ones require the sierra driver (run
1795 If your device isn't supported by usbserial yet, manually provide vendor and
1796 product ID when loading the usbserial module. Usage example:
1800 Bus 004 Device 008: ID 1199:6813 Sierra Wireless, Inc.
1802 # modprobe usbserial vendor=0x1199 product=0x6813
1804 To get a list of available providers execute:
1806 # comgt -s -d /dev/ttyUSB0 /etc/comgt/operator
1808 Tags: umts, 3g, vodafone, sierra, wvdial, ppp, howto
1810 <a name="153"></a><hr />
1812 hdparm - get/set hard disk parameters
1814 Display the identification info that was obtained from the drive at boot time,
1816 # hpdarm -i /dev/ice
1818 Request identification info directly from the drive:
1819 # hpdarm -I /dev/ice
1821 Perform timings of device + cache reads for benchmark and comparison purposes:
1822 # hdparm -tT /dev/ice
1824 Tags: hardware, performance, configuration, harddisk
1826 <a name="154"></a><hr />
1828 bonnie++ - program to test hard drive performance.
1830 # mkdir /mnt/benchmark
1831 # mount /dev/ice /mnt/benchmark
1832 # chmod go+w /mnt/benchmark
1833 # bonnie -u grml -d /mnt/benchmark -s 2000M
1835 Tags: benchmark, harddisk
1837 <a name="155"></a><hr />
1839 Use gizmo with a bluetooth headset:
1841 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1842 % gizmo --mic $DEVICE --speaker $DEVICE
1844 <a name="156"></a><hr />
1846 Scan a v4l device for TV stations:
1848 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1850 Then running xawtv should work:
1854 <a name="157"></a><hr />
1856 Run apt-get with timeout of 3 seconds:
1858 # apt-get -o acquire::http::timeout=3 update
1862 <a name="158"></a><hr />
1864 Debian GNU/Linux device driver check page
1866 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1868 <a name="159"></a><hr />
1870 Use dd with status line:
1872 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1874 <a name="160"></a><hr />
1876 Generate a 512k file of random data with status bar:
1878 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1880 <a name="161"></a><hr />
1882 Install Grub instead of lilo on grml installation (grml2hd):
1887 adjust grub's configuration file menu.lst:
1888 # $EDITOR /boot/grub/menu.lst
1890 now install grub (usage example for /dev/sda1):
1897 <a name="162"></a><hr />
1899 Install Ubuntu using grml:
1901 See https://wiki.ubuntu.com/Installation/FromKnoppix
1903 Tags: ubuntu, installation
1905 <a name="163"></a><hr />
1907 Resize ext2 / ext3 partition:
1909 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1910 # fsck.ext2 -v -y -f /dev/iceX # check the filesystem
1911 # resize2fs -p /dev/iceX $SIZE # resize it (adjust $SIZE)
1912 # fdisk /dev/ice # adjust partition in partition table
1913 # fsck.ext2 -v -y -f /dev/iceX # check filesystem again
1914 # resize2fs -p /dev/iceX # resize it to maximum
1915 # tune2fs -j /dev/iceX # re-enable journal
1917 Tags: resize, ext2, ext3, ext4, partition, howto
1919 <a name="164"></a><hr />
1921 Tune ext2 / ext3 filesystem:
1923 Check partition first:
1925 # tune2fs -l /dev/iceX
1927 If you don't see dir_index in the list, then enable it:
1929 # tune2fs -O dir_index /dev/iceX
1931 Now run e2fsck with the -D option to have the directories optimized:
1933 # e2fsck -D /dev/iceX
1935 Notice: since e2fsprogs (1.39-1) filesystems are created with
1936 directory indexing and on-line resizing enabled by default.
1938 Tags: configuration, ext2, ext3, ext4, partition
1940 <a name="165"></a><hr />
1942 Search for printers via network:
1944 # pconf_detect -m NETWORK -i 192.168.0.1/24
1946 Tags: printer, network, scan
1948 <a name="166"></a><hr />
1950 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1952 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1954 Tags: webdav, mount, mediacenter, gmx
1956 <a name="167"></a><hr />
1958 System-Profiling using oprofile:
1963 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1968 Now $DO_SOME_TASKS...
1971 # opcontrol --shutdown
1973 Then take a look at the reports using something like e.g.:
1974 # opreport -t 0.5 --exclude-dependent
1975 # opreport -t 0.5 /path/to/executable_to_check
1976 # opannotate -t 0.5 --source --assembly
1978 Tags: profile, profiling, opcontrol, howto
1980 <a name="168"></a><hr />
1982 Install ATI's fglrx driver for Xorg / X.org:
1984 Usually there already exist drivers for the grml-system:
1985 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1987 After installing adjust xorg.conf via running:
1988 # aticonfig --initial --input=/etc/X11/xorg.conf
1990 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1992 Tags: xorg, x11, driver, ati
1994 <a name="169"></a><hr />
1996 Install nvidia driver for Xorg / X.org:
1998 Usually there already exist drivers for the grml-system:
1999 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
2001 Then switch from module nv to nvidia:
2003 # sed -i 's/Driver.*nv.*/Driver "nvidia"/' /etc/X11/xorg.conf
2005 Tags: xorg, x11, driver, nvidia
2007 <a name="170"></a><hr />
2009 glxgears - a GLX demo that draws three rotating gears
2011 To print frames per second (fps) use:
2012 % glxgears -printfps
2014 Tags: xorg, x11, glx,
2016 <a name="171"></a><hr />
2018 You forgot to boot with 'grml noeject noprompt' to avoid
2019 ejecting and prompting for CD removal when rebooting/halting
2030 If you want to avoid only the prompting part, run:
2038 Tags: bootparam, fix, grml
2040 <a name="172"></a><hr />
2042 Mount wikipedia local via fuse:
2044 Adjust configuration:
2045 % cat ~/.wikipediafs/config.xml
2048 <article-cache-time>300</article-cache-time>
2052 <dirname>wikipedia-de</dirname>
2053 <host>de.wikipedia.org</host>
2054 <basename>/w/index.php</basename>
2057 <dirname>wikipedia-en</dirname>
2058 <host>en.wikipedia.org</host>
2059 <basename>/w/index.php</basename>
2064 Mount it (/wiki must exist of course):
2065 % mount.wikipediafs /wiki
2066 % cat /wiki/wikipedia-en/Cat
2069 % fusermount -u /wiki
2071 Tags: fuse, wikipedia, mount
2073 <a name="173"></a><hr />
2075 Remote notification on X via osd (on screen display):
2077 Start osd_server.py at your local host (listens on port 1234 by default):
2080 Then login to a $REMOTEHOST
2081 % ssh -R 1234:localhost:1234 $REMOTEHOST
2083 Now send the text to your local display via running something like:
2084 % echo "text to send" | nc localhost 1234
2086 Very useful when you are waiting for a long running job
2087 but want to do something else in the meanwhile:
2089 % ./configure && make && echo "finished compiling" | netcat localhost 1234
2091 You can use this in external programs as well of course. Examples:
2093 Use osd in centericq:
2095 % cat ~/.centericq/external
2104 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
2105 CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
2106 osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
2107 if echo | socat - TCP4:localhost:1234 &>/dev/null ; then
2108 echo "${osd_msg}" | netcat localhost 1234
2112 Use it in the IRC console client irssi via running:
2116 You can even activate the port forwarding by default globally:
2121 RemoteForward 1234 127.0.0.1:1234
2124 Notice: if you get 'ABORT: Requested font not found' make sure the
2125 requested font is available, running 'LANG=C LC_ALL=C osd_server.py...'
2128 Tags: osd, notification, ssh, network, port-forwarding
2130 <a name="174"></a><hr />
2132 Avoid automatical startup of init scripts via invoke-rc.d:
2134 First of all make sure the package policyrcd-script-zg2 (which
2135 provides the /usr/sbin/policy-rc.d interface) is installed.
2137 In policyrcd-script-zg2's configuration file named
2138 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
2139 defined as the interface for handling invoke-rc.d's startup policy.
2141 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf. By
2142 default you won't notice any differences to Debian's default
2143 behaviour, except that invoke-rc.d won't be executed if a chroot has
2144 been detected (detection: /proc is missing).
2146 If you want to disable automatical startup of newly installed packages
2147 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
2148 /etc/policy-rc.d.conf.
2150 To restore the default behaviour set EXITSTATUS back to '0' in
2151 /etc/policy-rc.d.conf.
2153 Tags: policy, init, script, invode-rc.d
2155 <a name="175"></a><hr />
2157 Install VMware-Tools for grml:
2159 First of all make sure a CD-ROM device in VMware is available.
2161 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
2165 unp /mnt/cdrom/vmware-linux-tools.tar.gz
2166 cd vmware-tools-distrib
2169 /etc/init.d/networking stop
2174 /etc/init.d/networking start
2176 In an X terminal, launch the VMware Tools running:
2180 Tags: vmware, tool, vmware-toolbox, howto
2182 <a name="176"></a><hr />
2184 Some important Postfix stuff
2192 Send all messages in the queue:
2196 Send all messages in the queue for a specific site:
2200 Delete a specific message
2201 # postsuper -d 12345678942
2203 Deletes all messages held in the queue for later delivery
2204 # postsuper -d ALL deferred
2206 Mail queues in postfix:
2208 incoming -> mail who just entered the system
2209 active -> mail to be delivered
2210 deferred -> mail to be delivered later because there were problems
2211 hold -> mail that should not be delivered until released from hold
2213 For configuration of postfix take a look at
2214 /etc/postfix/master.cf - man 5 master
2215 /etc/postfix/main.cf - man 5 postconf
2216 and http://www.postfix.org/documentation.html.
2218 <a name="177"></a><hr />
2222 mode 4000 - set user ID (suid):
2224 - for executable files: run as the user who owns the file, instead of the
2225 user who runs the file
2226 - for directories: not used
2228 mode 2000 - set group ID (guid):
2230 - for executable files: run as the group who owns the file, instead of the
2231 group of the user who runs the file
2232 - for directories: when a file is created inside the directory, it belongs
2233 to the group of the directory instead of the default group of the user who
2236 mode 1000 - sticky bit:
2238 - for files: not used
2239 - for directories: only the owner of a file can delete or rename the file
2241 Tags: postix, mailq, postsuper, queue, delete, smtp
2243 <a name="178"></a><hr />
2245 Create MySQL database
2247 # apt-get install mysql-client mysql-server
2249 Run 'mysql' as root - create a database with:
2251 create database grml
2253 Give a user access to the database (without password):
2255 grant all on grml.* to mika;
2257 Give a user access to the database (with password):
2259 grant all on grml.* to enrico identified by "PASSWORD";
2261 Tags: mysql, database
2263 <a name="179"></a><hr />
2265 Setup an HTTPS website:
2267 Create a certificate:
2269 # mkdir /etc/apache2/ssl
2270 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
2272 Create a virtual host on port 443:
2274 <VirtualHost www.foo.invalid:443>
2276 </VirtualHost>
2278 Enable SSL in the VirtualHost:
2281 SSLCertificateFile /etc/apache2/ssl/apache.pem
2283 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
2287 and make sure the SSL module is used:
2291 Tags: ssl, https, configuration, apache
2293 <a name="180"></a><hr />
2295 Useful Apache / Apache2 stuff
2297 Check configuration file via running:
2299 # apache2ctl configtest
2307 # a2enmod modulename
2309 Tags: apache, configuration
2311 <a name="181"></a><hr />
2313 Create tar archive and store it on remote machine:
2315 % tar zcf - /sourcedir | ssh user@targethost "cat >file.tgz"
2317 Tags: tar, backup, remote, network, ssh
2319 <a name="182"></a><hr />
2321 Pick out and displays images from network traffic:
2325 Tags: remote, network, sniff, image
2327 <a name="183"></a><hr />
2329 Install Flash plugin:
2331 # dpkg-reconfigure flashplugin-nonfree
2335 <a name="184"></a><hr />
2337 To test a proxy, low level way:
2341 GET http://www.google.com HTTP/1.0 [press enter twice]
2345 <a name="185"></a><hr />
2347 Adjust system for use of qemu with kqemu:
2349 Make sure you have all you need:
2350 # aptitude update ; aptitude install qemu kqemu-modules-$(uname -r)
2355 mknod /dev/kqemu c 250 0
2356 chmod 666 /dev/kqemu
2357 chmod 666 /dev/net/tun
2359 Check kqemu support via starting qemu, press
2360 Ctrl-Alt-2 and entering 'info kqemu'.
2362 <a name="186"></a><hr />
2364 (High-Load) Debugging related tools:
2366 mpstat # report processors related statistics
2367 iostat # report CPU statistics and input/output statistics for devices and partitions
2368 vmstat # report virtual memory statistics
2369 slabtop # display kernel slab cache information in real time
2370 atsar # system activity report
2371 dstat # versatile tool for generating system resource statistics
2382 Tags: test, debug, information, hardware, statistic
2384 <a name="187"></a><hr />
2386 Using WPA for network setup manually:
2388 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
2390 Adjust the options and configuration file to your needs.
2391 Also take a look at 'grml-network'.
2393 Tags: wireless, wpa, network, configuration
2395 <a name="188"></a><hr />
2397 Start X and lock console via exiting:
2399 % startx 2>~/.xsession-errors &| exit
2401 Tags: xorg, x11, startx, graphical
2403 <a name="189"></a><hr />
2405 Which process is writing to disk and/or causes the disk to spin up?
2407 First of all use lsof to check what's going on. Does not help? ->
2409 # echo 1 > /proc/sys/vm/block_dump
2411 The command sets a sysctl to cause the kernel to log all disk
2412 writes. Please notice that there is a lot of data. So please
2413 disable syslogd/syslog-ng before you do this, or you must make
2414 sure that kernel output is not logged.
2416 When you're done, disable block dump using:
2417 # echo 0 > /proc/sys/vm/block_dump
2420 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
2421 which handles block_dump on its own.
2423 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2425 Also take a look at event-viewer(8) which is part of grml-debugtools.
2427 Tags: debug, device, block, partition
2429 <a name="190"></a><hr />
2431 Install initrd via initramfs-tools for currently running kernel:
2433 # update-initramfs -c -t -k $(uname -r)
2437 <a name="191"></a><hr />
2439 Install initrd via yaird for currently running kernel:
2441 # yaird -o /boot/initrd.img-$(uname -r)
2443 Install initrd via yaird for specific kernel:
2447 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
2449 <a name="192"></a><hr />
2451 Reinstall package with its original configuration files:
2453 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o DPkg::Options::=--force-confnew package
2455 <a name="193"></a><hr />
2457 grml 0.8 funkenzutzler - rt2x00 drivers:
2459 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
2460 includes beta-version drivers) is not installed by default. If you want to
2461 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
2462 rt73usb please install the package manually running:
2464 # dpkg -i /usr/src/rt2x00-modules-*.deb
2466 <a name="194"></a><hr />
2468 Use Java with jikes and jamvm on grml:
2472 % cp /usr/share/doc/grml-templates/template.java .
2473 % jikes template.java
2476 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
2477 so you do not have to manually run
2478 jikes --bootclasspath /usr/share/classpath/glibj.zip
2480 <a name="195"></a><hr />
2482 Online resizing of (Software-)RAID5:
2484 # Initiate a RAID5 setup for testing purposes:
2485 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
2487 # Create filesystem, mount md0, create a testfile and save md5sum for
2490 mount /dev/md0 /mnt/test
2491 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
2492 md5sum /mnt/test/dd > md5sum
2494 # Make sure the RAID is synched via checking:
2497 # Now remove one partition:
2498 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
2500 # Delete partition, create a new + bigger one and set partition type to fd
2501 # (Linux raid autodetect):
2504 # And re-add the partition:
2505 mdadm -a /dev/md0 /dev/hdd1
2507 # Make sure the RAID is synched via checking:
2510 # Repeat the steps for all other disks/partitions as well:
2511 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2513 mdadm -a /dev/md0 /dev/hdb1
2515 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2517 mdadm -a /dev/md0 /dev/hda1
2520 # Now resize the RAID5 system online [see 'man mdadm' for details]:
2521 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
2522 mdadm --grow /dev/md0 -z max
2523 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
2525 # Last step - resize the filesystem (online again):
2528 Tags: raid, resize, raid5, mdadm
2530 <a name="196"></a><hr />
2532 ext3 online resizing:
2534 Starting with Linux kernel 2.6.10 you can resize ext3 online. With
2535 e2fsprogs >=1.39-1 new filesystems are created with directory indexing and
2536 on-line resizing enabled by default (see /etc/mke2fs.conf).
2540 cfdisk /dev/hda # create a partition with type 8e (lvm)
2541 pvcreate /dev/hda2 # create a physical volume
2542 vgcreate resize_me /dev/hda2 # create volume group
2543 lvcreate -n resize_me -L100 resize_me # create a logical volume
2544 mkfs.ext3 /dev/resize_me/resize_me # now create a new filesystem
2545 mount /dev/resize_me/resize_me /mnt/test # mount the new fs for demonstrating online resizing
2546 df -h # check the size of the partition
2547 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
2548 resize2fs /dev/resize_me/resize_me # and finally resize the filesystem
2549 df -h # recheck the size of the partition
2551 This also works for Software-RAID. Demo:
2553 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
2555 mount /dev/md0 /mnt/test
2556 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
2557 cfdisk /dev/hda # adjust partition size for hda2
2558 mdadm /dev/md0 --add /dev/hda2
2559 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2560 cfdisk /dev/hdb # adjust partition size for hdb1
2561 mdadm /dev/md0 --add /dev/hdb1
2562 mdadm --grow /dev/md0 --size=max
2565 Notice: online resizing works as soon as the kernel can re-read the
2566 partition table. So it works for example with LVM and SW-RAID but not with
2567 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
2568 table if the device is already mounted.
2570 Tags: resize, raid, lvm, ext2, ext3, ext4, raid1
2572 <a name="197"></a><hr />
2574 Use vim as an outline editor:
2576 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
2580 <a name="198"></a><hr />
2582 Monitor directories/files for changes using iwatch
2584 Monitor /tmp for changes:
2587 Monitor files/directories specified in /etc/iwatch.xml
2588 and send mail on changes:
2591 Tags: inotify, watch, file, directory
2593 <a name="199"></a><hr />
2595 Some often used mdadm commands:
2598 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
2600 Display details of specific RAID:
2601 # mdadm --detail /dev/md0
2604 Simulating a drive failure by software:
2605 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
2607 Remove disk from RAID:
2608 # mdadm /dev/md0 -r /dev/hda1
2610 Set disk as faulty and remove from RAID:
2611 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2616 Restart a RAID-device:
2619 Add another disk to existing RAID setup (hotadd):
2620 # mdadm /dev/md0 -a /dev/hde1
2621 # mdadm --grow /dev/md0 --raid-devices=4
2623 Assemble and start all arrays:
2624 # mdadm --assemble --scan
2626 Assemble a specific array:
2627 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
2630 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
2633 # mdadm --stop --scan
2635 Scan for and setup arrays automatically:
2636 # mdadm --assemble --scan --auto=yes --verbose
2638 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
2640 CREATE owner=root group=disk mode=0660 auto=yes
2641 HOMEHOST <system>
2645 # /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
2648 Monitoring the sw raid
2649 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
2651 Producing /etc/mdadm/mdadm.conf:
2652 # mdadm --detail --scan > /etc/mdadm/mdadm.conf
2654 See also: man mdadm | less -p "^EXAMPLES"
2655 http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
2657 Tags: raid, raid1, raid5, configuration, mdadm, howto
2659 <a name="200"></a><hr />
2661 A quick summary of the most commonly used RAID levels:
2664 => 2 disks each 160 GB: 320 GB data
2665 RAID 1: Mirrored Set
2666 => 2 disks each 160 GB: 160 GB data
2667 RAID 5: Striped Set with Parity
2668 => 3 disks each 160 GB: 320 GB data; 160 GB redundancy
2670 Common nested RAID levels:
2671 RAID 01: A mirror of stripes
2672 RAID 10: A stripe of mirrors
2673 RAID 30: A stripe across dedicated parity RAID systems
2674 RAID 100: A stripe of a stripe of mirrors
2676 -- http://en.wikipedia.org/wiki/RAID
2678 Tags: raid, raid1, raid5, raid01, raid10, raid100
2680 <a name="201"></a><hr />
2682 Logical Volume Management (LVM) with Linux
2687 | hda1 hdc1 (PV:s on partitions or whole disks)
2691 | / | | / | | usrlv rootlv varlv (LV:s)
2693 | ext3 ext3 xfs (filesystems)
2695 Often used commands:
2696 ~~~~~~~~~~~~~~~~~~~~
2698 Create a physical volume:
2699 # pvcreate /dev/hda2
2701 Create a volume group:
2702 # vgcreate testvg /dev/hda2
2704 Create a logical volume:
2705 # lvcreate -n test_lv -L100 testvg
2707 Resize a logical volume:
2708 # lvextend -L+100M /dev/resize_me/resize_me
2709 # resize2fs /dev/resize_me/resize_me # ext2/3
2710 # xfs_growfs /dev/resize_me/resize_me # xfs
2711 # resize_reiserfs -f /dev/resize_me/resize_me # reiserfs online
2712 # mount -o remount,resize /dev/resize_me/resize_me # jfs
2714 Create a snapshot of a logical volume:
2715 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2717 Deactivate a volume group:
2718 # vgchange -a n my_volume_group
2720 Actually remove a volume group:
2721 # vgremove my_volume_group
2723 Display information about physical volume:
2724 # pvdisplay /dev/hda1
2726 Remove physical volume:
2727 # vgreduce my_volume_group /dev/hda1
2729 Remove logical volume:
2730 # umount /dev/myvg/homevol
2731 # lvremove /dev/myvg/homevol
2734 http://www.tldp.org/HOWTO/LVM-HOWTO/
2736 Tags: lvm, howto, pvcreate, lvcreate
2738 <a name="202"></a><hr />
2740 How to use APT locally
2742 Sometimes you have lots of packages .deb that you would like to use APT to
2743 install so that the dependencies would be automatically solved. Solution:
2746 dpkg-scanpackages debs /dev/null | gzip > debs/Packages.gz
2747 echo " deb file:/root debs/" >> /etc/apt/sources.list
2748 dpkg-scansources debs | gzip > debs/Sources.gz
2749 echo " deb-src file:/root debs/" >> /etc/apt/sources.list
2751 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2755 <a name="203"></a><hr />
2757 Check filesystem's LABEL:
2762 ext2/3 without blkid:
2763 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2766 # xfs_admin -l /dev/sda1
2768 reiserfs without blkid:
2769 # debugreiserfs /dev/sda1 | grep -i label
2772 # jfs_tune -l /dev/sda1 | grep -i label
2774 reiser4 without blkid:
2775 # debugfs.reiser4 /dev/sda1 | grep -i label
2777 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, label
2779 <a name="204"></a><hr />
2781 Check filesystem's UUID:
2786 ext2/3 without blkid:
2787 # dumpe2fs /dev/sda1 | grep -i UUID
2790 # xfs_admin -u /dev/sda1
2792 reiserfs without blkid:
2793 # debugreiserfs /dev/sda1 | grep -i UUID
2795 reiser4 without blkid:
2796 # debugfs.reiser4 /dev/sda1 | grep -i UUID
2798 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, uuid
2800 <a name="205"></a><hr />
2802 Change a filesystem's LABEL:
2805 # mkswap -L $LABEL /dev/sda1
2808 # e2label /dev/sda1 $LABEL
2809 # tune2fs -L $LABEL /dev/sda1
2812 # reiserfstune -l $LABEL /dev/sda1
2815 # jfs_tune -L $LABEL /dev/sda1
2818 # xfs_admin -L $LABEL /dev/sda1
2821 # echo 'drive i: file="/dev/sda1"' >> ~/.mtoolsrc
2822 # mlabel -s i:$LABEL
2825 # ntfslabel $LABEL /dev/sda1
2827 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs
2829 <a name="206"></a><hr />
2831 Disable pdiffs feature of APT:
2834 # echo 'Acquire::PDiffs "false";' >> /etc/apt/apt.conf
2837 # apt-get update -o Acquire::Pdiffs=false
2839 <a name="207"></a><hr />
2841 Backup big devices or files and create compressed splitted
2842 image chunks of it using zsplit
2844 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2845 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2846 read/write buffer to 256kB:
2847 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2849 Restore the backup using unzsplit:
2850 # unzsplit -D /dev/sda -d archiveofsda
2852 More usage examples: man zsplit + man unzsplit
2854 Tags: backup, reocvery, spllt, limit, howto
2856 <a name="208"></a><hr />
2858 Measure network performance using iperf:
2864 % iperf -c <server_address> -V
2868 Server with 128k TCP window size:
2871 Client with running for 60 seconds and bidirectional test:
2872 % iperf -c <server_address> -r -w128k -t60
2874 Tags: network, benchmark
2876 <a name="209"></a><hr />
2878 Framebuffer resolutions:
2880 Resolution in pixels
2881 Color depth | 640x480 800x600 1024x768 1280x1024
2882 256 (8bit)| 769 771 773 775
2883 32000 (15bit)| 784 787 790 793
2884 65000 (16bit)| 785 788 791 794
2885 16.7 Mill.(24bit)| 786 789 792 795
2889 Mode 0x0300: 640x400 (+640), 8 bits
2890 Mode 0x0301: 640x480 (+640), 8 bits
2891 Mode 0x0303: 800x600 (+800), 8 bits
2892 Mode 0x0303: 800x600 (+832), 8 bits
2893 Mode 0x0305: 1024x768 (+1024), 8 bits
2894 Mode 0x0307: 1280x1024 (+1280), 8 bits
2895 Mode 0x030e: 320x200 (+640), 16 bits
2896 Mode 0x030f: 320x200 (+1280), 24 bits
2897 Mode 0x0311: 640x480 (+1280), 16 bits
2898 Mode 0x0312: 640x480 (+2560), 24 bits
2899 Mode 0x0314: 800x600 (+1600), 16 bits
2900 Mode 0x0315: 800x600 (+3200), 24 bits
2901 Mode 0x0317: 1024x768 (+2048), 16 bits
2902 Mode 0x0318: 1024x768 (+4096), 24 bits
2903 Mode 0x031a: 1280x1024 (+2560), 16 bits
2904 Mode 0x031b: 1280x1024 (+5120), 24 bits
2905 Mode 0x0330: 320x200 (+320), 8 bits
2906 Mode 0x0331: 320x400 (+320), 8 bits
2907 Mode 0x0332: 320x400 (+640), 16 bits
2908 Mode 0x0333: 320x400 (+1280), 24 bits
2909 Mode 0x0334: 320x240 (+320), 8 bits
2910 Mode 0x0335: 320x240 (+640), 16 bits
2911 Mode 0x0336: 320x240 (+1280), 24 bits
2912 Mode 0x033c: 1400x1050 (+1408), 8 bits
2913 Mode 0x033d: 640x400 (+1280), 16 bits
2914 Mode 0x033e: 640x400 (+2560), 24 bits
2915 Mode 0x0345: 1600x1200 (+1600), 8 bits
2916 Mode 0x0346: 1600x1200 (+3200), 16 bits
2917 Mode 0x034d: 1400x1050 (+2816), 16 bits
2918 Mode 0x035c: 1400x1050 (+5632), 24 bits
2920 Tags: framebuffer, resolution
2922 <a name="210"></a><hr />
2924 Portscan using netcat:
2926 # netcat -v -w2 <host|ip-addr.> 1-1024
2928 <a name="211"></a><hr />
2930 Run apt-get but disable apt-listchanges:
2932 APT_LISTCHANGES_FRONTEND=none apt-get ...
2934 Upgrade system but disable apt-listbugs:
2936 APT_LISTBUGS_FRONTEND=none apt-get ...
2938 <a name="212"></a><hr />
2940 Set up a Transparent Debian Proxy
2942 Install of apt-cacher, the default config will do:
2943 # apt-get install apt-cacher
2945 Check out the ip address of debian mirror(s).
2946 Then add this to your firewall script:
2948 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2949 for ip in ${DEBIAN_MIRRORS} ; do
2950 ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2953 where ${IPTABLES} is the location of your iptables binary
2954 and $subnet is your internal subnet.
2956 Now everybody in your subnet who does access either
2957 ftp.de.debian.org or ftp.at.debian.org will actually
2958 access your apt-cacher instead.
2960 To use apt-cacher on the router itself, add the following
2961 line to your /etc/apt/apt.conf:
2963 Acquire::http::Proxy "http://localhost:3142/";
2965 Tags: proxy, debian, apt-get, howto
2967 <a name="213"></a><hr />
2969 Version control using Mercurial
2971 Setting up a Mercurial project:
2974 % hg init # creates .hg
2975 % hg add # add all files
2976 % hg commit # commit all changes, edit changelog entry
2978 Branching and merging:
2980 % hg clone linux linux-work # create a new branch
2982 <make changes>
2985 % hg pull ../linux-work # pull changesets from linux-work
2986 % hg merge # merge the new tip from linux-work into
2987 # (old versions used "hg update -m" instead)
2988 # our working directory
2989 % hg commit # commit the result of the merge
2993 % cat ../p/patchlist | xargs hg import -p1 -b ../p
3001 % hg export 1234 > foo.patch # export changeset 1234
3003 Export your current repo via HTTP with browsable interface:
3005 % hg serve -n "My repo" -p 80
3007 Pushing changes to a remote repo with SSH:
3009 % hg push ssh://user@example.com/~/hg/
3011 Merge changes from a remote machine:
3013 host1% hg pull http://foo/
3014 host2% hg merge # merge changes into your working directory
3016 Set up a CGI server on your webserver:
3017 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
3018 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
3020 <a name="214"></a><hr />
3022 Download binary codecs for mplayer:
3024 # /usr/share/mplayer/scripts/win32codecs.sh
3028 # /usr/share/mplayer/scripts/binary_codecs.sh install
3030 (depending on the mplayer version you have).
3032 To play encrypted DVDs and if you are living in a country where using
3033 libdvdcss code is not illegal can install Debian package libdvdread3
3034 and use the script /usr/share/doc/libdvdread3/install-css.sh.
3036 <a name="215"></a><hr />
3038 Read manpages of uninstalled packages with debman:
3040 % debman -p git-core git
3042 <a name="216"></a><hr />
3044 Test network performance using netperf:
3050 # netperf -t TCP_STREAM -H 192.168.0.41
3052 Tags: benchmark, network
3054 <a name="217"></a><hr />
3056 Setup Xen within 20 minutes on Debian/grml
3058 Install relevant software und update grub's menu.lst (Xen does not work with
3059 usual lilo so install grub instead if not done already):
3061 apt-get install linux-image-2.6.18-1-xen-686 xen-hypervisor-3.0.3-1-i386 xen-utils-3.0.3-1 xen-tools bridge-utils
3064 Example for installation of Debian etch as DomU:
3067 xen-create-image --debootstrap --dir=/mnt/md1/xen --size=2Gb --memory=512Mb --fs=ext3 --cache=yes --dist=etch --hostname=xengrml1 --ip 192.168.1.2 --netmask 255.255.255.0 --gateway 192.168.1.1 --initrd=/boot/initrd.img-2.6.18-1-xen-686 --kernel=/boot/vmlinuz-2.6.18-1-xen-686 --mirror=http://ftp.at.debian.org/debian/
3071 /etc/init.d/xend start
3072 /etc/init.d/xendomains start
3074 Setup a bridge for network, either manually:
3076 brctl addbr xenintbr
3077 brctl stp xenintbr off
3078 brctl sethello xenintbr 0
3079 brctl setfd xenintbr 0
3080 ifconfig xenintbr 192.168.1.1 netmask 255.255.255.0 up
3082 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
3086 iface xenintbr inet static
3087 pre-up brctl addbr xenintbr
3088 post-down brctl delbr xenintbr
3090 netmask 255.255.255.0
3095 Setup forwarding (adjust $PUBLIC_IP; for permanet setup use /etc/sysctl.conf and
3096 add the iptables commands to a startup script like /etc/init.d/rc.local):
3098 echo 1 > /proc/sys/net/ipv4/ip_forward
3099 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to $PUBLIC_IP
3100 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $PUBLIC_IP
3102 Adjust network configuration of Xend:
3104 cat >> /etc/xen/xend-config.sxp << EOF
3105 (network-script network-route)
3106 (vif-bridge xenintbr)
3107 (vif-script vif-bridge)
3110 List domains, start up a DomU, shutdown later again:
3112 xm create -c /etc/xen/xengrml1.cfg
3116 This HowTo is also available online at http://grml.org/xen/
3118 Tags: howto, xen, grml
3120 <a name="218"></a><hr />
3122 Play tetris with zsh:
3126 bindkey "^Xt" tetris
3128 Now press 'ctrl-x t'.
3130 <a name="219"></a><hr />
3132 Set up a router with grml
3134 Run grml-router script:
3137 Install dnsmasq if not already present:
3138 # apt-get update ; apt-get install dnsmasq
3140 Adjust /etc/dnsmasq.conf according to your needs:
3141 # cat >> /etc/dnsmasq.conf << EOF
3144 dhcp-range=19.168.0.124,192.168.0.254,1m # dhcp range
3145 dhcp-option=3,192.168.0.1 # dns server
3146 dhcp-option=1,255.255.255.0 # netmask
3149 Start dnsmasq finally:
3152 Tags: network, router, grml
3154 <a name="220"></a><hr />
3156 Display stats about memory allocations performed by a program:
3158 Usage example for 'ls':
3160 % LD_PRELOAD=/lib/libmemusage.so ls > /dev/null
3162 <a name="221"></a><hr />
3164 Use KVM (Kernel-based Virtual Machine for Linux):
3166 Make sure to install the relevant tools:
3167 # apt-get update ; apt-get install kvm
3170 Test it with a minimal system like ttylinux:
3171 # wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz
3172 # gzip -d bootcd-i386-5.3.iso.gz
3173 # kvm -cdrom bootcd-i386-5.3.iso
3175 <a name="222"></a><hr />
3177 EEPROM data decoding for SDRAM DIMM modules:
3180 # /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl
3182 <a name="223"></a><hr />
3186 Make sure your device is supported by Linux and running.
3187 See http://www.linuxtv.org/ for more details.
3189 If the DVB device works on your system (see 'hwinfo --usb'
3190 when using a DVB usb device for example), then make sure you
3191 have the scan util from dvb-utils available:
3193 # aptitude install dvb-utils
3195 Then create a channels.conf configuration file:
3197 % scan /usr/share/doc/dvb-utils/examples/scan/... > ~/.mplayer/channels.conf
3199 You can find some example configuration files on
3200 your grml system in ~/.channels. Usage example:
3202 % ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf
3204 Tip: w_scan (see http://free.pages.at/wirbel4vdr/w_scan/index2.html)
3205 might be useful if you do not know the initial configuration
3208 <a name="224"></a><hr />
3210 Get the lastest mercurial snapshot:
3212 Make sure you have the python-dev package available:
3213 # apt-get update ; apt-get install python-dev
3215 Get and build the source:
3216 % hg clone http://selenic.com/repo/hg mercurial
3219 % export PYTHONPATH=$(pwd)
3220 % export PATH=$PATH:$(pwd)
3222 now you should have the newest version of mercurial whenever you execute hg.
3224 To update to the lastest development snapshot, additionally use
3225 the following commands:
3226 % hg pull -u http://hg.intevation.org/mercurial/crew
3229 <a name="225"></a><hr />
3234 Available bootoptions relevant in live-cd mode:
3235 -----------------------------------------------
3237 * utc: set UTC, if your system clock is set to UTC (GMT)
3238 * gmt: set UTC, if your system clock is set to UTC (GMT) [like bootoption utc]
3239 * tz=$option: set timezone to corresponding $option, usage example:
3242 Configuration options relevant on harddisk installation:
3243 --------------------------------------------------------
3245 * Use the tzconfig utility to set the local timezone:
3249 which adjusts /etc/timezone and /etc/localtime according
3250 to the provided information. Running:
3252 # dpkg-reconfigure tzdata
3254 might be useful as well.
3256 * /etc/default/rcS: set variable UTC according to your needs,
3257 whether your system clock is set to UTC (UTC='yes') or
3260 * /etc/localtime: adjust zoneinfo according to your needs:
3262 # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime
3264 The zoneinfo directory contains the time zone files that were
3265 compiled by zic. The files contain information such as rules
3266 about DST. They allow the kernel to convert UTC UNIX time into
3267 appropriate local dates and times. Use the zdump utility to
3268 print current time and date (in the specified time zone).
3270 * /etc/adjtime: This file is used e.g. by the adjtimex function,
3271 which can smoothly adjust system time while the system runs
3273 * If you change the time (using 'date --set ...', ntpdate,...)
3274 it is worth setting also the hardware clock to the correct time:
3276 # hwclock --systohc [--utc]
3278 Remember to add the --utc -option if the hardware clock is set
3284 Check your current settings via:
3287 zdump /etc/localtime
3290 grep hwclock /etc/runlevel.conf
3291 grep '^UTC' /etc/default/rc
3293 Further information:
3294 --------------------
3296 hwclock(8) tzselect(1) tzconfig(8)
3297 http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html
3298 http://wiki.debian.org/TimeZoneChanges
3300 Tags: timezone, rtc, configuration
3302 <a name="226"></a><hr />
3304 Recorder shellscript session using script:
3306 % script -t 2>~/upgrade.time -a ~/upgrade.script
3307 % scriptreplay ~/upgrade.time ~/upgrade.script
3309 <a name="227"></a><hr />
3311 Test UTF-8 capabilities of terminal:
3313 wget http://www.linux-cjk.net/Console/garabik/UTF-8-demo.txt.gz
3314 zcat UTF-8-demo.txt.gz
3318 wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
3321 <a name="228"></a><hr />
3323 UTF-8 at grml / some general information regarding Unicde/UTF-8:
3325 http://wiki.grml.org/doku.php?id=utf8
3327 <a name="229"></a><hr />
3330 This allows one ssh connection attepmt per minute per source ip, with a initial
3331 burst of 10. The available burst is like a counter which is initialised with
3332 10. Every connection attempt decrements the counter, and every minute where the
3333 connection limit of one per minute is not overstepped the counter is
3334 incremented by one. If the burst counter is exhausted the real rate limit
3335 comes into play. This gives you 11 connectionattepmts in the first minute
3336 before blocked for 10minutes. After 10 minutes block the game restarts.
3338 Hint: you could set the burst value to 5 and the block time to only 5 minutes
3339 to achive the same average connection rate but with halve the block time.
3341 iptables -A inet_in -p tcp --syn --dport 22 -m hashlimit --hashlimit-name ssh --hashlimit 1/minute --hashlimit-burst 10 --hashlimit-mode srcip --hashlimit-htable-expire 600000 -j ACCEPT
3342 iptables -A inet_in -p tcp --dport 22 -m state --state NEW -j REJECT
3344 <a name="230"></a><hr />
3346 Tunnel a specific connection via socat:
3349 % socat TCP4-LISTEN:8003 TCP4:gateway:500
3352 # socat TCP4-LISTEN:500,fork TCP4:target:$PORT
3354 Using localhost:8003 on the client uses the tunnel now.
3356 <a name="231"></a><hr />
3360 # date --set=060916102007
3362 where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4)
3364 Set date using a relative date:
3370 # date -s '+tomorrow'
3372 Display a specific relative date:
3374 # date -d '+5 days -2 hours'
3376 Don't forget to set hardware clock via:
3380 <a name="232"></a><hr />
3382 Booting grml via network / PXE:
3384 Start grml-terminalserver on a system with network access
3385 and where grml is running:
3387 # grml-terminalserver
3389 Then booting your client(s) via PXE should work without
3392 See: man grml-terminalserver + http://grml.org/terminalserver/
3394 Tags: howto, pxe, network, boot
3396 <a name="233"></a><hr />
3398 Debugging SSL communications:
3400 % openssl s_client -connect server.adress:993 > output_file
3401 % openssl x509 -noout -text -in output_file
3405 # ssldump -a -A -H -i eth0
3407 See http://prefetch.net/articles/debuggingssl.html for more details.
3409 Tags: debug, ssl, openssl
3411 <a name="234"></a><hr />
3413 Remove bootmanager from MBR:
3415 # lilo -M /dev/hda -s /dev/null
3419 <a name="235"></a><hr />
3421 Rewrite grub to MBR:
3424 # grub-install --recheck --no-floppy --root-directory=/mnt/sda1 /dev/sda
3428 <a name="236"></a><hr />
3430 Rewrite lilo to MBR:
3437 <a name="237"></a><hr />
3439 Create screenshot of plain/real console - tty1:
3441 # fbgrab -c 1 screeni.png
3443 <a name="238"></a><hr />
3445 Create screenshot when running X:
3449 Tip: use the gkrellshoot plugin when using gkrellm
3451 Tags: screenshot, xorg
3453 <a name="239"></a><hr />
3455 Redirect all connections to hostA:portA to hostB:portB, where hostA and hostB are
3458 Run the following commands on hostA:
3460 echo 1 > /proc/sys/net/ipv4/ip_forward
3461 iptables -t nat -A PREROUTING -p tcp --dport portA -j DNAT --to hostB:portB
3462 iptables -A FORWARD -i eth0 -o eth0 -d hostB -p tcp --dport portB -j ACCEPT
3463 iptables -A FORWARD -i eth0 -o eth0 -s hostB -p tcp --sport portB -j ACCEPT
3464 iptables -t nat -A POSTROUTING -p tcp -d hostB --dport portB -j SNAT --to-source hostA
3466 Tags: howto, network, redirect, port
3468 <a name="240"></a><hr />
3470 Flash BIOS without DOS/Windows:
3472 Dump flash info and set the flash chip to writable:
3475 Backup the original BIOS:
3476 # flashrom -r backup.bin
3478 Notice: the following step will overwrite your current BIOS!
3479 So make sure you really know what you are doing.
3481 Flash the BIOS image:
3482 # flashrom -wv newbios.bin
3484 Also check out LinuxBIOS: http://linuxbios.org/
3486 <a name="241"></a><hr />
3488 Enable shadow passwords:
3492 <a name="242"></a><hr />
3494 Set up an IPv6 tunnel on grml:
3498 <a name="243"></a><hr />
3500 Set up console newsreader slrn for use with Usenet:
3504 <a name="244"></a><hr />
3506 Calculate with IPv6 addresses:
3510 For usage examples refer to manpage ipv6calc(8).
3514 <a name="245"></a><hr />
3516 Common network debugging tools for use with IPv6:
3527 <a name="246"></a><hr />
3529 Set up NFS (Network File System):
3533 Make sure the relevant services are running on the server side:
3535 # /etc/init.d/portmap start
3536 # /etc/init.d/nfs-common start
3537 # /etc/init.d/nfs-kernel-server start
3539 Export shares via /etc/exports:
3541 /backups 192.168.1.100/24(rw,wdelay,no_root_squash,async,subtree_check)
3543 ... or manually export a directory running:
3545 # exportfs -o rw,wdelay,no_root_squash,async,subtree_check 192.168.1.100:/backups
3547 and unexport a share running:
3549 # exportfs -u 192.168.1.100:/backups
3551 and every time when you modify /etc/exports file run
3555 Display what NFS components are running:
3559 Display list of exported shares:
3567 Make sure the relevant services are running on the client side:
3569 # /etc/init.d/portmap start
3570 # /etc/init.d/nfs-common start
3572 Verify that the server allows you to access its RPC/NFS services:
3574 # rpcinfo -p server_name
3576 Check what directories the server exports:
3578 # showmount -e server_name
3580 On the client side you can use something like the following in /etc/fstab:
3582 192.168.1.101:/backups /mnt/nfs nfs defaults,users,wsize=8192,rsize=8192 0 0
3584 Tags: nfs, howto, network
3586 <a name="247"></a><hr />
3590 # aptitude install cloop-src
3593 # modprobe cloop file=/path/to/cloop/file
3594 # mount -r -t iso9660 /dev/cloop /mnt/test
3596 <a name="248"></a><hr />
3598 Create a PS/PDF of a plaintext file:
3600 % a2ps --medium A4dj -E -o output.ps input_file
3603 <a name="249"></a><hr />
3605 Print two pages on one in a PDF file:
3607 % pdfnup --nup 2x1 input.pdf
3609 Concatenate, extract pages/parts, encrypt/decrypt,
3610 compress PDFs using 'pdftk'.
3612 <a name="250"></a><hr />
3614 Read a PS/PDF file on console:
3618 or on plain framebuffer console in graphical mode:
3620 % pdf2ps file.pdf ; ps2png file.ps file.png ; fbi file.png
3626 <a name="251"></a><hr />
3628 Bypass the password of a PDF file:
3630 % gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c quit
3632 <a name="252"></a><hr />
3638 This will record a AIFF audio file.
3640 <a name="253"></a><hr />
3642 Change passphrase / password of an existing SSH key:
3646 <a name="254"></a><hr />
3648 Enable syntax highlighting in nano:
3650 Just uncomment the include directives for your respective
3651 language at the bottom of the file /etc/nanorc
3653 <a name="255"></a><hr />
3655 Create netboot package for grml-terminalserver:
3657 # bash /usr/share/doc/grml-terminalserver/examples/create-netboot
3659 <a name="256"></a><hr />
3661 To boot grml via network (PXE) check out grml-terminalserver:
3663 # grml-terminalserver
3665 See http://grml.org/terminalserver/ for more details.
3667 <a name="257"></a><hr />
3671 Using the 'Orientation' tag of the Exif header, rotate
3672 the image so that it is upright:
3673 % jhead -autorot *.jpg
3675 Manually rotate a picture:
3676 % convert -rotate 270 input.jpg output.jpg
3678 <a name="258"></a><hr />
3680 Rename files based on the information inside their exif header:
3682 % jhead -n%Y-%m-%d_%Hh%M_%f *.jpg
3684 This will rename a file named img_2071.jpg to something like:
3686 2007-08-17_10h38_img_2071.jpg
3688 if it was shot at 10:38 o'clock on 2007-08-17 (according to
3689 the information inside the exif header).
3691 <a name="259"></a><hr />
3693 Calculate network / netmask:
3696 % ipcalc 10.0.0.28 255.255.255.0
3697 % ipcalc 10.0.0.0/24
3699 <a name="260"></a><hr />
3701 Blacklist a kernel module:
3703 # blacklist <name_of_kernel_module>
3705 -> running 'blacklist hostap_cs' for example will generate an
3706 entry like this in /etc/modprobe.d/grml:
3711 To remove the module from the blacklist again just invoke:
3713 # unblacklist <name_of_kernel_module>
3715 or manually remove the entry from /etc/modprobe.d/grml.
3717 <a name="261"></a><hr />
3719 Create a Debian package of a perl module:
3721 % dh-make-perl --cpan Acme::Smirch --build
3723 <a name="262"></a><hr />
3725 The Magic SysRq Keys (SysReq or Sys Req, short for System Request):
3727 To reboot your system using the SysRq keys just hold down the Alt and
3728 SysRq (Print Screen) key while pressing the keys REISUB ("Raising
3729 Elephants Is So Utterly Boring").
3731 R = take the keyboard out of raw mode
3732 E = terminates all processes (except init)
3733 I = kills all processes (except init)
3734 S = synchronizes the disk(s)
3735 U = remounts all filesystems read-only
3736 B = reboot the system
3738 Notice: use O instead of B for poweroff.
3740 Or write the sequence to /proc/sysrq-trigger instead:
3742 # for i in r e i s u b ; do echo $i > /proc/sysrq-trigger ; done
3744 To enable or disable SysRq calls:
3746 # echo 0 > /proc/sys/kernel/sysrq
3747 # echo 1 > /proc/sys/kernel/sysrq
3749 See http://en.wikipedia.org/wiki/Magic_SysRq_key for more details.
3751 Tags: reboot, documentation, sysrq, magic
3753 <a name="263"></a><hr />
3757 Just boot your grml Live-CD with "memtest" to execute a memcheck/memtest
3760 <a name="264"></a><hr />
3762 Tunnel TCP-Traffic through DNS using dns2tcp:
3766 1. Create necessary DNS-Records:
3767 dnstun.example.com. 3600 IN NS host.example.com.
3768 dnstun.example.com. 3600 IN A 192.168.1.1
3769 host.example.com. 3600 IN A 192.168.1.1
3771 2. Configure dns2tcpd on host.example.com.:
3772 # cat /etc/dns2tcpd.conf
3773 listen = 192.168.1.1 #the ip dns2tcpd should listen on
3774 port = 53 #" port " " " "
3777 domain = dnstun.example.com. # the zone as specified inside dns
3778 ressources = ssh:127.0.0.1:22 # available resources
3780 3. Start the daemon:
3781 # cat > /etc/default/dns2tcp << EOF
3782 # Set ENABLED to 1 if you want the init script to start dns2tcpd.
3786 # /etc/init.d/dns2tcp start
3790 You have two possibilities:
3791 - Use the DNS inside your network (DNS must allow resolving for external domains)
3792 # grep nameserver /etc/resolv.conf
3793 nameserver 172.16.42.1
3794 # dns2tcpc -z dnstun.example.com 172.16.42.1
3795 Available connection(s) :
3797 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com 172.16.42.1 &
3798 Listening on port : 2222
3799 # ssh localhost -p 2222
3800 user@host.example.com:~#
3802 - Directly contact the endpoint (port 53 UDP must be allowed outgoing)
3803 # dns2tcpc -z dnstun.example.com dnstun.example.com
3804 Available connection(s) :
3806 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com dnstun.example.com &
3807 Listenning on port : 2222
3808 # ssh localhost -p 2222
3809 user@host.example.com:~#
3811 Notice: using 'ssh -D 8080 ..' you will get a socks5-proxy listening on
3812 localhost:8080 which you can use to tunnel everything through your "dns-uplink".
3814 Tags: howto, network, tunnel
3816 <a name="265"></a><hr />
3818 Configure a MadWifi device for adhoc mode:
3820 Disable the autocreation of athX devices:
3821 # echo "options ath_pci autocreate=none" > /etc/modprobe.d/madwifi
3823 Remove the autocreated device for now:
3824 # wlanconfig ath0 destroy
3826 Configuration in /etc/network/interfaces:
3828 iface ath0 inet static
3834 - Do not use interface names without ending 0 (otherwise startup fails).
3835 - Only chooss unique names for interfaces.
3837 <a name="266"></a><hr />
3839 Find dangling symlinks using zsh:
3843 <a name="267"></a><hr />
3845 Use approx with runit supervision
3846 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3848 Install the packages:
3849 # apt-get install approx runit
3851 Add user approxlog for the logging daemon:
3852 # adduser --system --home /nonexistent --no-create-home approxlog
3854 Create config directory:
3855 # mkdir /etc/sv/approx
3857 Use /var/run/sv.approx as supervise directory:
3858 # ln -s /var/run/sv.approx /etc/sv/approx/supervise
3860 # cat > /etc/sv/approx/run << EOF
3862 echo 'approx starting'
3863 exec approx -f 2>&1
3866 You normally do not need a logging service for approx because it logs
3867 to syslog too. So just for completion:
3868 # mkdir -p /etc/sv/approx/log
3869 # ln -s /var/run/sv.approx.log /etc/sv/approx/log/supervise
3870 # cat > /etc/sv/approx/log/run << EOF
3873 LOG="/var/log/approx"
3874 test -d "$LOG" || mkdir -p -m2750 "$LOG" && chown approxlog:adm "$LOG"
3875 exec chpst -uapproxlog svlogd -tt -v "$LOG"
3878 Now activate the new approx service (will be started within 5s):
3879 # ln -s /etc/sv/approx/ /var/service/
3881 Make approx managed via runit available via init-script interface:
3882 # dpkg-divert --local --rename /etc/init.d/approx
3883 # ln -s /usr/bin/sv /etc/init.d/approx
3885 <a name="268"></a><hr />
3887 Remote-reboot a grml system using SysRQ via /proc (execute as root):
3889 eject &>/dev/null
3892 echo b > /proc/sysrq-trigger
3894 Tags: reboot, howto, grml, network
3896 <a name="269"></a><hr />
3898 Show what happens on /dev/sda0:
3900 # mount the debugfs to relay kernel info to userspace
3901 mount -t debugfs none /sys/kernel/debug
3903 # is a convenient wrapper arround blktrace and blkparse
3906 Tags: debug, block, partition, trace
3908 <a name="270"></a><hr />
3910 Convert Flash to Avi:
3912 % ffmpeg -i input.flv output.avi
3914 Extract MP3 from Flash file:
3916 % for i in *.flv; do ffmpeg -i $i -acodec copy ${i%.flv}.mp3 ; done
3918 <a name="271"></a><hr />
3920 Usage example for cryptsetup / -luks encrypted partition on LVM:
3922 volume group name: x61
3923 logical volume name: home
3925 echo "grml-crypt_home /dev/mapper/x61-home none luks" >> /etc/crypttab
3927 mount /dev/mapper/grml-crypt_home /mnt/test
3929 <a name="272"></a><hr />
3931 fdisk/parted/... complains with something like
3932 'unable to open /dev/sda - unrecognised disk label'?!
3934 See http://grml.org/faq/#fdisk =>
3936 * use /sbin/fdisk.distrib from util-linux
3937 * switch to sfdisk, cfdisk,...
3938 * use parted's mklabel command (but please read the
3939 parted manual before executing this command)
3941 <a name="273"></a><hr />
3943 dmraid - support for SW-RAID / FakeRAID controllers
3944 like Highpoint HPT and Promise FastTrack
3946 Activate all software RAID sets discovered:
3949 Deactivates all active software RAID sets:
3952 Discover all software RAID devices supported on the system:
3955 <a name="274"></a><hr />
3957 Extract winmail.dat:
3962 Extract files to current directory:
3963 % ytnef -f . winmail.dat
3965 <a name="275"></a><hr />
3967 Approx - Debian package proxy/cacher howto
3969 % apt-get install approx
3970 % echo 'debian http://ftp.de.debian.org/debian' >>/etc/approx/approx.conf
3973 Add your new approx to sources.list
3976 deb http://localhost:9999/debian unstable main contrib non-free
3978 use approx in grml-debootstrap like:
3979 % grml-debootstrap -r lenny -t /dev/sda1 -m http://127.0.0.1:9999/debian
3981 <a name="276"></a><hr />
3983 Simple webserver with python:
3985 % python -m SimpleHTTPServer
3987 <a name="277"></a><hr />
3989 Upgrade only packages from the grml-stable Debian repository:
3991 echo 'deb http://deb.grml.org/ grml-stable main' > /etc/apt/grml-stable.list
3992 apt-get -o Dir::Etc::sourcelist=/etc/apt/grml-stable.list -o Dir::Etc::sourceparts=/doesnotexist update
3995 <a name="278"></a><hr />
3997 Install Centos into a directory:
3999 % febootstrap centos-5 directory http://mirror.centos.org/centos-5/5.3/os/i386/
4001 <a name="279"></a><hr />
4003 Install Fedora into a directory:
4005 % febootstrap fedora-11 target_directory
4007 <a name="280"></a><hr />
4009 Use Nessus / OpenVAS (remote network security auditor):
4011 Install software packages:
4013 # apt-get install openvas-client openvas-server openvas-plugins-base openvas-plugins-dfsg
4018 Start openvas server (takes a while):
4019 # Start openvas-server
4021 Invoke client as user:
4024 <a name="281"></a><hr />
4026 Find packages not available from any active apt repository:
4028 % apt-show-versions | awk '/No available version in archive/{print $1}'
4030 <a name="282"></a><hr />
4032 Simple mailserver with python:
4034 % python -m smtpd -n -c DebuggingServer localhost:1025
4036 <a name="283"></a><hr />
4040 echo $USER | nc $HOST 79
4042 <a name="284"></a><hr />
4044 Install Archlinux using Grml:
4046 https://wiki.archlinux.org/index.php/Install_from_Existing_Linux
4048 wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh
4050 <a name="285"></a><hr />
4052 Export blockdevices via AoE (ATA over Ethernet):
4054 % vblade -m 11:22:33:44:55:66 160 2 eth0 /dev/sdb1
4056 Allow the host with the mac address 11:22:33:44:55:66 to access /dev/sdb1
4057 via eth0, using the shelf and slot numbers 160 and 2. These numbers are
4058 arbitrary but should be unique within the network.
4060 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4061 especially arp spoofing. Do not use in hostile networks.
4063 Tags: aoe, blockdevice, export, server
4065 <a name="286"></a><hr />
4067 Access blockdevices via AoE (ATA over Ethernet):
4071 and the device should show up under /dev/etherd/. If your shelf and
4072 slot numbers re 160 and 2 the device will be /dev/etherd/e160.2
4074 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4075 especially arp spoofing. Do not use in hostile networks.
4077 Tags: aoe, blockdevice, export, client
4079 <a name="287"></a><hr />