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="fdse-index-as" content="http://www.grml.org/tips/" />
10 <meta name="Robots" content="index,follow" />
11 <meta name="Language" content="english" />
12 <meta name="identifier-url" content="http://www.grml.org/" />
13 <meta name="MSSmartTagsPreventParsing" content="true" />
14 <meta http-equiv="imagetoolbar" content="no" />
15 <link rel="home" href="/" title="grml.org" />
16 <link rel="help" href="/features/" title="About" />
17 <link rel="author" href="/team/" title="Team" />
18 <link rel="icon" href="/favicon.png" type="image/png" />
19 <link rel="stylesheet" href="/style.css" type="text/css" />
25 Install grml to harddisk:
29 Notice: You can pre-select the partition for the partition selector
30 and mbr dialogs inside grml2hd using:
31 # grml2hd /dev/hda1 -mbr /dev/hda
33 See: man grml2hd + http://grml.org/grml2hd/
35 <a name="1"></a><hr />
37 Install grml on software RAID level 1:
39 Create /dev/md0 (and some more /dev/md* devices) first of all:
40 # cd /dev && MAKEDEV dev
43 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdc1
45 Finally install grml on it:
46 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
48 See: man grml2hd + http://grml.org/grml2hd/
50 <a name="2"></a><hr />
52 Install grml in non interactive mode with grml2hd:
54 Adjust configuration as needed:
55 # vim /etc/grml2hd/config
59 # GRML2HD_NONINTERACTIVE=yes grml2hd
65 Use with care and only if you really know what you are doing!
67 See: man grml2hd + http://grml.org/grml2hd/
69 <a name="3"></a><hr />
75 <a name="4"></a><hr />
77 Deactivate error correction of zsh:
81 Run zsh-help for more information regarding zsh.
83 <a name="5"></a><hr />
85 Disable automatic setting of title in GNU screen:
89 Set it manually e.g. via:
91 % screen -X title foobar
93 Run zsh-help for more information regarding zsh.
95 <a name="6"></a><hr />
97 Do not use menu completion in zsh:
101 Run zsh-help for more information regarding zsh.
103 <a name="7"></a><hr />
105 Run GNU screen with grml-configuration:
111 % screen -c /etc/grml/screenrc
113 <a name="8"></a><hr />
115 Print out grml-version:
119 <a name="9"></a><hr />
125 <a name="10"></a><hr />
127 Configure mutt-ng / muttng:
131 <a name="11"></a><hr />
133 Set up Inode-PPTP connection:
137 # grml-pptp-xdsl-students
139 <a name="12"></a><hr />
141 Set up VPN / WLAN connection at TUG (TU Graz):
143 Set ESSID and request for ip-address via DHCP:
144 # iwconfig $DEVICE essid tug
147 Now run the main script:
150 After running the script an init script is available:
152 # /etc/init.d/vpnctug [start|stop]
154 <a name="13"></a><hr />
156 Set up PPTP connection at VCG (Virtual Campus Graz):
160 <a name="14"></a><hr />
164 # grml-vpn <options>
168 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
172 <a name="15"></a><hr />
174 Use encrypted files / partitions:
176 # grml-crypt <options>
182 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
183 # cp big_file /mnt/test
184 # grml-crypt stop /mnt/test
188 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
189 # grml-crypt stop /mnt/test
193 <a name="16"></a><hr />
195 Change resolution of X:
197 % xrandr -s '1024x768'
199 <a name="17"></a><hr />
201 Change resolution of framebuffer:
205 <a name="18"></a><hr />
207 Configure newsreader slrn:
211 <a name="19"></a><hr />
213 Configure grml system:
217 Or directly run scripts:
222 <a name="20"></a><hr />
224 Lock screen (X / console):
228 Press ctrl-alt-x to lock a GNU screen session.
230 <a name="21"></a><hr />
232 Change wallpaper in X:
234 % grml-wallpaper <press-tab>
236 <a name="22"></a><hr />
238 Start X window system (XFree86 / Xorg / X.org):
240 % grml-x $WINDOWMANAGER
245 % grml-x -mode '1024x768' wmii
246 % grml-x -nosync wm-ng
248 <a name="23"></a><hr />
250 Collect hardware information:
254 or run as root to collect some more information:
258 will generate a file named info.tar.bz2.
260 <a name="24"></a><hr />
262 Configure hardware detection features of harddisk installation:
266 or manually edit /etc/grml/autoconfig[.small]
268 See: man grml-autoconfig
270 <a name="25"></a><hr />
272 Bootoptions / cheatcodes / bootparams for booting grml:
274 On the grml-ISO if not running grml:
275 % less /cdrom/GRML/grml-cheatcodes.txt
278 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
280 <a name="26"></a><hr />
282 Report bugs to Debian's Bug Tracking System (BTS):
284 % reportbug --bts debian
286 or adjust /etc/reportbug.conf to your needs.
290 http://grml.org/bugs/
291 http://www.debian.org/Bugs/
293 <a name="27"></a><hr />
295 Offline documentation:
299 Online documentation:
302 http://grml.org/docs/
303 http://wiki.grml.org/doku.php
305 <a name="28"></a><hr />
307 Mount ntfs partition (read-write):
310 # ntfsmount /dev/hda1 /mnt/hda1
312 <a name="29"></a><hr />
314 Overwrite specific file on an NTFS partition:
316 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
318 <a name="30"></a><hr />
320 Resize an NTFS partition:
326 ntfsresize -n -s 10G /dev/hda1 # testcase
327 ntfsresize -s 10G /dev/hda1 # testing was successfull, now really resize partition
328 cfdisk /dev/hda # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
330 <a name="31"></a><hr />
332 Modify resolution for intel graphic chipsets:
338 # 915resolution 4d 1400 1050
340 <a name="32"></a><hr />
342 Connect bluetooth mouse:
346 ... and press 'connect' button on your bluetooth device.
348 <a name="33"></a><hr />
350 Connect bluetooth headset:
354 ... and press 'connect' button on your bluetooth device.
356 <a name="34"></a><hr />
358 Secure delete file / directory / partition:
364 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
366 <a name="35"></a><hr />
368 Use grml on Samsung X20 laptop:
370 # apt-get install grml-samsung-x20
372 See: http://www.michael-prokop.at/computer/samsung_x20.html
374 <a name="36"></a><hr />
376 Development information regarding grml:
378 http://blog.grml.org/
380 <a name="37"></a><hr />
384 #grml on irc.freenode.org - http://grml.org/irc/
385 http://grml.org/contact/
387 <a name="38"></a><hr />
389 Join the grml mailinglist:
391 http://grml.org/mailinglist/
393 <a name="39"></a><hr />
397 http://grml.org/donations/
399 <a name="40"></a><hr />
401 Commercial support / system administration / adjusted live-cds:
403 grml-solutions: http://grml.org/solutions/
405 <a name="41"></a><hr />
407 Information regarding the kernel provided by grml:
409 http://grml.org/kernel/
411 <a name="42"></a><hr />
413 SMTP command-line test tool:
415 % swaks <options>
419 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
423 <a name="43"></a><hr />
425 NTFS related packages:
431 <a name="44"></a><hr />
433 Modify service through init script:
440 # /etc/init.d/lvm start
442 <a name="45"></a><hr />
446 # jstest /dev/input/js0
448 <a name="46"></a><hr />
452 % mplayer /path/to/movie
454 <a name="47"></a><hr />
456 Use webcam with mplayer:
458 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
460 <a name="48"></a><hr />
462 Powerful network discovery tool:
466 <a name="49"></a><hr />
468 Grab an entire CD and compress it to Ogg/Vorbis,
469 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
473 <a name="50"></a><hr />
475 Show a console session in several terminals:
479 <a name="51"></a><hr />
481 Switch behaviour of caps lock key:
485 <a name="52"></a><hr />
487 grep with Perl-compatible regular expressions:
491 <a name="53"></a><hr />
493 ncp: a fast file copy tool for LANs
498 Remote (receive file):
501 <a name="54"></a><hr />
503 utility for sorting records in complex ways:
507 <a name="55"></a><hr />
509 a smaller, cheaper, faster SED implementation:
513 <a name="56"></a><hr />
519 See: http://grml.org/zsh/
521 <a name="57"></a><hr />
523 zsh reference card for grml system:
526 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
528 <a name="58"></a><hr />
532 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
534 % prename 's/foo/bar/' foo*
536 % zmv 'foo(*)' 'bar$1'
538 <a name="59"></a><hr />
540 Test TFT / LCD display:
544 <a name="60"></a><hr />
550 <a name="61"></a><hr />
552 Improved grep version:
556 <a name="62"></a><hr />
558 Grep with highlighting:
560 % grep --color=auto ...
563 <a name="63"></a><hr />
565 Extract matches when grepping:
568 % ifconfig | grepc 'inet addr:(.*?)s'
569 % ifconfig | glark --extract-matches 'inet addr:(.*?)s'
571 <a name="64"></a><hr />
573 Output text as sound:
576 % xsay # when running X and text selected via mouse
578 <a name="65"></a><hr />
580 Adjust a grml harddisk (grml2hd) installation:
584 <a name="66"></a><hr />
586 Get information on movie files:
588 % tcprobe -i file.avi
590 <a name="67"></a><hr />
592 Get an overview of your image files:
594 % convert 'vid:*.jpg' thumbnails.jpg
596 <a name="68"></a><hr />
598 List all standard defines:
600 % gcc -dM -E - < /dev/null
602 <a name="69"></a><hr />
604 Send a mail as reminder:
606 echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
608 <a name="70"></a><hr />
610 ncurses-based presentation tool:
614 See: man tpp and /usr/share/doc/tpp/examples/
616 <a name="71"></a><hr />
618 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
622 <a name="72"></a><hr />
624 Use IRC on command line:
628 <a name="73"></a><hr />
632 % vimdiff file1 file2
638 Moving between diffs:
648 <a name="74"></a><hr />
650 Hardware monitoring without kernel dependencies:
654 <a name="75"></a><hr />
656 Install grml-iso to usb-stick:
658 % grml2usb grml.iso /mount/point
660 <a name="76"></a><hr />
662 Use mplayer on framebuffer console:
664 % mplayer -vo fbdev ...
666 <a name="77"></a><hr />
668 Use links2 on framebuffer console:
670 % links2 -driver fb ...
672 <a name="78"></a><hr />
674 Switch language / keyboard:
676 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
677 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
678 Usage example: 'grml lang=us keyboard=de xkeyboard=de'
680 Or run one of the following commands:
684 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
687 <a name="79"></a><hr />
689 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
693 <a name="80"></a><hr />
695 Mount usb device / usb stick:
697 % mount /mnt/external1 # corresponds to /dev/sda1
699 % mount /mnt/external # corresponds to /dev/sda
701 <a name="81"></a><hr />
703 Install Sun Java packages:
705 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
707 # apt-get install java-package
708 # fakeroot make-jpkg j2re-*.bin
709 # dpkg -i sun-j2re*.deb
710 # update-alternatives --config java
712 <a name="82"></a><hr />
716 ddrescue is an improved version of dd which tries to read and
717 if it fails it will go on with the next sectors, where tools
724 <a name="83"></a><hr />
726 How to make an audio file (e.g. Musepack format) out of a DVD track:
728 % mkfifo /tmp/fifo.wav
729 % mppenc /tmp/fifo.wav track06.mpc &
730 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
732 Adjust the mppenc line with the encoder you would like to use,
733 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
737 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
738 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
740 Usage example for getting a PCM/wave file from audio channel 128:
741 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
743 <a name="84"></a><hr />
745 Create simple chroot:
747 # make_chroot_jail $USERNAME
749 <a name="85"></a><hr />
751 Convert DOS formated file to unix format:
753 sed 's/.$//' dosfile > unixfile # assumes that all lines end with CR/LF
754 sed 's/^M$//' dosfile > unixfile # in bash/tcsh, press Ctrl-V then Ctrl-M
755 sed 's/x0D$//' dosfile > unixfile # gsed 3.02.80, but top script is easier
756 awk '{sub(/r$/,"");print}' # assumes EACH line ends with Ctrl-M
757 gawk -v BINMODE="w" '1' infile >outfile # in DOS environment; cannot be done with
758 # DOS versions of awk, other than gawk
759 tr -d r < dosfile > unixfile # GNU tr version 1.22 or higher
760 tr -d '015' < dosfile > unixfile # use octal value for "r" (see man ascii)
761 tr -d '[015032]' < dosfile > unixfile # sometimes ^Z is appended to DOS-files
762 vim -c ":set ff=unix" -c ":wq" file # convert using vim
763 vim -c "se ff=dos|x" file # ... and even shorter ;)
764 recode ibmpc..lat1 file # convert using recode
765 echo -e "s/r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
767 <a name="86"></a><hr />
769 Save live audio stream to file:
771 % mplayer -ao pcm:file=$FILE
775 % mencoder mms://file.wmv -o $FILE -ovc copy -oac copy
779 % mimms mms://file.wmv
781 <a name="87"></a><hr />
787 % avimerge -i *.avi -o blub.avi
791 % cat *.mpg > blub.mpg
795 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
796 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
797 % avimerge -i file1.avi file2.avi -o blub.avi
799 <a name="88"></a><hr />
801 Display MS-Word file:
803 % strings file.doc | fmt | less
809 <a name="89"></a><hr />
811 Convert MS-Word file to postscript:
813 % antiword -p a4 file.doc > file.ps
815 <a name="90"></a><hr />
817 Convert manual to postscript:
819 % zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
821 % man -t zsh > zsh.ps
823 <a name="91"></a><hr />
827 % dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
829 <a name="92"></a><hr />
831 Read HTTP via netcat:
833 echo "GET / HTTP/1.0rnrn" | netcat $DOMAIN 80
835 <a name="93"></a><hr />
837 Get X ressources for specific program:
839 % xrdb -q |grep -i xterm
841 <a name="94"></a><hr />
843 Get windowid of specific X-window:
845 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
847 <a name="95"></a><hr />
849 Get titel of specific X-window:
853 <a name="96"></a><hr />
855 check locale - LC_MESSAGES:
857 % locale -ck LC_MESSAGES
859 <a name="97"></a><hr />
861 Create random password:
865 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
867 <a name="98"></a><hr />
869 Get tarballs of various Linux Kernel trees:
872 to get the current stable 2.6 release
875 to get a list of all supported trees
877 <a name="99"></a><hr />
879 Transfer your SSH public key to another host:
881 % ssh-keygen # ssh-keygen / ssh-key-gen: if you don't have a key yet
883 % ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
885 % cat $HOME/.ssh/id_rsa.pub | ssh user@remote-system 'cat >> .ssh/authorized_keys'
887 <a name="100"></a><hr />
889 Update /etc/fstab entries:
893 See "man grml-rebuildfstab" for more details about
894 generation of /etc/fstab (including stuff like
895 fs LABELs / UUIDs,...).
897 <a name="101"></a><hr />
899 Fetch and potentially change SCSI device parameters:
905 <a name="102"></a><hr />
907 reclaim disk space by linking identical files together:
911 <a name="103"></a><hr />
913 Find and remove duplicate files:
917 <a name="104"></a><hr />
919 Perform layer 2 attacks:
923 <a name="105"></a><hr />
927 <a name="106"></a><hr />
929 Guess PC-type hard disk partitions / partition table:
931 # gpart <options>
933 Perform a standard scan:
936 Write back the guessed table:
937 # gpart -W /dev/ice /dev/ice
939 <a name="107"></a><hr />
941 Develop, test and use exploit code with the Metasploit Framework:
944 wget http://framework-mirrors.metasploit.com/msf/downloader/framework-3.0.tar.gz
945 unp framework-3.0.tar.gz
949 <a name="108"></a><hr />
951 Useful documentation:
953 % w3m /usr/share/doc/Debian/reference/reference.en.html
955 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
957 http://grml.org/docs/ grml Documentation
958 http://wiki.grml.org/ grml Wiki
959 http://www.debian.org/doc/ Debian Documentation
960 http://wiki.debian.org/ Debian Wiki
961 http://www.gentoo.org/doc/en/ Gentoo Documentation
962 http://gentoo-wiki.com/ Gentoo Wiki
963 http://www.tldp.org/ The Linux Documentation Project
967 % fortune debian-hints
969 <a name="109"></a><hr />
973 % fortune debian-hints
974 % dpkg -L funny-manpages
976 <a name="110"></a><hr />
978 Backup master boot record (MBR):
980 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
982 <a name="111"></a><hr />
984 Backup partition table:
986 # sfdisk -d /dev/hda > hda.out
988 Restore partition table:
990 # sfdisk /dev/hda < hda.out
992 <a name="112"></a><hr />
994 Clone disk via network using netcat:
997 # nc -vlp 30000 > hda1.img
999 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
1001 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
1004 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
1006 <a name="113"></a><hr />
1008 Backup specific directories via cpio and ssh:
1010 # for f in directory_list; do find $f >> backup.list done
1011 # cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
1013 <a name="114"></a><hr />
1017 This one uses CPU cycles on the remote server to compare the files:
1018 # ssh target_address cat remotefile | diff - localfile
1019 # cat localfile | ssh target_address diff - remotefile
1021 This one uses CPU cycles on the local server to compare the files:
1022 # ssh target_address cat <localfile "|" diff - remotefile
1024 <a name="115"></a><hr />
1026 Useful tools for cloning / backups:
1028 * dd: convert and copy a file
1029 * dd_rescue: copies data from one file (or block device) to another
1030 * pcopy: a replacement for dd
1031 * partimage: back up and restore disk partitions
1032 * dirvish: Disk based virtual image network backup system
1033 * devclone: in-place filesystem conversion -- device cloning
1034 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
1035 * dump: ext2/3 filesystem backup
1036 * udpcast: multicast file transfer tool
1037 * cpio: copy files to and from archives
1038 * pax: read and write file archives and copy directory hierarchies
1039 * netcat / ssh / tar / gzip / bzip2: additional helper tools
1041 <a name="116"></a><hr />
1043 Use grml as a rescue system:
1047 * dd: convert and copy a file
1048 * ddrescue: copies data from one file or block device to another
1049 * partimage: Linux/UNIX utility to save partitions in a compressed image file
1050 * cfdisk: Partition a hard drive
1051 * nparted: Newt and GNU Parted based disk partition table manipulator
1052 * parted-bf: The GNU Parted disk partition resizing program, small version
1053 * testdisk: Partition scanner and disk recovery tool
1054 * gpart: Guess PC disk partition table, find lost partitions
1058 * e2fsprogs: ext2 file system utilities and libraries
1059 * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
1060 * e2undel: Undelete utility for the ext2 file system
1061 * ext2resize: an ext2 filesystem resizer
1062 * recover: Undelete files on ext2 partitions
1066 * reiser4progs: administration utilities for the Reiser4 filesystem
1067 * reiserfsprogs: User-level tools for ReiserFS filesystems
1071 * xfsdump: Administrative utilities for the XFS filesystem
1072 * xfsprogs: Utilities for managing the XFS filesystem
1076 * jfsutils: utilities for managing the JFS filesystem
1080 * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
1081 * salvage-ntfs: free NTFS data recovery tools
1082 * scrounge-ntfs: data recovery program for NTFS file systems
1083 * ntfsresize: resize ntfs partitions
1085 <a name="117"></a><hr />
1087 Get ASCII value of a character with zsh:
1089 % char=N ; print $((#char))
1091 <a name="118"></a><hr />
1093 Convert a collection of mp3 files to wave or cdr using zsh:
1095 % for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
1097 <a name="119"></a><hr />
1099 Convert images (foo.gif to foo.png) using zsh:
1101 % for i in **/*.gif; convert $i $i:r.png
1103 <a name="120"></a><hr />
1105 Remove all "non txt" files using zsh:
1109 <a name="121"></a><hr />
1111 Remote Shell Using SSH:
1114 % ssh -NR 3333:localhost:22 user@yourhost
1117 % ssh user@localhost -p 3333
1119 <a name="122"></a><hr />
1121 Reverse Shell with Netcat:
1124 % netcat -v -l -p 3333 -e /bin/sh
1127 % netcat 192.168.0.1 3333
1129 <a name="123"></a><hr />
1131 Reverse Shell via SSH:
1133 local host (inside the network):
1134 % ssh -NR 1234:localhost:22 remote_host
1136 remote host (outside the network):
1137 % ssh localhost -p 1234
1139 <a name="124"></a><hr />
1141 Remove empty directories with zsh:
1143 % rmdir ./**/*(/od) 2> /dev/null
1145 <a name="125"></a><hr />
1147 Find all the empty directories in a tree with zsh:
1151 <a name="126"></a><hr />
1153 Find all files without a valid owner and change ownership with zsh:
1155 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
1157 <a name="127"></a><hr />
1159 Display the 5-10 last modified files with zsh:
1161 % print -rl -- /path/to/dir/**/*(D.om[5,10])
1163 <a name="128"></a><hr />
1165 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
1167 % print -rl -- **/*(Dom[1,10])
1169 <a name="129"></a><hr />
1171 Find most recent file in a directory with zsh:
1173 % setopt dotglob ; print directory/**/*(om[1])
1175 <a name="130"></a><hr />
1177 Tunnel all traffic through an external server:
1179 % ssh -ND 3333 username@external.machine
1181 Then set the SOCKS4/5 proxy to localhost:3333.
1182 Check whether it's working by surfing e.g. to checkip.dyndns.org
1184 <a name="131"></a><hr />
1186 Tunnel everything through SSH via tsocks:
1188 set up the SSH proxy on the client side:
1190 % ssh -ND 3333 user@remote.host.example.com
1192 Adjust /etc/tsocks.conf afterwards (delete all other lines):
1197 For programs who natively support proxying connections (e.g. Mozilla
1198 Firefox) you can now set the proxy address to localhost port 3333.
1200 All other programs which's connections you want to tunnel through your
1201 external host are prefixed with tsocks, e.g.:
1203 % tsocks netcat example.com 80
1204 % tsocks irssi -c irc.quakenet.eu.org -p 6667
1206 If you call tsocks without parameters it executes a shell witht the
1207 LD_PRELOAD environment variable already set and exported.
1209 <a name="132"></a><hr />
1211 smartctl - control and monitor utility for harddisks using Self-Monitoring,
1212 Analysis and Reporting Technology (SMART):
1214 # smartctl --all /dev/ice
1216 If you want to use smartctl on S-ATA (sata) disks use:
1218 # smartctl -d ata --all /dev/sda
1221 # smartctl -t offline /dev/ice
1224 # smartctl -t short /dev/ice
1226 Display results of test:
1227 # smartctl -l selftest /dev/ice
1229 Query device information:
1230 # smartctl -i /dev/ice
1232 <a name="133"></a><hr />
1234 Mount a BSD / Solaris partition:
1236 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
1238 Use ufstype 44bsd for FreeBSD, NetBSD, OpenBSD (read-write).
1239 Use ufstype ufs2 for >= FreeBSD 5.x (read-only).
1240 Use ufstype sun for SunOS (Solaris) (read-write).
1241 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
1243 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
1246 <a name="134"></a><hr />
1248 Read BIOS (and or BIOS) password:
1250 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
1252 <a name="135"></a><hr />
1254 Clone one of the kernel trees via git:
1256 git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
1257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1258 This path defines the tree. See http://kernel.org/git/ for an overview.
1260 <a name="136"></a><hr />
1262 Mount filesystems over ssh protocol:
1264 % sshfs user@host:/remote_dir /mnt/test
1268 % fusermount -u /mnt/test
1270 (Notice: requires fuse kernel module)
1272 <a name="137"></a><hr />
1274 Install Gentoo using grml:
1276 See http://www.gentoo.org/doc/en/altinstall.xml
1278 <a name="138"></a><hr />
1280 Install (plain) Debian (sarge release) via grml:
1282 Assuming you want to install Debian to sda1:
1284 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1285 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1286 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1287 chroot /mnt/test /bin/bash # let's chroot into the new system
1288 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
1289 mount -t proc none /proc # make sure we also have a mounted /proc
1290 base-config # now configure some main settings
1291 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
1292 cd /dev ; ./MAKEDEV generic # make sure we have all necessary devices for lilo
1293 apt-get install lilo linux-image-2.6.12-1-386 # install lilo and a kernel which fits your needs
1294 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
1295 vi /etc/lilo.conf && lilo # adjust the file for your needs and run lilo afterwards
1296 umount /proc ; umount /dev/pts # we do not need them any more
1297 exit # now leave chroot
1298 cp /etc/hosts /etc/fstab /mnt/test/etc/ # you might want to take the existing files...
1299 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
1300 umount /mnt/test && reboot # unmount partition and reboot...
1302 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1303 Avoid all of the above steps - use grml-debootstrap(8) instead!
1305 <a name="139"></a><hr />
1307 Install (plain) Debian (etch release) via grml
1309 Assuming you want to install Debian to sda1:
1311 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1312 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1313 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1314 chroot /mnt/test /bin/bash # let's chroot into the new system
1315 mount -t proc none /proc # make sure we have a mounted /proc
1316 apt-get install locales console-data # install locales
1317 dpkg-reconfigure locales console-data # adjust locales to your needs
1318 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
1319 apt-get install linux-headers-2.6-686 linux-image-686 # install current kernel
1321 echo "127.0.0.1 localhost" > /etc/hosts # adjust /etc/hosts and network:
1322 cat >> /etc/network/interfaces << EOF
1323 iface lo inet loopback
1324 iface eth0 inet dhcp
1329 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1330 cat >> /etc/fstab << EOF
1331 sysfs /sys sysfs auto 0 0
1332 proc /proc proc defaults 0 0
1333 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1
1334 /dev/sda2 none swap sw 0 0
1335 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
1337 passwd # set password of user root
1339 mkdir /boot/grub # setup grub
1340 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1341 cat >> /boot/grub/menu.lst << EOF
1342 title Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1344 kernel /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1345 initrd /boot/initrd.img-2.6.18-3-686
1347 vim /boot/grub/menu.lst # adjust grub configuration to your needs
1348 cd /dev && MAKEDEV generic # create default devices
1349 cp -i /usr/lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1350 grub install # now install grub, run in grub-cmdline following commands:
1354 umount -a # unmount all filesystems in chroot and finally:
1355 exit # exit the chroot and:
1358 If you want to use lilo instead of grub take a look at
1359 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1361 cat > /etc/lilo.conf << EOF
1362 # This allows booting from any partition on disks with more than 1024 cylinders.
1365 # Specifies the boot device
1368 # Specifies the device that should be mounted as root.
1371 # use Debian on software raid:
1372 # raid-extra-boot=mbr-only
1380 image=/boot/vmlinuz-2.6.18-grml
1384 initrd=/boot/initrd.img-2.6.18-grml
1387 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1388 Avoid all of the above steps - use grml-debootstrap(8) instead!
1390 <a name="140"></a><hr />
1392 Convert files from Unicode / UTF-8 to ISO:
1394 % iconv -c -f utf8 -t iso-8859-15 < utffile > isofile
1398 % iconv -f iso-8859-15 -t utf8 < isofile > utffile
1400 <a name="141"></a><hr />
1402 Assign static setup for network cards (eth0 and eth1) via udev:
1404 First method - manual:
1405 ~~~~~~~~~~~~~~~~~~~~~~
1406 Get information for SYSFS address:
1407 # udevinfo -a -p /sys/class/net/eth0/ | grep address
1409 Then create udev rules:
1410 # cat /etc/udev/network.rules
1412 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:01", NAME="wlan0"
1413 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:02", NAME="lan0"
1414 # do not match eth* drivers but also e.g. firewire stuff:
1415 ACTION=="add", SUBSYSTEM=="net", SYSFS{address}=="00:00:00:00:00:03", NAME="1394"
1417 Now activate the rules:
1418 # cd /etc/udev/rules.d/ && ln -s ../network.rules z35_network.rules
1420 Unload the drivers, restart udev and load the drivers again to activate
1423 Second method - automatic:
1424 ~~~~~~~~~~~~~~~~~~~~~~~~~~
1425 Run /lib/udev/write_net_rules shipped with recent udev versions:
1427 # INTERFACE=wlan1 /lib/udev/write_net_rules 00:00:00:00:00:04
1429 This command will create /etc/udev/rules.d/z25_persistent-net.rules containing:
1431 SUBSYSTEM=="net", DRIVER=="?*", SYSFS{address}=="00:00:00:00:00:04", NAME=wlan1
1433 See /usr/share/doc/udev/writing_udev_rules/index.html for more information.
1435 <a name="142"></a><hr />
1437 Change the suffix from *.sh to *.pl using zsh:
1440 % zmv -W '*.sh' '*.pl'
1442 <a name="143"></a><hr />
1444 Generate SSL certificate:
1446 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1447 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1450 # openssl x509 -in certfile -text
1452 Verify against CA certificate:
1453 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1455 Generate 2048bit RSA-key:
1456 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1458 As before but add request to existing key pub-sec-key.pem:
1459 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1461 Show request request.pem:
1462 # openssl req -text -noout -in request.pem
1464 Verify signature of request request.pem:
1465 # openssl req -verify -noout -in request.pem
1467 Generate SHA1 fingerprint (modulo key) of request.pem:
1468 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1470 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1471 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1473 As before but create self signed certificate based on existing key pub-sec-key.pem:
1474 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1476 Generate new request out of existing self signed certificate:
1477 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1479 Display certificate self-signed-certificate.pem in plaintext:
1480 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1482 Check self signed certificate:
1483 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1485 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1486 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1488 Generate ssl-certificate for use with apache2:
1490 export RANDFILE=/dev/random
1491 mkdir /etc/apache2/ssl/
1492 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
1493 chmod 600 /etc/apache2/ssl/apache.pem
1495 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1497 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1499 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1501 <a name="144"></a><hr />
1503 Change Windows NT password(s):
1505 # mount -o rw /mnt/hda1
1506 # cd /mnt/hda1/WINDOWS/system32/config/
1507 # chntpw SAM SECURITY system
1509 Notice: if mounting the partition read-write did not work (check syslog!)
1510 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1512 (Be careful with deactivating syskey!)
1514 <a name="145"></a><hr />
1516 glark - replacement for grep written in Ruby:
1518 A replacement for (or supplement to) the grep family, glark offers:
1519 Perl compatible regular expressions, highlighting of matches,
1520 context around matches, complex expressions and automatic exclusion
1525 % glark -y keyword file # display only the region that matched, not the entire line
1526 % glark -o format print *.h # search for either "printf" or "format"
1528 More information: man glark
1530 <a name="146"></a><hr />
1532 Find CD burning device(s):
1534 General information on CD-ROM:
1535 % cat /proc/sys/dev/cdrom/info
1537 Scan using ATA Packet specific SCSI transport:
1538 # cdrecord -dev=ATA -scanbus
1539 # cdrecord-prodvd -s -scanbus dev=ATA
1541 Get specific information for /dev/ice:
1542 # cdrecord dev=/dev/ice -scanbus
1544 <a name="147"></a><hr />
1546 Create devices in /dev on udev:
1548 For example create md devices (/dev/md0, /dev/md1,...):
1549 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1551 <a name="148"></a><hr />
1553 Identify network device (NIC):
1555 # ethtool -i $DEVICE
1557 Show NIC statistics:
1559 # ethtool -S $DEVICE
1561 If your NIC shows some aging signs, you may want to be sure:
1563 # ethtool -t $DEVICE
1565 Disable TCP/UDP checksums:
1567 # ethtool -K $DEVICE tx off
1569 <a name="149"></a><hr />
1571 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1573 Switch to tty12 and take a look at the syslog. If you see something like:
1575 SQUASHFS error: zlib_fs returned unexpected result 0x........
1576 SQUASHFS error: Unable to read cache block [.....]
1577 SQUASHFS error: Unable to read inode [.....]
1579 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1580 Check your CD low-level via running:
1582 # readcd -c2scan dev=/dev/cdrom
1584 If the medium really is ok and it still fails try to boot with deactivated DMA
1585 via using grml nodma at the bootprompt.
1587 <a name="150"></a><hr />
1589 Write a Microsoft compatible boot record (MBR) using ms-sys
1591 Write a Windows 2000/XP/2003 MBR to device:
1593 # ms-sys -m /dev/ice
1595 <a name="151"></a><hr />
1597 Use a Vodafone 3G Datacard (UMTS) with Linux:
1599 Plug in your vodafone card and check in syslog whether the appropriate
1600 (probably /dev/ttyUSB0 or /dev/noz0) has been created. If so run:
1603 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1606 # gcom -d /dev/ttyUSB0
1607 # wvdial --config /etc/wvdial.conf.umts a1usb
1610 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1613 # wvdial --config /etc/wvdial.conf.umts dreiusb
1615 If you receive invalid DNS nameservers when connecting, like:
1618 --> primary DNS address 10.11.12.13
1619 --> secondary DNS address 10.11.12.14
1621 just provide a working nameserver to resolvconf via:
1623 # echo "nameserver 80.120.17.70" | resolvconf -a ppp0
1625 Notice: some vodafone cards require the nozomi driver (run 'modprobe nozomi' on
1626 your grml system), some other ones require the sierra driver (run
1629 If your device isn't supported by usbserial yet, manually provide vendor and
1630 product ID when loading the usbserial module. Usage example:
1634 Bus 004 Device 008: ID 1199:6813 Sierra Wireless, Inc.
1636 # modprobe usbserial vendor=0x1199 product=0x6813
1638 <a name="152"></a><hr />
1640 hdparm - get/set hard disk parameters
1642 Display the identification info that was obtained from the drive at boot time,
1644 # hpdarm -i /dev/ice
1646 Request identification info directly from the drive:
1647 # hpdarm -I /dev/ice
1649 Perform timings of device + cache reads for benchmark and comparison purposes:
1650 # hdparm -tT /dev/ice
1652 <a name="153"></a><hr />
1654 bonnie++ - program to test hard drive performance.
1656 # mkdir /mnt/benchmark
1657 # mount /dev/ice /mnt/benchmark
1658 # chmod go+w /mnt/benchmark
1659 # bonnie -u grml -d /mnt/benchmark -s 2000M
1661 <a name="154"></a><hr />
1663 Use gizmo with a bluetooth headset:
1665 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1666 % gizmo --mic $DEVICE --speaker $DEVICE
1668 <a name="155"></a><hr />
1670 Scan a v4l device for TV stations:
1672 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1674 Then running xawtv should work:
1678 <a name="156"></a><hr />
1680 Run apt-get with timeout of 3 seconds:
1682 # apt-get -o acquire::http::timeout=3 update
1684 <a name="157"></a><hr />
1686 Debian GNU/Linux device driver check page
1688 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1690 <a name="158"></a><hr />
1692 Use dd with status line:
1694 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1696 <a name="159"></a><hr />
1698 Generate a 512k file of random data with status bar:
1700 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1702 <a name="160"></a><hr />
1704 Install Grub instead of lilo on grml installation (grml2hd):
1709 adjust grub's configuration file menu.lst:
1710 # $EDITOR /boot/grub/menu.lst
1712 now install grub (usage example for /dev/sda1):
1717 <a name="161"></a><hr />
1719 Install Ubuntu using grml:
1721 See https://wiki.ubuntu.com/Installation/FromKnoppix
1723 <a name="162"></a><hr />
1725 Resize ext2 / ext3 partition:
1727 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1728 # fsck.ext2 -v -y -f /dev/iceX # check the filesystem
1729 # resize2fs -p /dev/iceX $SIZE # resize it (adjust $SIZE)
1730 # fdisk /dev/ice # adjust partition in partition table
1731 # fsck.ext2 -v -y -f /dev/iceX # check filesystem again
1732 # resize2fs -p /dev/iceX # resize it to maximum
1733 # tune2fs -j /dev/iceX # re-enable journal
1735 <a name="163"></a><hr />
1737 Tune ext2 / ext3 filesystem:
1739 Check partition first:
1741 # tune2fs -l /dev/iceX
1743 If you don't see dir_index in the list, then enable it:
1745 # tune2fs -O dir_index /dev/iceX
1747 Now run e2fsck with the -D option to have the directories optimized:
1749 # e2fsck -D /dev/iceX
1751 Notice: since e2fsprogs (1.39-1) filesystems are created with
1752 directory indexing and on-line resizing enabled by default.
1754 <a name="164"></a><hr />
1756 Search for printers via network:
1758 # pconf_detect -m NETWORK -i 192.168.0.1/24
1760 <a name="165"></a><hr />
1762 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1764 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1766 <a name="166"></a><hr />
1768 System-Profiling using oprofile:
1773 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1778 Now $DO_SOME_TASKS...
1781 # opcontrol --shutdown
1783 Then take a look at the reports using something like e.g.:
1784 # opreport -t 0.5 --exclude-dependent
1785 # opreport -t 0.5 /path/to/executable_to_check
1786 # opannotate -t 0.5 --source --assembly
1788 <a name="167"></a><hr />
1790 Install ATI's fglrx driver for Xorg / X.org:
1792 Usually there already exist drivers for the grml-system:
1793 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1795 After installing adjust xorg.conf via running:
1796 # aticonfig --initial --input=/etc/X11/xorg.conf
1798 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1800 <a name="168"></a><hr />
1802 Install nvidia driver for Xorg / X.org:
1804 Usually there already exist drivers for the grml-system:
1805 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
1807 Then switch from module nv to nvidia:
1809 # sed -i 's/Driver.*nv.*/Driver "nvidia"/' /etc/X11/xorg.conf
1811 <a name="169"></a><hr />
1813 glxgears - a GLX demo that draws three rotating gears
1815 To print frames per second (fps) use:
1816 % glxgears -printfps
1818 <a name="170"></a><hr />
1820 You forgot to boot with 'grml noeject noprompt' to avoid
1821 ejecting and prompting for CD removal when rebooting/halting
1832 If you want to avoid only the prompting part, run:
1840 <a name="171"></a><hr />
1842 Mount wikipedia local via fuse:
1844 Adjust configuration:
1845 % cat ~/.wikipediafs/config.xml
1848 <article-cache-time>300</article-cache-time>
1852 <dirname>wikipedia-de</dirname>
1853 <host>de.wikipedia.org</host>
1854 <basename>/w/index.php</basename>
1857 <dirname>wikipedia-en</dirname>
1858 <host>en.wikipedia.org</host>
1859 <basename>/w/index.php</basename>
1864 Mount it (/wiki must exist of course):
1865 % mount.wikipediafs /wiki
1866 % cat /wiki/wikipedia-en/Cat
1869 % fusermount -u /wiki
1871 <a name="172"></a><hr />
1873 Remote notification on X via osd (on screen display):
1875 Start osd_server.py at your local host (listens on port 1234 by default):
1878 Then login to a $REMOTEHOST
1879 % ssh -R 1234:localhost:1234 $REMOTEHOST
1881 Now send the text to your local display via running something like:
1882 % echo "text to send" | nc localhost 1234
1884 Very useful when you are waiting for a long running job
1885 but want to do something else in the meanwhile:
1887 % ./configure && make && echo "finished compiling" | netcat localhost 1234
1889 You can use this in external programs as well of course. Examples:
1891 Use osd in centericq:
1893 % cat ~/.centericq/external
1902 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
1903 CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
1904 osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
1905 if echo | socat - TCP4:localhost:1234 &>/dev/null ; then
1906 echo "${osd_msg}" | netcat localhost 1234
1910 Use it in the IRC console client irssi via running:
1914 You can even activate the port forwarding by default globally:
1919 RemoteForward 1234 127.0.0.1:1234
1922 Notice: if you get 'ABORT: Requested font not found' make sure the
1923 requested font is available, running 'LANG=C LC_ALL=C osd_server.py...'
1926 <a name="173"></a><hr />
1928 Avoid automatical startup of init scripts via invoke-rc.d:
1930 First of all make sure the package policyrcd-script-zg2 (which
1931 provides the /usr/sbin/policy-rc.d interface) is installed.
1933 In policyrcd-script-zg2's configuration file named
1934 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
1935 defined as the interface for handling invoke-rc.d's startup policy.
1937 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf. By
1938 default you won't notice any differences to Debian's default
1939 behaviour, except that invoke-rc.d won't be executed if a chroot has
1940 been detected (detection: /proc is missing).
1942 If you want to disable automatical startup of newly installed packages
1943 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
1944 /etc/policy-rc.d.conf.
1946 To restore the default behaviour set EXITSTATUS back to '0' in
1947 /etc/policy-rc.d.conf.
1949 <a name="174"></a><hr />
1951 Install VMware-Tools for grml:
1953 First of all make sure a CD-ROM device in VMware is available.
1955 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
1959 unp /mnt/cdrom/vmware-linux-tools.tar.gz
1960 cd vmware-tools-distrib
1963 /etc/init.d/networking stop
1968 /etc/init.d/networking start
1970 In an X terminal, launch the VMware Tools running:
1974 <a name="175"></a><hr />
1976 Some important Postfix stuff
1984 Send all messages in the queue:
1988 Send all messages in the queue for a specific site:
1992 Delete a specific message
1993 # postsuper -d 12345678942
1995 Deletes all messages held in the queue for later delivery
1996 # postsuper -d ALL deferred
1998 Mail queues in postfix:
2000 incoming -> mail who just entered the system
2001 active -> mail to be delivered
2002 deferred -> mail to be delivered later because there were problems
2003 hold -> mail that should not be delivered until released from hold
2005 For configuration of postfix take a look at
2006 /etc/postfix/master.cf - man 5 master
2007 /etc/postfix/main.cf - man 5 postconf
2008 and http://www.postfix.org/documentation.html.
2010 <a name="176"></a><hr />
2014 mode 4000 - set user ID (suid):
2016 - for executable files: run as the user who owns the file, instead of the
2017 user who runs the file
2018 - for directories: not used
2020 mode 2000 - set group ID (guid):
2022 - for executable files: run as the group who owns the file, instead of the
2023 group of the user who runs the file
2024 - for directories: when a file is created inside the directory, it belongs
2025 to the group of the directory instead of the default group of the user who
2028 mode 1000 - sticky bit:
2030 - for files: not used
2031 - for directories: only the owner of a file can delete or rename the file
2033 <a name="177"></a><hr />
2035 Create MySQL database
2037 # apt-get install mysql-client mysql-server
2039 Run 'mysql' as root - create a database with:
2041 create database grml
2043 Give a user access to the database (without password):
2045 grant all on grml.* to mika;
2047 Give a user access to the database (with password):
2049 grant all on grml.* to enrico identified by "PASSWORD";
2051 <a name="178"></a><hr />
2053 Setup an HTTPS website:
2055 Create a certificate:
2057 # mkdir /etc/apache2/ssl
2058 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
2060 Create a virtual host on port 443:
2062 <VirtualHost www.foo.invalid:443>
2064 </VirtualHost>
2066 Enable SSL in the VirtualHost:
2069 SSLCertificateFile /etc/apache2/ssl/apache.pem
2071 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
2075 and make sure the SSL module is used:
2079 <a name="179"></a><hr />
2081 Useful Apache / Apache2 stuff
2083 Check configuration file via running:
2085 # apache2ctl configtest
2093 # a2enmod modulename
2095 <a name="180"></a><hr />
2097 Create tar archive and store it on remote machine:
2099 % tar zcf - /sourcedir | ssh user@targethost "cat >file.tgz"
2101 <a name="181"></a><hr />
2103 Pick out and displays images from network traffic:
2107 <a name="182"></a><hr />
2109 Install Flash plugin:
2111 # dpkg-reconfigure flashplugin-nonfree
2113 <a name="183"></a><hr />
2115 To test a proxy, low level way:
2119 GET http://www.google.com HTTP/1.0 [press enter twice]
2121 <a name="184"></a><hr />
2123 Adjust system for use of qemu with kqemu:
2125 Make sure you have all you need:
2126 # aptitude update ; aptitude install qemu kqemu-modules-$(uname -r)
2131 mknod /dev/kqemu c 250 0
2132 chmod 666 /dev/kqemu
2133 chmod 666 /dev/net/tun
2135 Check kqemu support via starting qemu, press
2136 Ctrl-Alt-2 and entering 'info kqemu'.
2138 <a name="185"></a><hr />
2140 (High-Load) Debugging related tools:
2142 mpstat # report processors related statistics
2143 iostat # report CPU statistics and input/output statistics for devices and partitions
2144 vmstat # report virtual memory statistics
2145 slabtop # display kernel slab cache information in real time
2146 atsar # system activity report
2147 dstat # versatile tool for generating system resource statistics
2158 <a name="186"></a><hr />
2160 Using WPA for network setup manually:
2162 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
2164 Adjust the options and configuration file to your needs.
2165 Also take a look at 'grml-network'.
2167 <a name="187"></a><hr />
2169 Start X and lock console via exiting:
2171 % startx 2>~/.xsession-errors &| exit
2173 <a name="188"></a><hr />
2175 Which process is writing to disk and/or causes the disk to spin up?
2177 First of all use lsof to check what's going on. Does not help? ->
2179 # echo 1 > /proc/sys/vm/block_dump
2181 The command sets a sysctl to cause the kernel to log all disk
2182 writes. Please notice that there is a lot of data. So please
2183 disable syslogd/syslog-ng before you do this, or you must make
2184 sure that kernel output is not logged.
2186 When you're done, disable block dump using:
2187 # echo 0 > /proc/sys/vm/block_dump
2190 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
2191 which handles block_dump on its own.
2193 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2195 Also take a look at event-viewer(8) which is part of grml-debugtools.
2197 <a name="189"></a><hr />
2199 Install initrd via initramfs-tools for currently running kernel:
2201 # update-initramfs -c -t -k $(uname -r)
2203 <a name="190"></a><hr />
2205 Install initrd via yaird for currently running kernel:
2207 # yaird -o /boot/initrd.img-$(uname -r)
2209 Install initrd via yaird for specific kernel:
2213 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
2215 <a name="191"></a><hr />
2217 Reinstall package with its original configuration files:
2219 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o DPkg::Options::=--force-confnew package
2221 <a name="192"></a><hr />
2223 grml 0.8 funkenzutzler - rt2x00 drivers:
2225 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
2226 includes beta-version drivers) is not installed by default. If you want to
2227 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
2228 rt73usb please install the package manually running:
2230 # dpkg -i /usr/src/rt2x00-modules-*.deb
2232 <a name="193"></a><hr />
2234 Use Java with jikes and jamvm on grml:
2238 % cp /usr/share/doc/grml-templates/template.java .
2239 % jikes template.java
2242 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
2243 so you do not have to manually run
2244 jikes --bootclasspath /usr/share/classpath/glibj.zip
2246 <a name="194"></a><hr />
2248 Online resizing of (Software-)RAID5:
2250 # Initiate a RAID5 setup for testing purposes:
2251 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
2253 # Create filesystem, mount md0, create a testfile and save md5sum for
2256 mount /dev/md0 /mnt/test
2257 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
2258 md5sum /mnt/test/dd > md5sum
2260 # Make sure the RAID is synched via checking:
2263 # Now remove one partition:
2264 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
2266 # Delete partition, create a new + bigger one and set partition type to fd
2267 # (Linux raid autodetect):
2270 # And re-add the partition:
2271 mdadm -a /dev/md0 /dev/hdd1
2273 # Make sure the RAID is synched via checking:
2276 # Repeat the steps for all other disks/partitions as well:
2277 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2279 mdadm -a /dev/md0 /dev/hdb1
2281 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2283 mdadm -a /dev/md0 /dev/hda1
2286 # Now resize the RAID5 system online [see 'man mdadm' for details]:
2287 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
2288 mdadm --grow /dev/md0 -z max
2289 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
2291 # Last step - resize the filesystem (online again):
2294 <a name="195"></a><hr />
2296 ext3 online resizing:
2298 Starting with Linux kernel 2.6.10 you can resize ext3 online. With
2299 e2fsprogs >=1.39-1 new filesystems are created with directory indexing and
2300 on-line resizing enabled by default (see /etc/mke2fs.conf).
2304 cfdisk /dev/hda # create a partition with type 8e (lvm)
2305 pvcreate /dev/hda2 # create a physical volume
2306 vgcreate resize_me /dev/hda2 # create volume group
2307 lvcreate -n resize_me -L100 resize_me # create a logical volume
2308 mkfs.ext3 /dev/resize_me/resize_me # now create a new filesystem
2309 mount /dev/resize_me/resize_me /mnt/test # mount the new fs for demonstrating online resizing
2310 df -h # check the size of the partition
2311 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
2312 resize2fs /dev/resize_me/resize_me # and finally resize the filesystem
2313 df -h # recheck the size of the partition
2315 This also works for Software-RAID. Demo:
2317 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
2319 mount /dev/md0 /mnt/test
2320 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
2321 cfdisk /dev/hda # adjust partition size for hda2
2322 mdadm /dev/md0 --add /dev/hda2
2323 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2324 cfdisk /dev/hdb # adjust partition size for hdb1
2325 mdadm /dev/md0 --add /dev/hdb1
2326 mdadm --grow /dev/md0 --size=max
2329 Notice: online resizing works as soon as the kernel can re-read the
2330 partition table. So it works for example with LVM and SW-RAID but not with
2331 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
2332 table if the device is already mounted.
2334 <a name="196"></a><hr />
2336 Use vim as an outline editor:
2338 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
2342 <a name="197"></a><hr />
2344 Monitor directories/files for changes using iwatch
2346 Monitor /tmp for changes:
2349 Monitor files/directories specified in /etc/iwatch.xml
2350 and send mail on changes:
2353 <a name="198"></a><hr />
2355 Some often used mdadm commands:
2358 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
2360 Display details of specific RAID:
2361 # mdadm --detail /dev/md0
2364 Simulating a drive failure by software:
2365 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
2367 Remove disk from RAID:
2368 # mdadm /dev/md0 -r /dev/hda1
2370 Set disk as faulty and remove from RAID:
2371 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2376 Restart a RAID-device:
2379 Add another disk to existing RAID setup (hotadd):
2380 # mdadm /dev/md0 -a /dev/hde1
2381 # mdadm --grow /dev/md0 --raid-devices=4
2383 Assemble and start all arrays:
2384 # mdadm --assemble --scan
2386 Assemble a specific array:
2387 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
2390 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
2393 # mdadm --stop --scan
2395 Scan for and setup arrays automatically:
2396 # mdadm --assemble --scan --auto=yes --verbose
2398 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
2400 CREATE owner=root group=disk mode=0660 auto=yes
2401 HOMEHOST <system>
2405 # /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
2408 Monitoring the sw raid
2409 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
2411 Producing /etc/mdadm/mdadm.conf:
2412 # mdadm --detail --scan > /etc/mdadm/mdadm.conf
2414 See also: man mdadm | less -p "^EXAMPLES"
2415 http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
2417 <a name="199"></a><hr />
2419 A quick summary of the most commonly used RAID levels:
2422 => 2 disks each 160 GB: 320 GB data
2423 RAID 1: Mirrored Set
2424 => 2 disks each 160 GB: 160 GB data
2425 RAID 5: Striped Set with Parity
2426 => 3 disks each 160 GB: 320 GB data; 160 GB redundancy
2428 Common nested RAID levels:
2429 RAID 01: A mirror of stripes
2430 RAID 10: A stripe of mirrors
2431 RAID 30: A stripe across dedicated parity RAID systems
2432 RAID 100: A stripe of a stripe of mirrors
2434 -- http://en.wikipedia.org/wiki/RAID
2436 <a name="200"></a><hr />
2438 Logical Volume Management (LVM) with Linux
2443 | hda1 hdc1 (PV:s on partitions or whole disks)
2447 | / | | / | | usrlv rootlv varlv (LV:s)
2449 | ext3 ext3 xfs (filesystems)
2451 Often used commands:
2452 ~~~~~~~~~~~~~~~~~~~~
2454 Create a physical volume:
2455 # pvcreate /dev/hda2
2457 Create a volume group:
2458 # vgcreate testvg /dev/hda2
2460 Create a logical volume:
2461 # lvcreate -n test_lv -L100 testvg
2463 Resize a logical volume:
2464 # lvextend -L+100M /dev/resize_me/resize_me
2465 # resize2fs /dev/resize_me/resize_me # ext2/3
2466 # xfs_growfs /dev/resize_me/resize_me # xfs
2467 # resize_reiserfs -f /dev/resize_me/resize_me # reiserfs online
2468 # mount -o remount,resize /dev/resize_me/resize_me # jfs
2470 Create a snapshot of a logical volume:
2471 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2473 Deactivate a volume group:
2474 # vgchange -a n my_volume_group
2476 Actually remove a volume group:
2477 # vgremove my_volume_group
2479 Display information about physical volume:
2480 # pvdisplay /dev/hda1
2482 Remove physical volume:
2483 # vgreduce my_volume_group /dev/hda1
2485 Remove logical volume:
2486 # umount /dev/myvg/homevol
2487 # lvremove /dev/myvg/homevol
2490 http://www.tldp.org/HOWTO/LVM-HOWTO/
2492 <a name="201"></a><hr />
2494 How to use APT locally
2496 Sometimes you have lots of packages .deb that you would like to use APT to
2497 install so that the dependencies would be automatically solved. Solution:
2500 dpkg-scanpackages debs /dev/null | gzip > debs/Packages.gz
2501 echo " deb file:/root debs/" >> /etc/apt/sources.list
2502 dpkg-scansources debs | gzip > debs/Sources.gz
2503 echo " deb-src file:/root debs/" >> /etc/apt/sources.list
2505 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2507 <a name="202"></a><hr />
2509 Check filesystem's LABEL:
2512 # vol_id -l /dev/sda1
2514 ext2/3 without vol_id:
2515 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2518 # xfs_admin -l /dev/sda1
2520 reiserfs without vol_id:
2521 # debugreiserfs /dev/sda1 | grep -i label
2524 # jfs_tune -l /dev/sda1 | grep -i label
2526 reiser4 without vol_id:
2527 # debugfs.reiser4 /dev/sda1 | grep -i label
2529 <a name="203"></a><hr />
2531 Check filesystem's UUID:
2534 # vol_id -u /dev/sda1
2536 ext2/3 without vol_id:
2537 # dumpe2fs /dev/sda1 | grep -i UUID
2540 # xfs_admin -u /dev/sda1
2542 reiserfs without vol_id:
2543 # debugreiserfs /dev/sda1 | grep -i UUID
2545 reiser4 without vol_id:
2546 # debugfs.reiser4 /dev/sda1 | grep -i UUID
2548 <a name="204"></a><hr />
2550 Change a filesystem's LABEL:
2553 # mkswap -L $LABEL /dev/sda1
2556 # e2label /dev/sda1 $LABEL
2557 # tune2fs -L $LABEL /dev/sda1
2560 # reiserfstune -l $LABEL /dev/sda1
2563 # jfs_tune -L $LABEL /dev/sda1
2566 # xfs_admin -L $LABEL /dev/sda1
2569 # echo 'drive i: file="/dev/sda1"' >> ~/.mtoolsrc
2570 # mlabel -s i:$LABEL
2573 # ntfslabel $LABEL /dev/sda1
2575 <a name="205"></a><hr />
2577 Disable pdiffs feature of APT:
2580 # echo 'Acquire::PDiffs "false";' >> /etc/apt/apt.conf
2583 # apt-get update -o Acquire::Pdiffs=false
2585 <a name="206"></a><hr />
2587 Backup big devices or files and create compressed splitted
2588 image chunks of it using zsplit
2590 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2591 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2592 read/write buffer to 256kB:
2593 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2595 Restore the backup using unzsplit:
2596 # unzsplit -D /dev/sda -d archiveofsda
2598 More usage examples: man zsplit + man unzsplit
2600 <a name="207"></a><hr />
2602 Measure network performance using iperf:
2608 % iperf -c <server_address> -V
2612 Server with 128k TCP window size:
2615 Client with running for 60 seconds and bidirectional test:
2616 % iperf -c <server_address> -r -w128k -t60
2618 <a name="208"></a><hr />
2620 Framebuffer resolutions:
2622 Resolution in pixels
2623 Color depth | 640x480 800x600 1024x768 1280x1024
2624 256 (8bit)| 769 771 773 775
2625 32000 (15bit)| 784 787 790 793
2626 65000 (16bit)| 785 788 791 794
2627 16.7 Mill.(24bit)| 786 789 792 795
2631 Mode 0x0300: 640x400 (+640), 8 bits
2632 Mode 0x0301: 640x480 (+640), 8 bits
2633 Mode 0x0303: 800x600 (+800), 8 bits
2634 Mode 0x0303: 800x600 (+832), 8 bits
2635 Mode 0x0305: 1024x768 (+1024), 8 bits
2636 Mode 0x0307: 1280x1024 (+1280), 8 bits
2637 Mode 0x030e: 320x200 (+640), 16 bits
2638 Mode 0x030f: 320x200 (+1280), 24 bits
2639 Mode 0x0311: 640x480 (+1280), 16 bits
2640 Mode 0x0312: 640x480 (+2560), 24 bits
2641 Mode 0x0314: 800x600 (+1600), 16 bits
2642 Mode 0x0315: 800x600 (+3200), 24 bits
2643 Mode 0x0317: 1024x768 (+2048), 16 bits
2644 Mode 0x0318: 1024x768 (+4096), 24 bits
2645 Mode 0x031a: 1280x1024 (+2560), 16 bits
2646 Mode 0x031b: 1280x1024 (+5120), 24 bits
2647 Mode 0x0330: 320x200 (+320), 8 bits
2648 Mode 0x0331: 320x400 (+320), 8 bits
2649 Mode 0x0332: 320x400 (+640), 16 bits
2650 Mode 0x0333: 320x400 (+1280), 24 bits
2651 Mode 0x0334: 320x240 (+320), 8 bits
2652 Mode 0x0335: 320x240 (+640), 16 bits
2653 Mode 0x0336: 320x240 (+1280), 24 bits
2654 Mode 0x033c: 1400x1050 (+1408), 8 bits
2655 Mode 0x033d: 640x400 (+1280), 16 bits
2656 Mode 0x033e: 640x400 (+2560), 24 bits
2657 Mode 0x0345: 1600x1200 (+1600), 8 bits
2658 Mode 0x0346: 1600x1200 (+3200), 16 bits
2659 Mode 0x034d: 1400x1050 (+2816), 16 bits
2660 Mode 0x035c: 1400x1050 (+5632), 24 bits
2662 <a name="209"></a><hr />
2664 Portscan using netcat:
2666 # netcat -v -w2 <host|ip-addr.> 1-1024
2668 <a name="210"></a><hr />
2670 Run apt-get but disable apt-listchanges:
2672 APT_LISTCHANGES_FRONTEND=none apt-get ...
2674 Upgrade system but disable apt-listbugs:
2676 APT_LISTBUGS_FRONTEND=none apt-get ...
2678 <a name="211"></a><hr />
2680 Set up a Transparent Debian Proxy
2682 Install of apt-cacher, the default config will do:
2683 # apt-get install apt-cacher
2685 Check out the ip address of debian mirror(s).
2686 Then add this to your firewall script:
2688 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2689 for ip in ${DEBIAN_MIRRORS} ; do
2690 ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2693 where ${IPTABLES} is the location of your iptables binary
2694 and $subnet is your internal subnet.
2696 Now everybody in your subnet who does access either
2697 ftp.de.debian.org or ftp.at.debian.org will actually
2698 access your apt-cacher instead.
2700 To use apt-cacher on the router itself, add the following
2701 line to your /etc/apt/apt.conf:
2703 Acquire::http::Proxy "http://localhost:3142/";
2705 <a name="212"></a><hr />
2707 Version control using Mercurial
2709 Setting up a Mercurial project:
2712 % hg init # creates .hg
2713 % hg add # add all files
2714 % hg commit # commit all changes, edit changelog entry
2716 Branching and merging:
2718 % hg clone linux linux-work # create a new branch
2720 <make changes>
2723 % hg pull ../linux-work # pull changesets from linux-work
2724 % hg merge # merge the new tip from linux-work into
2725 # (old versions used "hg update -m" instead)
2726 # our working directory
2727 % hg commit # commit the result of the merge
2731 % cat ../p/patchlist | xargs hg import -p1 -b ../p
2739 % hg export 1234 > foo.patch # export changeset 1234
2741 Export your current repo via HTTP with browsable interface:
2743 % hg serve -n "My repo" -p 80
2745 Pushing changes to a remote repo with SSH:
2747 % hg push ssh://user@example.com/~/hg/
2749 Merge changes from a remote machine:
2751 host1% hg pull http://foo/
2752 host2% hg merge # merge changes into your working directory
2754 Set up a CGI server on your webserver:
2755 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
2756 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
2758 Mercurial repositories of grml can be found at http://hg.grml.org/
2760 <a name="213"></a><hr />
2762 Download binary codecs for mplayer:
2764 # /usr/share/mplayer/scripts/win32codecs.sh
2768 # /usr/share/mplayer/scripts/binary_codecs.sh install
2770 (depending on the mplayer version you have).
2772 To play encrypted DVDs and if you are living in a country where using
2773 libdvdcss code is not illegal can install Debian package libdvdread3
2774 and use the script /usr/share/doc/libdvdread3/install-css.sh.
2776 <a name="214"></a><hr />
2778 Read manpages of uninstalled packages with debman:
2780 % debman -p git-core git
2782 <a name="215"></a><hr />
2784 Test network performance using netperf:
2790 # netperf -t TCP_STREAM -H 192.168.0.41
2792 <a name="216"></a><hr />
2794 Setup Xen within 20 minutes on Debian/grml
2796 Install relevant software und update grub's menu.lst (Xen does not work with
2797 usual lilo so install grub instead if not done already):
2799 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
2802 Example for installation of Debian etch as DomU:
2805 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/
2809 /etc/init.d/xend start
2810 /etc/init.d/xendomains start
2812 Setup a bridge for network, either manually:
2814 brctl addbr xenintbr
2815 brctl stp xenintbr off
2816 brctl sethello xenintbr 0
2817 brctl setfd xenintbr 0
2818 ifconfig xenintbr 192.168.1.1 netmask 255.255.255.0 up
2820 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
2824 iface xenintbr inet static
2825 pre-up brctl addbr xenintbr
2826 post-down brctl delbr xenintbr
2828 netmask 255.255.255.0
2833 Setup forwarding (adjust $PUBLIC_IP; for permanet setup use /etc/sysctl.conf and
2834 add the iptables commands to a startup script like /etc/init.d/rc.local):
2836 echo 1 > /proc/sys/net/ipv4/ip_forward
2837 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to $PUBLIC_IP
2838 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $PUBLIC_IP
2840 Adjust network configuration of Xend:
2842 cat >> /etc/xen/xend-config.sxp << EOF
2843 (network-script network-route)
2844 (vif-bridge xenintbr)
2845 (vif-script vif-bridge)
2848 List domains, start up a DomU, shutdown later again:
2850 xm create -c /etc/xen/xengrml1.cfg
2854 This HowTo is also available online at http://grml.org/xen/
2856 <a name="217"></a><hr />
2858 Play tetris with zsh:
2862 bindkey "^Xt" tetris
2864 Now press 'ctrl-x t'.
2866 <a name="218"></a><hr />
2868 Set up a router with grml
2870 Run grml-router script:
2873 Install dnsmasq if not already present:
2874 # apt-get update ; apt-get install dnsmasq
2876 Adjust /etc/dnsmasq.conf according to your needs:
2877 # cat >> /etc/dnsmasq.conf << EOF
2880 dhcp-range=19.168.0.124,192.168.0.254,1m # dhcp range
2881 dhcp-option=3,192.168.0.1 # dns server
2882 dhcp-option=1,255.255.255.0 # netmask
2885 Start dnsmasq finally:
2888 <a name="219"></a><hr />
2890 Display stats about memory allocations performed by a program:
2892 Usage example for 'ls':
2894 % LD_PRELOAD=/lib/libmemusage.so ls > /dev/null
2896 <a name="220"></a><hr />
2898 Use KVM (Kernel-based Virtual Machine for Linux):
2900 Make sure to install the relevant tools:
2901 # apt-get update ; apt-get install kvm
2904 Test it with a minimal system like ttylinux:
2905 # wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz
2906 # gzip -d bootcd-i386-5.3.iso.gz
2907 # kvm -cdrom bootcd-i386-5.3.iso
2909 <a name="221"></a><hr />
2911 EEPROM data decoding for SDRAM DIMM modules:
2914 # /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl
2916 <a name="222"></a><hr />
2920 Make sure your device is supported by Linux and running.
2921 See http://www.linuxtv.org/ for more details.
2923 If the DVB device works on your system (see 'hwinfo --usb'
2924 when using a DVB usb device for example), then make sure you
2925 have the scan util from dvb-utils available:
2927 # aptitude install dvb-utils
2929 Then create a channels.conf configuration file:
2931 % scan /usr/share/doc/dvb-utils/examples/scan/... > ~/.mplayer/channels.conf
2933 You can find some example configuration files on
2934 your grml system in ~/.channels. Usage example:
2936 % ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf
2938 Tip: w_scan (see http://free.pages.at/wirbel4vdr/w_scan/index2.html)
2939 might be useful if you do not know the initial configuration
2942 <a name="223"></a><hr />
2944 Get the lastest mercurial snapshot:
2946 Make sure you have the python-dev package available:
2947 # apt-get update ; apt-get install python-dev
2949 Get and build the source:
2950 % hg clone http://selenic.com/repo/hg mercurial
2953 % export PYTHONPATH=$(pwd)
2954 % export PATH=$PATH:$(pwd)
2956 now you should have the newest version of mercurial whenever you execute hg.
2958 To update to the lastest development snapshot, additionally use
2959 the following commands:
2960 % hg pull -u http://hg.intevation.org/mercurial/crew
2963 <a name="224"></a><hr />
2968 Available bootoptions relevant in live-cd mode:
2969 -----------------------------------------------
2971 * utc: set UTC, if your system clock is set to UTC (GMT)
2972 * gmt: set UTC, if your system clock is set to UTC (GMT) [like bootoption utc]
2973 * tz=$option: set timezone to corresponding $option, usage example:
2976 Configuration options relevant on harddisk installation:
2977 --------------------------------------------------------
2979 * Use the tzconfig utility to set the local timezone:
2983 which adjusts /etc/timezone and /etc/localtime according
2984 to the provided information. Running:
2986 # dpkg-reconfigure tzdata
2988 might be useful as well.
2990 * /etc/default/rcS: set variable UTC according to your needs,
2991 whether your system clock is set to UTC (UTC='yes') or
2994 * /etc/localtime: adjust zoneinfo according to your needs:
2996 # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime
2998 The zoneinfo directory contains the time zone files that were
2999 compiled by zic. The files contain information such as rules
3000 about DST. They allow the kernel to convert UTC UNIX time into
3001 appropriate local dates and times. Use the zdump utility to
3002 print current time and date (in the specified time zone).
3004 * /etc/adjtime: This file is used e.g. by the adjtimex function,
3005 which can smoothly adjust system time while the system runs
3007 * If you change the time (using 'date --set ...', ntpdate,...)
3008 it is worth setting also the hardware clock to the correct time:
3010 # hwclock --systohc [--utc]
3012 Remember to add the --utc -option if the hardware clock is set
3018 Check your current settings via:
3021 zdump /etc/localtime
3024 grep hwclock /etc/runlevel.conf
3025 grep '^UTC' /etc/default/rc
3027 Further information:
3028 --------------------
3030 hwclock(8) tzselect(1) tzconfig(8)
3031 http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html
3032 http://wiki.debian.org/TimeZoneChanges
3034 <a name="225"></a><hr />
3036 Recorder shellscript session using script:
3038 % script -t 2>~/upgrade.time -a ~/upgrade.script
3039 % scriptreplay ~/upgrade.time ~/upgrade.script
3041 <a name="226"></a><hr />
3043 Test UTF-8 capabilities of terminal:
3045 wget http://melkor.dnp.fmph.uniba.sk/~garabik/debian-utf8/download/UTF-8-demo.txt.gz
3046 zcat UTF-8-demo.txt.gz
3050 wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
3053 <a name="227"></a><hr />
3055 UTF-8 at grml / some general information regarding Unicde/UTF-8:
3057 http://wiki.grml.org/doku.php?id=utf8
3059 <a name="228"></a><hr />
3062 This allows one ssh connection attepmt per minute per source ip, with a initial
3063 burst of 10. The available burst is like a counter which is initialised with
3064 10. Every connection attempt decrements the counter, and every minute where the
3065 connection limit of one per minute is not overstepped the counter is
3066 incremented by one. If the burst counter is exhausted the real rate limit
3067 comes into play. This gives you 11 connectionattepmts in the first minute
3068 before blocked for 10minutes. After 10 minutes block the game restarts.
3070 Hint: you could set the burst value to 5 and the block time to only 5 minutes
3071 to achive the same average connection rate but with halve the block time.
3073 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
3074 iptables -A inet_in -p tcp --dport 22 -m state --state NEW -j REJECT
3076 <a name="229"></a><hr />
3078 Tunnel a specific connection via socat:
3081 % socat TCP4-LISTEN:8003 TCP4:gateway:500
3084 # socat TCP4-LISTEN:500,fork TCP4:target:$PORT
3086 Using localhost:8003 on the client uses the tunnel now.
3088 <a name="230"></a><hr />
3092 # date --set=060916102007
3094 where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4)
3096 Set date using a relative date:
3102 # date -s '+tomorrow'
3104 Display a specific relative date:
3106 # date -d '+5 days -2 hours'
3108 Don't forget to set hardware clock via:
3112 <a name="231"></a><hr />
3114 Booting grml via network / PXE:
3116 Start grml-terminalserver on a system with network access
3117 and where grml is running:
3119 # grml-terminalserver
3121 Then booting your client(s) via PXE should work without
3124 See: man grml-terminalserver + http://grml.org/terminalserver/
3126 <a name="232"></a><hr />
3128 Debugging SSL communications:
3130 % openssl s_client -connect server.adress:993
3134 # ssldump -a -A -H -i eth0
3136 See http://prefetch.net/articles/debuggingssl.html for more details.
3138 <a name="233"></a><hr />
3140 Remove bootmanager from MBR:
3142 # lilo -M /dev/hda -s /dev/null
3144 <a name="234"></a><hr />
3146 Rewrite grub to MBR:
3149 # grub-install --recheck --no-floppy --root-directory=/mnt/sda1 /dev/sda
3151 <a name="235"></a><hr />
3153 Rewrite lilo to MBR:
3158 <a name="236"></a><hr />
3160 Create screenshot of plain/real console - tty1:
3162 # fbgrab -c 1 screeni.png
3164 <a name="237"></a><hr />
3166 Create screenshot when running X:
3170 Tip: use the gkrellshoot plugin when using gkrellm
3172 <a name="238"></a><hr />
3174 Redirect all connections to hostA:portA to hostB:portB, where hostA and hostB are
3177 Run the following commands on hostA:
3179 echo 1 > /proc/sys/net/ipv4/ip_forward
3180 iptables -t nat -A PREROUTING -p tcp --dport portA -j DNAT --to hostB:portB
3181 iptables -A FORWARD -i eth0 -o eth0 -d hostB -p tcp --dport portB -j ACCEPT
3182 iptables -A FORWARD -i eth0 -o eth0 -s hostB -p tcp --sport portB -j ACCEPT
3183 iptables -t nat -A POSTROUTING -p tcp -d hostB --dport portB -j SNAT --to-source hostA
3185 <a name="239"></a><hr />
3187 Flash BIOS without DOS/Windows:
3189 Dump flash info and set the flash chip to writable:
3192 Backup the original BIOS:
3193 # flashrom -r backup.bin
3195 Notice: the following step will overwrite your current BIOS!
3196 So make sure you really know what you are doing.
3198 Flash the BIOS image:
3199 # flashrom -wv newbios.bin
3201 Also check out LinuxBIOS: http://linuxbios.org/
3203 <a name="240"></a><hr />
3205 Enable shadow passwords:
3209 <a name="241"></a><hr />
3211 Set up an IPv6 tunneln on grml:
3215 <a name="242"></a><hr />
3217 Set up console newsreader slrn for use with Usenet:
3221 <a name="243"></a><hr />
3223 Calculate with IPv6 addresses:
3227 For usage examples refer to manpage ipv6calc(8).
3229 <a name="244"></a><hr />
3231 Common network debugging tools for use with IPv6:
3240 <a name="245"></a><hr />
3242 Set up NFS (Network File System):
3246 Make sure the relevant services are running on the server side:
3248 # /etc/init.d/portmap start
3249 # /etc/init.d/nfs-common start
3250 # /etc/init.d/nfs-kernel-server start
3252 Export shares via /etc/exports:
3254 /backups 192.168.1.100/24(rw,wdelay,no_root_squash,async,subtree_check)
3256 ... or manually export a directory running:
3258 # exportfs -o rw,wdelay,no_root_squash,async,subtree_check 192.168.1.100:/backups
3260 and unexport a share running:
3262 # exportfs -u 192.168.1.100:/backups
3264 and every time when you modify /etc/exports file run
3268 Display what NFS components are running:
3272 Display list of exported shares:
3280 Make sure the relevant services are running on the client side:
3282 # /etc/init.d/portmap start
3283 # /etc/init.d/nfs-common start
3285 Verify that the server allows you to access its RPC/NFS services:
3287 # rpcinfo -p server_name
3289 Check what directories the server exports:
3291 # showmount -e server_name
3293 On the client side you can use something like the following in /etc/fstab:
3295 192.168.1.101:/backups /mnt/nfs nfs defaults,users,wsize=8192,rsize=8192 0 0
3297 <a name="246"></a><hr />
3301 # aptitude install cloop-src
3304 # modprobe cloop file=/path/to/cloop/file
3305 # mount -r -t iso9660 /dev/cloop /mnt/test
3307 <a name="247"></a><hr />
3309 Create a PS/PDF of a plaintext file:
3311 % a2ps --medium A4dj -E -o output.ps input_file
3314 <a name="248"></a><hr />
3316 Print two pages on one in a PDF file:
3318 % pdfnup --nup 2x1 input.pdf
3320 Concatenate, extract pages/parts, encrypt/decrypt,
3321 compress PDFs using 'pdftk'.
3323 <a name="249"></a><hr />
3325 Read a PS/PDF file on console:
3329 or on plain framebuffer console in graphical mode:
3331 % pdf2ps file.pdf ; ps2png file.ps file.png ; fbi file.png
3337 <a name="250"></a><hr />
3339 Bypass the password of a PDF file:
3341 % gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c quit
3343 <a name="251"></a><hr />
3349 This will record a AIFF audio file.
3351 <a name="252"></a><hr />
3353 Change passphrase / password of an existing SSH key:
3357 <a name="253"></a><hr />
3359 Enable syntax highlighting in nano:
3361 Just uncomment the include directives for your respective
3362 language at the bottom of the file /etc/nanorc
3364 <a name="254"></a><hr />
3366 Create netboot package for grml-terminalserver:
3368 # sh /usr/share/doc/grml-terminalserver/examples/create-netboot
3370 <a name="255"></a><hr />
3372 To boot grml via network (PXE) check out grml-terminalserver:
3374 # grml-terminalserver
3376 See http://grml.org/terminalserver/ for more details.
3378 <a name="256"></a><hr />
3382 Using the 'Orientation' tag of the Exif header, rotate
3383 the image so that it is upright:
3384 % jhead -autorot *.jpg
3386 Manually rotate a picture:
3387 % convert -rotate 270 input.jpg output.jpg
3389 <a name="257"></a><hr />
3391 Rename files based on the information inside their exif header:
3393 % jhead -n%Y-%m-%d_%Hh%M_%f *.jpg
3395 This will rename a file named img_2071.jpg to something like:
3397 2007-08-17_10h38_img_2071.jpg
3399 if it was shot at 10:38 o'clock on 2007-08-17 (according to
3400 the information inside the exif header).
3402 <a name="258"></a><hr />
3404 Calculate network / netmask:
3407 % ipcalc 10.0.0.28 255.255.255.0
3408 % ipcalc 10.0.0.0/24
3410 <a name="259"></a><hr />
3412 Blacklist a kernel module:
3414 # blacklist <name_of_kernel_module>
3416 -> running 'blacklist hostap_cs' for example will generate an
3417 entry like this in /etc/modprobe.d/grml:
3422 To remove the module from the blacklist again just invoke:
3424 # unblacklist <name_of_kernel_module>
3426 or manually remove the entry from /etc/modprobe.d/grml.
3428 <a name="260"></a><hr />
3430 Create a Debian package of a perl module:
3432 % dh-make-perl --cpan Acme::Smirch --build
3434 <a name="261"></a><hr />
3436 The Magic SysRq Keys (SysReq or Sys Req, short for System Request):
3438 To reboot your system using the SysRq keys just hold down the Alt and
3439 SysRq (Print Screen) key while pressing the keys REISUB ("Raising
3440 Elephants Is So Utterly Boring").
3442 R = take the keyboard out of raw mode
3443 E = terminates all processes (except init)
3444 I = kills all processes (except init)
3445 S = synchronizes the disk(s)
3446 U = remounts all filesystems read-only
3447 B = reboot the system
3449 Notice: use O instead of B for poweroff.
3451 Or write the sequence to /proc/sysrq-trigger instead:
3453 # for i in r e i s u b ; do echo $i > /proc/sysrq-trigger ; done
3455 To enable or disable SysRq calls:
3457 # echo 0 > /proc/sys/kernel/sysrq
3458 # echo 1 > /proc/sys/kernel/sysrq
3460 See http://en.wikipedia.org/wiki/Magic_SysRq_key for more details.
3462 <a name="262"></a><hr />
3466 Just boot your grml Live-CD with "memtest" to execute a memcheck/memtest
3469 <a name="263"></a><hr />
3471 Tunnel TCP-Traffic through DNS using dns2tcp:
3475 1. Create necessary DNS-Records:
3476 dnstun.example.com. 3600 IN NS host.example.com.
3477 dnstun.example.com. 3600 IN A 192.168.1.1
3478 host.example.com. 3600 IN A 192.168.1.1
3480 2. Configure dns2tcpd on host.example.com.:
3481 # cat /etc/dns2tcpd.conf
3482 listen = 192.168.1.1 #the ip dnstun should listen on
3483 port = 53 #" port " " " "
3486 domain = dnstun.example.com. # the zone as specified inside dns
3487 ressources = ssh:127.0.0.1:22 # available resources
3489 3. Start the daemon:
3490 # cat > /etc/default/dns2tcp << EOF
3491 # Set ENABLED to 1 if you want the init script to start dns2tcpd.
3495 # /etc/init.d/dns2tcp start
3499 You have two possibilities:
3500 - Use the DNS inside your network (DNS must allow resolving for external domains)
3501 # grep nameserver /etc/resolv.conf
3502 nameserver 172.16.42.1
3503 # dns2tcpc -z dnstun.example.com 172.16.42.1
3504 Available connection(s) :
3506 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com 172.16.42.1 &
3507 Listening on port : 2222
3508 # ssh localhost -p 2222
3509 user@host.example.com:~#
3511 - Directly contact the endpoint (port 53 UDP must be allowed outgoing)
3512 # dns2tcpc -z dnstun.example.com dnstun.example.com
3513 Available connection(s) :
3515 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com dnstun.example.com &
3516 Listenning on port : 2222
3517 # ssh localhost -p 2222
3518 user@host.example.com:~#
3520 Notice: using 'ssh -D 8080 ..' you will get a socks5-proxy listening on
3521 localhost:8080 which you can use to tunnel everything through your "dns-uplink".
3523 <a name="264"></a><hr />