make urls clickable
[grml.org.git] / tips / index.html
1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2 <head>
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" />
20 </head>
21 <body>
22
23 <a name="0"></a>
24 <pre>
25 Install grml to harddisk:
26
27 # grml2hd
28
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
32
33 See: man grml2hd + http://grml.org/grml2hd/
34 </pre>
35 <a name="1"></a><hr />
36 <pre>
37 Install grml on software RAID level 1:
38
39 Create /dev/md0 (and some more /dev/md* devices) first of all:
40 # cd /dev && MAKEDEV dev
41
42 Create RAID:
43 # mdadm --create --verbose /dev/md0 --level=raid1         --raid-devices=2   /dev/hda1  /dev/hdc1
44
45 Finally install grml on it:
46 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
47
48 See: man grml2hd + http://grml.org/grml2hd/
49 </pre>
50 <a name="2"></a><hr />
51 <pre>
52 Install grml in non interactive mode with grml2hd:
53
54 Adjust configuration as needed:
55 # vim /etc/grml2hd/config
56
57 Then execute:
58
59 # GRML2HD_NONINTERACTIVE=yes grml2hd
60
61 or run:
62
63 # grml2hd -i
64
65 Use with care and only if you really know what you are doing!
66
67 See: man grml2hd + http://grml.org/grml2hd/
68 </pre>
69 <a name="3"></a><hr />
70 <pre>
71 Configure network:
72
73 # grml-network
74 </pre>
75 <a name="4"></a><hr />
76 <pre>
77 Deactivate error correction of zsh:
78
79 % NOCOR=1 zsh
80
81 Run zsh-help for more information regarding zsh.
82 </pre>
83 <a name="5"></a><hr />
84 <pre>
85 Disable automatic setting of title in GNU screen:
86
87 % NOPRECMD=1 zsh
88
89 Set it manually e.g. via:
90
91 % screen -X title foobar
92
93 Run zsh-help for more information regarding zsh.
94 </pre>
95 <a name="6"></a><hr />
96 <pre>
97 Do not use menu completion in zsh:
98
99 % NOMENU=1 zsh
100
101 Run zsh-help for more information regarding zsh.
102 </pre>
103 <a name="7"></a><hr />
104 <pre>
105 Run GNU screen with grml-configuration:
106
107 % grml-screen
108
109 or
110
111 % screen -c /etc/grml/screenrc
112 </pre>
113 <a name="8"></a><hr />
114 <pre>
115 Print out grml-version:
116
117 % grml-version
118 </pre>
119 <a name="9"></a><hr />
120 <pre>
121 Configure mutt:
122
123 % grml-mutt
124 </pre>
125 <a name="10"></a><hr />
126 <pre>
127 Configure mutt-ng / muttng:
128
129 % grml-muttng
130 </pre>
131 <a name="11"></a><hr />
132 <pre>
133 Set up Inode-PPTP connection:
134
135 # grml-pptp-inode
136 or
137 # grml-pptp-xdsl-students
138 </pre>
139 <a name="12"></a><hr />
140 <pre>
141 Set up VPN / WLAN connection at TUG (TU Graz):
142
143 Set ESSID and request for ip-address via DHCP:
144 # iwconfig $DEVICE essid tug
145 # dhclient $DEVICE
146
147 Now run the main script:
148 # grml-vpnc-tugraz
149
150 After running the script an init script is available:
151
152 # /etc/init.d/vpnctug [start|stop]
153 </pre>
154 <a name="13"></a><hr />
155 <pre>
156 Set up PPTP connection at VCG (Virtual Campus Graz):
157
158 # grml-pptp-vcgraz
159 </pre>
160 <a name="14"></a><hr />
161 <pre>
162 Set up VPN:
163
164 # grml-vpn &lt;options&gt;
165
166 Usage example:
167
168 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
169
170 See: man grml-vpn
171 </pre>
172 <a name="15"></a><hr />
173 <pre>
174 Use encrypted files / partitions:
175
176 # grml-crypt &lt;options&gt;
177
178 Usage example:
179
180 Initialize:
181
182 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
183 # cp big_file /mnt/test
184 # grml-crypt stop /mnt/test
185
186 Use:
187
188 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
189 # grml-crypt stop /mnt/test
190
191 See: man grml-crypt
192 </pre>
193 <a name="16"></a><hr />
194 <pre>
195 Change resolution of X:
196
197 % xrandr -s '1024x768'
198 </pre>
199 <a name="17"></a><hr />
200 <pre>
201 Change resolution of framebuffer:
202
203 # fbset 800x600-60
204 </pre>
205 <a name="18"></a><hr />
206 <pre>
207 Configure newsreader slrn:
208
209 % grml-slrn
210 </pre>
211 <a name="19"></a><hr />
212 <pre>
213 Configure grml system:
214
215 # grml-config
216
217 Or directly run scripts:
218
219 # grml-config-root
220 % grml-config-user
221 </pre>
222 <a name="20"></a><hr />
223 <pre>
224 Lock screen (X / console):
225
226 % grml-lock
227
228 Press ctrl-alt-x to lock a GNU screen session.
229 </pre>
230 <a name="21"></a><hr />
231 <pre>
232 Change wallpaper in X:
233
234 % grml-wallpaper &lt;press-tab&gt;
235 </pre>
236 <a name="22"></a><hr />
237 <pre>
238 Start X window system (XFree86 / Xorg / X.org):
239
240 % grml-x $WINDOWMANAGER
241
242 Usage examples:
243
244 % grml-x fluxbox
245 % grml-x -mode '1024x768' wmii
246 % grml-x -nosync wm-ng
247 </pre>
248 <a name="23"></a><hr />
249 <pre>
250 Collect hardware information:
251
252 % grml-hwinfo
253
254 or run as root to collect some more information:
255
256 # grml-hwinfo
257
258 will generate a file named info.tar.bz2.
259 </pre>
260 <a name="24"></a><hr />
261 <pre>
262 Configure hardware detection features of harddisk installation:
263
264 # grml-autoconfig
265
266 or manually edit /etc/grml/autoconfig[.small]
267
268 See: man grml-autoconfig
269 </pre>
270 <a name="25"></a><hr />
271 <pre>
272 Bootoptions / cheatcodes / bootparams for booting grml:
273
274 On the grml-ISO if not running grml:
275 % less /cdrom/GRML/grml-cheatcodes.txt
276
277 When running grml:
278 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
279 </pre>
280 <a name="26"></a><hr />
281 <pre>
282 Report bugs to Debian's Bug Tracking System (BTS):
283
284 % reportbug --bts debian
285
286 or adjust /etc/reportbug.conf to your needs.
287
288 See:
289
290   http://grml.org/bugs/
291   http://www.debian.org/Bugs/
292 </pre>
293 <a name="27"></a><hr />
294 <pre>
295 Offline documentation:
296
297 % grml-info
298
299 Online documentation:
300
301   http://grml.org/faq/
302   http://grml.org/docs/
303   http://wiki.grml.org/doku.php
304 </pre>
305 <a name="28"></a><hr />
306 <pre>
307 Mount ntfs partition (read-write):
308
309 # modprobe fuse
310 # ntfsmount /dev/hda1 /mnt/hda1
311 </pre>
312 <a name="29"></a><hr />
313 <pre>
314 Overwrite specific file on an NTFS partition:
315
316 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
317 </pre>
318 <a name="30"></a><hr />
319 <pre>
320 Resize an NTFS partition:
321
322 # ntfsresize ..
323
324 Usage example:
325
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)
329 </pre>
330 <a name="31"></a><hr />
331 <pre>
332 Modify resolution for intel graphic chipsets:
333
334 # 915resolution ..
335
336 Usage example:
337
338 # 915resolution 4d 1400 1050
339 </pre>
340 <a name="32"></a><hr />
341 <pre>
342 Connect bluetooth mouse:
343
344 # bt-hid start
345
346 ... and press 'connect' button on your bluetooth device.
347 </pre>
348 <a name="33"></a><hr />
349 <pre>
350 Connect bluetooth headset:
351
352 # bt-audio start
353
354 ... and press 'connect' button on your bluetooth device.
355 </pre>
356 <a name="34"></a><hr />
357 <pre>
358 Secure delete file / directory / partition:
359
360 # wipe -kq /dev/hda1
361
362 See: man wipe
363
364 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
365 </pre>
366 <a name="35"></a><hr />
367 <pre>
368 Use grml on Samsung X20 laptop:
369
370 # apt-get install grml-samsung-x20
371
372 See: http://www.michael-prokop.at/computer/samsung_x20.html
373 </pre>
374 <a name="36"></a><hr />
375 <pre>
376 Development information regarding grml:
377
378   http://blog.grml.org/
379 </pre>
380 <a name="37"></a><hr />
381 <pre>
382 Contact grml team:
383
384 #grml on irc.freenode.org - http://grml.org/irc/
385 http://grml.org/contact/
386 </pre>
387 <a name="38"></a><hr />
388 <pre>
389 Join the grml mailinglist:
390
391 http://grml.org/mailinglist/
392 </pre>
393 <a name="39"></a><hr />
394 <pre>
395 Help us - donate!
396
397 http://grml.org/donations/
398 </pre>
399 <a name="40"></a><hr />
400 <pre>
401 Commercial support / system administration / adjusted live-cds:
402
403 grml-solutions: http://grml.org/solutions/
404 </pre>
405 <a name="41"></a><hr />
406 <pre>
407 Information regarding the kernel provided by grml:
408
409   http://grml.org/kernel/
410 </pre>
411 <a name="42"></a><hr />
412 <pre>
413 SMTP command-line test tool:
414
415 % swaks &lt;options&gt;
416
417 Usage example:
418
419 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
420
421 See: man swaks
422 </pre>
423 <a name="43"></a><hr />
424 <pre>
425 NTFS related packages:
426
427 scrounge-ntfs
428 salvage-ntfs
429 ntfsprogs
430 </pre>
431 <a name="44"></a><hr />
432 <pre>
433 Modify service through init script:
434
435 # Start ssh
436 # Stop samba
437 # Restart apache
438 # Reload postfix
439 # service gpm start
440 # /etc/init.d/lvm start
441 </pre>
442 <a name="45"></a><hr />
443 <pre>
444 Test joystick:
445
446 # jstest /dev/input/js0
447 </pre>
448 <a name="46"></a><hr />
449 <pre>
450 Play movie:
451
452 % mplayer /path/to/movie
453 </pre>
454 <a name="47"></a><hr />
455 <pre>
456 Use webcam with mplayer:
457
458 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
459 </pre>
460 <a name="48"></a><hr />
461 <pre>
462 Powerful network discovery tool:
463
464 # scapy
465 </pre>
466 <a name="49"></a><hr />
467 <pre>
468 Grab an entire CD and compress it to Ogg/Vorbis,
469 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
470
471 % abcde
472 </pre>
473 <a name="50"></a><hr />
474 <pre>
475 Show a console session in several terminals:
476
477 % gems
478 </pre>
479 <a name="51"></a><hr />
480 <pre>
481 Switch behaviour of caps lock key:
482
483 % caps-ctrl
484 </pre>
485 <a name="52"></a><hr />
486 <pre>
487 grep with Perl-compatible regular expressions:
488
489 % pcregrep
490 </pre>
491 <a name="53"></a><hr />
492 <pre>
493 ncp: a fast file copy tool for LANs
494
495 Local (send file):
496 % npush file_to_copy
497
498 Remote (receive file):
499 % npoll
500 </pre>
501 <a name="54"></a><hr />
502 <pre>
503 utility for sorting records in complex ways:
504
505 % msort
506 </pre>
507 <a name="55"></a><hr />
508 <pre>
509 a smaller, cheaper, faster SED implementation:
510
511 % minised
512 </pre>
513 <a name="56"></a><hr />
514 <pre>
515 zsh tips:
516
517 % man zsh-lovers
518
519 See: http://grml.org/zsh/
520 </pre>
521 <a name="57"></a><hr />
522 <pre>
523 zsh reference card for grml system:
524
525 http://grml.org/zsh/
526 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
527 </pre>
528 <a name="58"></a><hr />
529 <pre>
530 Multiple rename:
531
532 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
533 % qmv foo*
534 % prename 's/foo/bar/' foo*
535 % mmv "foo*"   "bar#1"
536 % zmv 'foo(*)' 'bar$1'
537 </pre>
538 <a name="59"></a><hr />
539 <pre>
540 Test TFT / LCD display:
541
542 % lcdtest
543 </pre>
544 <a name="60"></a><hr />
545 <pre>
546 Test sound:
547
548 % soundtest
549 </pre>
550 <a name="61"></a><hr />
551 <pre>
552 Improved grep version:
553
554 % glark
555 </pre>
556 <a name="62"></a><hr />
557 <pre>
558 Grep with highlighting:
559
560 % grep --color=auto ...
561 % hgrep ...
562 </pre>
563 <a name="63"></a><hr />
564 <pre>
565 Extract matches when grepping:
566
567 Usage examples:
568 % ifconfig | grepc 'inet addr:(.*?)s'
569 % ifconfig | glark --extract-matches 'inet addr:(.*?)s'
570 </pre>
571 <a name="64"></a><hr />
572 <pre>
573 Output text as sound:
574
575 % say 'ghroummel'
576 % xsay            # when running X and text selected via mouse
577 </pre>
578 <a name="65"></a><hr />
579 <pre>
580 Adjust a grml harddisk (grml2hd) installation:
581
582 # grml2hd-utils
583 </pre>
584 <a name="66"></a><hr />
585 <pre>
586 Get information on movie files:
587
588 % tcprobe -i file.avi
589 </pre>
590 <a name="67"></a><hr />
591 <pre>
592 Get an overview of your image files:
593
594 % convert 'vid:*.jpg' thumbnails.jpg
595 </pre>
596 <a name="68"></a><hr />
597 <pre>
598 List all standard defines:
599
600 % gcc -dM -E - &lt; /dev/null
601 </pre>
602 <a name="69"></a><hr />
603 <pre>
604 Send a mail as reminder:
605
606 echo "mail -s 'check TODO-list' $MAILADDRESS &lt; /dev/null" | at 23:42
607 </pre>
608 <a name="70"></a><hr />
609 <pre>
610 ncurses-based presentation tool:
611
612 % tpp
613
614 See: man tpp and /usr/share/doc/tpp/examples/
615 </pre>
616 <a name="71"></a><hr />
617 <pre>
618 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
619
620 % centericq
621 </pre>
622 <a name="72"></a><hr />
623 <pre>
624 Use IRC on command line:
625
626 % irssi
627 </pre>
628 <a name="73"></a><hr />
629 <pre>
630 Diff / merge files:
631
632 % vimdiff file1 file2
633
634 Re-diffing:
635
636 :diffupdate
637
638 Moving between diffs:
639
640 [c
641 ]c
642
643 Synchronizing:
644
645 :diffget
646 :diffput
647 </pre>
648 <a name="74"></a><hr />
649 <pre>
650 Hardware monitoring without kernel dependencies:
651
652 % mbmon
653 </pre>
654 <a name="75"></a><hr />
655 <pre>
656 Install grml-iso to usb-stick:
657
658 % grml2usb grml.iso /mount/point
659 </pre>
660 <a name="76"></a><hr />
661 <pre>
662 Use mplayer on framebuffer console:
663
664 % mplayer -vo fbdev ...
665 </pre>
666 <a name="77"></a><hr />
667 <pre>
668 Use links2 on framebuffer console:
669
670 % links2 -driver fb ...
671 </pre>
672 <a name="78"></a><hr />
673 <pre>
674 Switch language / keyboard:
675
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'
679
680 Or run one of the following commands:
681
682 % grml-lang de
683 or
684 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
685 % setxkbmap de                                      # X11
686 </pre>
687 <a name="79"></a><hr />
688 <pre>
689 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
690
691 # caps-ctrl
692 </pre>
693 <a name="80"></a><hr />
694 <pre>
695 Mount usb device / usb stick:
696
697 % mount /mnt/external1   # corresponds to /dev/sda1
698 or
699 % mount /mnt/external    # corresponds to /dev/sda
700 </pre>
701 <a name="81"></a><hr />
702 <pre>
703 Install Sun Java packages:
704
705 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
706
707 # apt-get install java-package
708 # fakeroot make-jpkg j2re-*.bin
709 # dpkg -i sun-j2re*.deb
710 # update-alternatives --config java
711 </pre>
712 <a name="82"></a><hr />
713 <pre>
714 Improved dd version:
715
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
718 like dd will fail.
719
720 % ddrescue ...
721
722 See: man ddrescue
723 </pre>
724 <a name="83"></a><hr />
725 <pre>
726 How to make an audio file (e.g. Musepack format) out of a DVD track:
727
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
731
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.
734
735 Alternative:
736
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')
739
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
742 </pre>
743 <a name="84"></a><hr />
744 <pre>
745 Create simple chroot:
746
747 # make_chroot_jail $USERNAME
748 </pre>
749 <a name="85"></a><hr />
750 <pre>
751 Convert DOS formated file to unix format:
752
753 sed 's/.$//'    dosfile &gt; unixfile       # assumes that all lines end with CR/LF
754 sed 's/^M$//'   dosfile &gt; unixfile       # in bash/tcsh, press Ctrl-V then Ctrl-M
755 sed 's/x0D$//' dosfile &gt; 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 &gt;outfile  # in DOS environment; cannot be done with
758                                          # DOS versions of awk, other than gawk
759 tr -d r &lt; dosfile &gt; unixfile            # GNU tr version 1.22 or higher
760 tr -d '015' &lt; dosfile &gt; unixfile        # use octal value for "r" (see man ascii)
761 tr -d '[015032]' &lt; dosfile &gt; 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" &gt; dos2unix.sed; sed -f dos2unix.sed &lt; dosfile > unixfile
766 </pre>
767 <a name="86"></a><hr />
768 <pre>
769 Save live audio stream to file:
770
771 % mplayer -ao pcm:file=$FILE
772
773 or
774
775 % mencoder mms://file.wmv -o $FILE -ovc copy -oac copy
776
777 or
778
779 % mimms mms://file.wmv
780 </pre>
781 <a name="87"></a><hr />
782 <pre>
783 Merge video files:
784
785 AVI:
786
787 % avimerge -i *.avi -o blub.avi
788
789 MPEG:
790
791 % cat *.mpg &gt; blub.mpg
792
793 WMV:
794
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
798 </pre>
799 <a name="88"></a><hr />
800 <pre>
801 Display MS-Word file:
802
803 % strings file.doc | fmt | less
804
805 or
806
807 % antiword file.doc
808 </pre>
809 <a name="89"></a><hr />
810 <pre>
811 Convert MS-Word file to postscript:
812
813 % antiword -p a4 file.doc &gt; file.ps
814 </pre>
815 <a name="90"></a><hr />
816 <pre>
817 Convert manual to postscript:
818
819 % zcat /usr/share/man/man1/zsh.1.gz | groff -man &gt; zsh.1.ps
820 or
821 % man -t zsh &gt; zsh.ps
822 </pre>
823 <a name="91"></a><hr />
824 <pre>
825 Read BIOS:
826
827 % dd if=/dev/mem bs=1k skip=768 count=256 2&gt;/dev/null | strings -n 8
828 </pre>
829 <a name="92"></a><hr />
830 <pre>
831 Read HTTP via netcat:
832
833 echo "GET / HTTP/1.0rnrn" | netcat $DOMAIN 80
834 </pre>
835 <a name="93"></a><hr />
836 <pre>
837 Get X ressources for specific program:
838
839 % xrdb -q |grep -i xterm
840 </pre>
841 <a name="94"></a><hr />
842 <pre>
843 Get windowid of specific X-window:
844
845 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
846 </pre>
847 <a name="95"></a><hr />
848 <pre>
849 Get titel of specific X-window:
850
851 % xprop WM_CLASS
852 </pre>
853 <a name="96"></a><hr />
854 <pre>
855 check locale - LC_MESSAGES:
856
857 % locale -ck LC_MESSAGES
858 </pre>
859 <a name="97"></a><hr />
860 <pre>
861 Create random password:
862
863 % pwgen
864 or
865 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
866 </pre>
867 <a name="98"></a><hr />
868 <pre>
869 Get tarballs of various Linux Kernel trees:
870
871 % ketchup 2.6
872 to get the current stable 2.6 release
873
874 % ketchup -l
875 to get a list of all supported trees
876 </pre>
877 <a name="99"></a><hr />
878 <pre>
879 Transfer your SSH public key to another host:
880
881 % ssh-keygen   # ssh-keygen / ssh-key-gen: if you don't have a key yet
882 [...]
883 % ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
884 or
885 % cat $HOME/.ssh/id_rsa.pub  | ssh user@remote-system 'cat &gt;> .ssh/authorized_keys'
886 </pre>
887 <a name="100"></a><hr />
888 <pre>
889 Update /etc/fstab entries:
890
891 # grml-rebuildfstab
892
893 See "man grml-rebuildfstab" for more details about
894 generation of /etc/fstab (including stuff like
895 fs LABELs / UUIDs,...).
896 </pre>
897 <a name="101"></a><hr />
898 <pre>
899 Fetch and potentially change SCSI device parameters:
900
901 # sdparm /dev/sda
902
903 See: man sdparm
904 </pre>
905 <a name="102"></a><hr />
906 <pre>
907 reclaim disk space by linking identical files together:
908
909 % dupmerge...
910 </pre>
911 <a name="103"></a><hr />
912 <pre>
913 Find and remove duplicate files:
914
915 % dupseek ...
916 </pre>
917 <a name="104"></a><hr />
918 <pre>
919 Perform layer 2 attacks:
920
921 # yersinia ...
922 </pre>
923 <a name="105"></a><hr />
924 <pre>
925 rootsh
926 </pre>
927 <a name="106"></a><hr />
928 <pre>
929 Guess PC-type hard disk partitions / partition table:
930
931 # gpart &lt;options&gt;
932
933 Perform a standard scan:
934 # gpart /dev/ice
935
936 Write back the guessed table:
937 # gpart -W /dev/ice /dev/ice
938 </pre>
939 <a name="107"></a><hr />
940 <pre>
941 Develop, test and use exploit code with the Metasploit Framework:
942
943 cd /tmp
944 wget http://framework-mirrors.metasploit.com/msf/downloader/framework-3.0.tar.gz
945 unp framework-3.0.tar.gz
946 cd framework-3.0
947 ./msfcli
948 </pre>
949 <a name="108"></a><hr />
950 <pre>
951 Useful documentation:
952
953 % w3m   /usr/share/doc/Debian/reference/reference.en.html
954 or
955 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
956
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
964
965 Tips and tricks:
966
967 % fortune debian-hints
968 </pre>
969 <a name="109"></a><hr />
970 <pre>
971 Fun stuff:
972
973 % fortune debian-hints
974 % dpkg -L funny-manpages
975 </pre>
976 <a name="110"></a><hr />
977 <pre>
978 Backup master boot record (MBR):
979
980 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
981 </pre>
982 <a name="111"></a><hr />
983 <pre>
984 Backup partition table:
985
986 # sfdisk -d /dev/hda &gt; hda.out
987
988 Restore partition table:
989
990 # sfdisk /dev/hda &lt; hda.out
991 </pre>
992 <a name="112"></a><hr />
993 <pre>
994 Clone disk via network using netcat:
995
996 Listener:
997 # nc -vlp 30000 &gt; hda1.img
998 Source:
999 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
1000
1001 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
1002 to tune speed:
1003
1004 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
1005 </pre>
1006 <a name="113"></a><hr />
1007 <pre>
1008 Backup specific directories via cpio and ssh:
1009
1010 # for f in directory_list; do find $f &gt;> backup.list done
1011 # cpio -v -o --format=newc &lt; backup.list | ssh user@host "cat &gt; backup_device"
1012 </pre>
1013 <a name="114"></a><hr />
1014 <pre>
1015 Clone disk via ssh:
1016
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
1020
1021 This one uses CPU cycles on the local server to compare the files:
1022 # ssh target_address cat &lt;localfile "|" diff - remotefile
1023 </pre>
1024 <a name="115"></a><hr />
1025 <pre>
1026 Useful tools for cloning / backups:
1027
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
1040 </pre>
1041 <a name="116"></a><hr />
1042 <pre>
1043 Use grml as a rescue system:
1044
1045 Different tools:
1046
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
1055
1056 ext2/ext3:
1057
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
1063
1064 ReiserFS/Reiser4:
1065
1066   * reiser4progs: administration utilities for the Reiser4 filesystem
1067   * reiserfsprogs: User-level tools for ReiserFS filesystems
1068
1069 XFS:
1070
1071   * xfsdump: Administrative utilities for the XFS filesystem
1072   * xfsprogs: Utilities for managing the XFS filesystem
1073
1074 JFS:
1075
1076   * jfsutils: utilities for managing the JFS filesystem
1077
1078 NTFS:
1079
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
1084 </pre>
1085 <a name="117"></a><hr />
1086 <pre>
1087 Get ASCII value of a character with zsh:
1088
1089 % char=N ; print $((#char))
1090 </pre>
1091 <a name="118"></a><hr />
1092 <pre>
1093 Convert a collection of mp3 files to wave or cdr using zsh:
1094
1095 % for i (./*.mp3){mpg321 --w - $i &gt; ${i:r}.wav}
1096 </pre>
1097 <a name="119"></a><hr />
1098 <pre>
1099 Convert images (foo.gif to foo.png) using zsh:
1100
1101 % for i in **/*.gif; convert $i $i:r.png
1102 </pre>
1103 <a name="120"></a><hr />
1104 <pre>
1105 Remove all "non txt" files using zsh:
1106
1107 % rm ./^*.txt
1108 </pre>
1109 <a name="121"></a><hr />
1110 <pre>
1111 Remote Shell Using SSH:
1112
1113 remote host:
1114 % ssh -NR 3333:localhost:22 user@yourhost
1115
1116 local host:
1117 % ssh user@localhost -p 3333
1118 </pre>
1119 <a name="122"></a><hr />
1120 <pre>
1121 Reverse Shell with Netcat:
1122
1123 local host:
1124 % netcat -v -l -p 3333 -e /bin/sh
1125
1126 remote host:
1127 % netcat 192.168.0.1 3333
1128 </pre>
1129 <a name="123"></a><hr />
1130 <pre>
1131 Reverse Shell via SSH:
1132
1133 local host (inside the network):
1134 % ssh -NR 1234:localhost:22 remote_host
1135
1136 remote host (outside the network):
1137 % ssh localhost -p 1234
1138 </pre>
1139 <a name="124"></a><hr />
1140 <pre>
1141 Remove empty directories with zsh:
1142
1143 % rmdir ./**/*(/od) 2&gt; /dev/null
1144 </pre>
1145 <a name="125"></a><hr />
1146 <pre>
1147 Find all the empty directories in a tree with zsh:
1148
1149 % ls -ld *(/^F)
1150 </pre>
1151 <a name="126"></a><hr />
1152 <pre>
1153 Find all files without a valid owner and change ownership with zsh:
1154
1155 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(&lt;/etc/passwd)"}%%:*}:)
1156 </pre>
1157 <a name="127"></a><hr />
1158 <pre>
1159 Display the 5-10 last modified files with zsh:
1160
1161 % print -rl -- /path/to/dir/**/*(D.om[5,10])
1162 </pre>
1163 <a name="128"></a><hr />
1164 <pre>
1165 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
1166
1167 % print -rl -- **/*(Dom[1,10])
1168 </pre>
1169 <a name="129"></a><hr />
1170 <pre>
1171 Find most recent file in a directory with zsh:
1172
1173 % setopt dotglob ; print directory/**/*(om[1])
1174 </pre>
1175 <a name="130"></a><hr />
1176 <pre>
1177 Tunnel all traffic through an external server:
1178
1179 % ssh -ND 3333 username@external.machine
1180
1181 Then set the SOCKS4/5 proxy to localhost:3333.
1182 Check whether it's working by surfing e.g. to checkip.dyndns.org
1183 </pre>
1184 <a name="131"></a><hr />
1185 <pre>
1186 Tunnel everything through SSH via tsocks:
1187
1188 set up the SSH proxy on the client side:
1189
1190 % ssh -ND 3333 user@remote.host.example.com
1191
1192 Adjust /etc/tsocks.conf afterwards (delete all other lines):
1193
1194 server = 127.0.0.1
1195 server_port = 3333
1196
1197 For programs who natively support proxying connections (e.g. Mozilla
1198 Firefox) you can now set the proxy address to localhost port 3333.
1199
1200 All other programs which's connections you want to tunnel through your
1201 external host are prefixed with tsocks, e.g.:
1202
1203 % tsocks netcat example.com 80
1204 % tsocks irssi -c irc.quakenet.eu.org -p 6667
1205
1206 If you call tsocks without parameters it executes a shell witht the
1207 LD_PRELOAD environment variable already set and exported.
1208 </pre>
1209 <a name="132"></a><hr />
1210 <pre>
1211 smartctl - control and monitor utility for harddisks using Self-Monitoring,
1212 Analysis and Reporting Technology (SMART):
1213
1214 # smartctl --all /dev/ice
1215
1216 If you want to use smartctl on S-ATA (sata) disks use:
1217
1218 # smartctl -d ata --all /dev/sda
1219
1220 Start offline test:
1221 # smartctl -t offline /dev/ice
1222
1223 Start short test:
1224 # smartctl -t short /dev/ice
1225
1226 Display results of test:
1227 # smartctl -l selftest /dev/ice
1228
1229 Query device information:
1230 # smartctl -i /dev/ice
1231 </pre>
1232 <a name="133"></a><hr />
1233 <pre>
1234 Mount a BSD / Solaris partition:
1235
1236 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
1237
1238 Use ufstype 44bsd  for FreeBSD, NetBSD, OpenBSD (read-write).
1239 Use ufstype ufs2   for &gt;= 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).
1242
1243 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
1244 for more details.
1245 </pre>
1246 <a name="134"></a><hr />
1247 <pre>
1248 Read BIOS (and or BIOS) password:
1249
1250 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
1251 </pre>
1252 <a name="135"></a><hr />
1253 <pre>
1254 Clone one of the kernel trees via git:
1255
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.
1259 </pre>
1260 <a name="136"></a><hr />
1261 <pre>
1262 Mount filesystems over ssh protocol:
1263
1264 % sshfs user@host:/remote_dir /mnt/test
1265
1266 Unmount via:
1267
1268 % fusermount -u /mnt/test
1269
1270 (Notice: requires fuse kernel module)
1271 </pre>
1272 <a name="137"></a><hr />
1273 <pre>
1274 Install Gentoo using grml:
1275
1276 See http://www.gentoo.org/doc/en/altinstall.xml
1277 </pre>
1278 <a name="138"></a><hr />
1279 <pre>
1280 Install (plain) Debian (sarge release) via grml:
1281
1282 Assuming you want to install Debian to sda1:
1283
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...
1301
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!
1304 </pre>
1305 <a name="139"></a><hr />
1306 <pre>
1307 Install (plain) Debian (etch release) via grml
1308
1309 Assuming you want to install Debian to sda1:
1310
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
1320
1321 echo "127.0.0.1       localhost" &gt; /etc/hosts   # adjust /etc/hosts and network:
1322 cat &gt;> /etc/network/interfaces &lt;< EOF
1323 iface lo inet loopback
1324 iface eth0 inet dhcp
1325 auto lo
1326 auto eth0
1327 EOF
1328
1329 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1330 cat &gt;> /etc/fstab &lt;< 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
1336 EOF
1337 passwd             # set password of user root
1338
1339 mkdir /boot/grub   # setup grub
1340 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1341 cat &gt;> /boot/grub/menu.lst &lt;< EOF
1342 title           Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1343 root            (hd0,0)
1344 kernel          /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1345 initrd          /boot/initrd.img-2.6.18-3-686
1346 EOF
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:
1351 &gt; root (hd0,0)
1352 &gt; setup (hd0)
1353 &gt; quit
1354 umount -a # unmount all filesystems in chroot and finally:
1355 exit      # exit the chroot and:
1356 reboot
1357
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:
1360
1361 cat &gt; /etc/lilo.conf &lt;< EOF
1362 # This allows booting from any partition on disks with more than 1024 cylinders.
1363 lba32
1364
1365 # Specifies the boot device
1366 boot=/dev/sda1
1367
1368 # Specifies the device that should be mounted as root.
1369 root=/dev/sda1
1370
1371 # use Debian on software raid:
1372 # raid-extra-boot=mbr-only
1373
1374 install=text
1375 # prompt
1376 timeout=1
1377 map=/boot/map
1378 vga=normal
1379
1380 image=/boot/vmlinuz-2.6.18-grml
1381         label="2.6.18-grml"
1382         #append="...."
1383         read-only
1384         initrd=/boot/initrd.img-2.6.18-grml
1385 EOF
1386
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!
1389 </pre>
1390 <a name="140"></a><hr />
1391 <pre>
1392 Convert files from Unicode / UTF-8 to ISO:
1393
1394 % iconv -c -f utf8 -t iso-8859-15 &lt; utffile &gt; isofile
1395
1396 and vice versa:
1397
1398 % iconv -f iso-8859-15 -t utf8 &lt; isofile &gt; utffile
1399 </pre>
1400 <a name="141"></a><hr />
1401 <pre>
1402 Assign static setup for network cards (eth0 and eth1) via udev:
1403
1404 First method - manual:
1405 ~~~~~~~~~~~~~~~~~~~~~~
1406 Get information for SYSFS address:
1407 # udevinfo -a -p /sys/class/net/eth0/ | grep address
1408
1409 Then create udev rules:
1410 # cat /etc/udev/network.rules
1411 # match eth* stuff:
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"
1416
1417 Now activate the rules:
1418 # cd /etc/udev/rules.d/ && ln -s ../network.rules z35_network.rules
1419
1420 Unload the drivers, restart udev and load the drivers again to activate
1421 the settings.
1422
1423 Second method - automatic:
1424 ~~~~~~~~~~~~~~~~~~~~~~~~~~
1425 Run /lib/udev/write_net_rules shipped with recent udev versions:
1426
1427 # INTERFACE=wlan1 /lib/udev/write_net_rules 00:00:00:00:00:04
1428
1429 This command will create /etc/udev/rules.d/z25_persistent-net.rules containing:
1430
1431 SUBSYSTEM=="net", DRIVER=="?*", SYSFS{address}=="00:00:00:00:00:04", NAME=wlan1
1432
1433 See /usr/share/doc/udev/writing_udev_rules/index.html for more information.
1434 </pre>
1435 <a name="142"></a><hr />
1436 <pre>
1437 Change the suffix from *.sh to *.pl using zsh:
1438
1439 % autoload zmv
1440 % zmv -W '*.sh' '*.pl'
1441 </pre>
1442 <a name="143"></a><hr />
1443 <pre>
1444 Generate SSL certificate:
1445
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
1448
1449 Check certfile:
1450 # openssl x509 -in certfile -text
1451
1452 Verify against CA certificate:
1453 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1454
1455 Generate 2048bit RSA-key:
1456 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1457
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
1460
1461 Show request request.pem:
1462 # openssl req -text -noout -in request.pem
1463
1464 Verify signature of request request.pem:
1465 # openssl req -verify -noout -in request.pem
1466
1467 Generate SHA1 fingerprint (modulo key) of request.pem:
1468 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1469
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
1472
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
1475
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
1478
1479 Display certificate self-signed-certificate.pem in plaintext:
1480 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1481
1482 Check self signed certificate:
1483 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1484
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
1487
1488 Generate ssl-certificate for use with apache2:
1489
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
1494
1495 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1496
1497 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1498
1499 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1500 </pre>
1501 <a name="144"></a><hr />
1502 <pre>
1503 Change Windows NT password(s):
1504
1505 # mount -o rw /mnt/hda1
1506 # cd /mnt/hda1/WINDOWS/system32/config/
1507 # chntpw SAM SECURITY system
1508
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
1511
1512 (Be careful with deactivating syskey!)
1513 </pre>
1514 <a name="145"></a><hr />
1515 <pre>
1516 glark - replacement for grep written in Ruby:
1517
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
1521 of non-text files.
1522
1523 Usage examples:
1524
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"
1527
1528 More information: man glark
1529 </pre>
1530 <a name="146"></a><hr />
1531 <pre>
1532 Find CD burning device(s):
1533
1534 General information on CD-ROM:
1535 % cat /proc/sys/dev/cdrom/info
1536
1537 Scan using ATA Packet specific SCSI transport:
1538 # cdrecord -dev=ATA -scanbus
1539 # cdrecord-prodvd -s -scanbus dev=ATA
1540
1541 Get specific information for /dev/ice:
1542 # cdrecord dev=/dev/ice -scanbus
1543 </pre>
1544 <a name="147"></a><hr />
1545 <pre>
1546 Create devices in /dev on udev:
1547
1548 For example create md devices (/dev/md0, /dev/md1,...):
1549 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1550 </pre>
1551 <a name="148"></a><hr />
1552 <pre>
1553 Identify network device (NIC):
1554
1555 # ethtool -i $DEVICE
1556
1557 Show NIC statistics:
1558
1559 # ethtool -S $DEVICE
1560
1561 If your NIC shows some aging signs, you may want to be sure:
1562
1563 # ethtool -t $DEVICE
1564
1565 Disable TCP/UDP checksums:
1566
1567 # ethtool -K $DEVICE tx off
1568 </pre>
1569 <a name="149"></a><hr />
1570 <pre>
1571 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1572
1573 Switch to tty12 and take a look at the syslog. If you see something like:
1574
1575   SQUASHFS error: zlib_fs returned unexpected result 0x........
1576   SQUASHFS error: Unable to read cache block [.....]
1577   SQUASHFS error: Unable to read inode [.....]
1578
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:
1581
1582 # readcd -c2scan dev=/dev/cdrom
1583
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.
1586 </pre>
1587 <a name="150"></a><hr />
1588 <pre>
1589 Write a Microsoft compatible boot record (MBR) using ms-sys
1590
1591 Write a Windows 2000/XP/2003 MBR to device:
1592
1593 # ms-sys -m /dev/ice
1594 </pre>
1595 <a name="151"></a><hr />
1596 <pre>
1597 Use a Vodafone 3G Datacard (UMTS) with Linux:
1598
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:
1601
1602 # gcom -d $DEVICE
1603 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1604
1605 Usage examples:
1606 # gcom -d /dev/ttyUSB0
1607 # wvdial --config /etc/wvdial.conf.umts a1usb
1608
1609 # gcom -d /dev/noz0
1610 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1611
1612 # gcom -d /dev/noz0
1613 # wvdial --config /etc/wvdial.conf.umts dreiusb
1614
1615 If you receive invalid DNS nameservers when connecting, like:
1616
1617 [...]
1618 --&gt; primary   DNS address 10.11.12.13
1619 --&gt; secondary DNS address 10.11.12.14
1620
1621 just provide a working nameserver to resolvconf via:
1622
1623 # echo "nameserver 80.120.17.70" | resolvconf -a ppp0
1624
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
1627 'modprobe sierra').
1628
1629 If your device isn't supported by usbserial yet, manually provide vendor and
1630 product ID when loading the usbserial module. Usage example:
1631
1632 % lsusb
1633 [...]
1634 Bus 004 Device 008: ID 1199:6813 Sierra Wireless, Inc.
1635
1636 # modprobe usbserial vendor=0x1199 product=0x6813
1637 </pre>
1638 <a name="152"></a><hr />
1639 <pre>
1640 hdparm - get/set hard disk parameters
1641
1642 Display the identification info that was obtained from the drive at boot time,
1643 if available:
1644 # hpdarm -i /dev/ice
1645
1646 Request identification info directly from the drive:
1647 # hpdarm -I /dev/ice
1648
1649 Perform timings of device + cache reads for benchmark and comparison purposes:
1650 # hdparm -tT /dev/ice
1651 </pre>
1652 <a name="153"></a><hr />
1653 <pre>
1654 bonnie++ - program to test hard drive performance.
1655
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
1660 </pre>
1661 <a name="154"></a><hr />
1662 <pre>
1663 Use gizmo with a bluetooth headset:
1664
1665 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1666 % gizmo --mic $DEVICE --speaker $DEVICE
1667 </pre>
1668 <a name="155"></a><hr />
1669 <pre>
1670 Scan a v4l device for TV stations:
1671
1672 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1673
1674 Then running xawtv should work:
1675
1676 % xawtv
1677 </pre>
1678 <a name="156"></a><hr />
1679 <pre>
1680 Run apt-get with timeout of 3 seconds:
1681
1682 # apt-get -o acquire::http::timeout=3  update
1683 </pre>
1684 <a name="157"></a><hr />
1685 <pre>
1686 Debian GNU/Linux device driver check page
1687
1688 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1689 </pre>
1690 <a name="158"></a><hr />
1691 <pre>
1692 Use dd with status line:
1693
1694 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1695 </pre>
1696 <a name="159"></a><hr />
1697 <pre>
1698 Generate a 512k file of random data with status bar:
1699
1700 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1701 </pre>
1702 <a name="160"></a><hr />
1703 <pre>
1704 Install Grub instead of lilo on grml installation (grml2hd):
1705
1706 install grml:
1707 # grml2hd ....
1708
1709 adjust grub's configuration file menu.lst:
1710 # $EDITOR /boot/grub/menu.lst
1711
1712 now install grub (usage example for /dev/sda1):
1713 # grub install
1714 root (hd0,0)
1715 setup (hd0)
1716 </pre>
1717 <a name="161"></a><hr />
1718 <pre>
1719 Install Ubuntu using grml:
1720
1721 See https://wiki.ubuntu.com/Installation/FromKnoppix
1722 </pre>
1723 <a name="162"></a><hr />
1724 <pre>
1725 Resize ext2 / ext3 partition:
1726
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
1734 </pre>
1735 <a name="163"></a><hr />
1736 <pre>
1737 Tune ext2 / ext3 filesystem:
1738
1739 Check partition first:
1740
1741 # tune2fs -l /dev/iceX
1742
1743 If you don't see dir_index in the list, then enable it:
1744
1745 # tune2fs -O dir_index /dev/iceX
1746
1747 Now run e2fsck with the -D option to have the directories optimized:
1748
1749 # e2fsck -D /dev/iceX
1750
1751 Notice: since e2fsprogs (1.39-1) filesystems are created with
1752 directory indexing and on-line resizing enabled by default.
1753 </pre>
1754 <a name="164"></a><hr />
1755 <pre>
1756 Search for printers via network:
1757
1758 # pconf_detect -m NETWORK -i 192.168.0.1/24
1759 </pre>
1760 <a name="165"></a><hr />
1761 <pre>
1762 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1763
1764 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1765 </pre>
1766 <a name="166"></a><hr />
1767 <pre>
1768 System-Profiling using oprofile:
1769
1770 Prepare setup:
1771
1772 # opcontrol --reset
1773 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1774
1775 Start logging:
1776 # opcontrol --start
1777
1778 Now $DO_SOME_TASKS...
1779
1780 Stop logging:
1781 # opcontrol --shutdown
1782
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
1787 </pre>
1788 <a name="167"></a><hr />
1789 <pre>
1790 Install ATI's fglrx driver for Xorg / X.org:
1791
1792 Usually there already exist drivers for the grml-system:
1793 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1794
1795 After installing adjust xorg.conf via running:
1796 # aticonfig --initial --input=/etc/X11/xorg.conf
1797
1798 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1799 </pre>
1800 <a name="168"></a><hr />
1801 <pre>
1802 Install nvidia driver for Xorg / X.org:
1803
1804 Usually there already exist drivers for the grml-system:
1805 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
1806
1807 Then switch from module nv to nvidia:
1808
1809 # sed -i 's/Driver.*nv.*/Driver      "nvidia"/' /etc/X11/xorg.conf
1810 </pre>
1811 <a name="169"></a><hr />
1812 <pre>
1813 glxgears - a GLX demo that draws three rotating gears
1814
1815 To print frames per second (fps) use:
1816 % glxgears -printfps
1817 </pre>
1818 <a name="170"></a><hr />
1819 <pre>
1820 You forgot to boot with 'grml noeject noprompt' to avoid
1821 ejecting and prompting for CD removal when rebooting/halting
1822 the system?
1823
1824 Either run:
1825
1826 # noeject reboot
1827
1828 or:
1829
1830 # noeject halt
1831
1832 If you want to avoid only the prompting part, run:
1833
1834 # noprompt reboot
1835
1836 or:
1837
1838 # noprompt halt
1839 </pre>
1840 <a name="171"></a><hr />
1841 <pre>
1842 Mount wikipedia local via fuse:
1843
1844 Adjust configuration:
1845 % cat ~/.wikipediafs/config.xml
1846 &lt;wfs-config&gt;
1847     &lt;general&gt;
1848        &lt;article-cache-time&gt;300</article-cache-time>
1849     &lt;/general&gt;
1850     &lt;sites&gt;
1851       &lt;site&gt;
1852         &lt;dirname&gt;wikipedia-de</dirname>
1853         &lt;host&gt;de.wikipedia.org</host>
1854         &lt;basename&gt;/w/index.php</basename>
1855       &lt;/site&gt;
1856       &lt;site&gt;
1857         &lt;dirname&gt;wikipedia-en</dirname>
1858         &lt;host&gt;en.wikipedia.org</host>
1859         &lt;basename&gt;/w/index.php</basename>
1860       &lt;/site&gt;
1861     &lt;/sites&gt;
1862 &lt;/wfs-config&gt;
1863
1864 Mount it (/wiki must exist of course):
1865 % mount.wikipediafs /wiki
1866 % cat /wiki/wikipedia-en/Cat
1867
1868 Unmount via:
1869 % fusermount -u /wiki
1870 </pre>
1871 <a name="172"></a><hr />
1872 <pre>
1873 Remote notification on X via osd (on screen display):
1874
1875 Start osd_server.py at your local host (listens on port 1234 by default):
1876 % osd_server.py
1877
1878 Then login to a $REMOTEHOST
1879 % ssh -R 1234:localhost:1234 $REMOTEHOST
1880
1881 Now send the text to your local display via running something like:
1882 % echo "text to send" | nc localhost 1234
1883
1884 Very useful when you are waiting for a long running job
1885 but want to do something else in the meanwhile:
1886
1887 % ./configure && make && echo "finished compiling" | netcat localhost 1234
1888
1889 You can use this in external programs as well of course. Examples:
1890
1891 Use osd in centericq:
1892
1893 % cat ~/.centericq/external
1894 [...]
1895 %action osd notify
1896 event msg
1897 proto all
1898 status all
1899 options nowait
1900 %exec
1901 #!/bin/bash
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 &&gt;/dev/null ; then
1906     echo "${osd_msg}" | netcat localhost 1234
1907   fi
1908 fi
1909
1910 Use it in the IRC console client irssi via running:
1911
1912 /script load osd.pl
1913
1914 You can even activate the port forwarding by default globally:
1915
1916 % cat ~/.ssh/config
1917 [...]
1918 Host *
1919 RemoteForward 1234 127.0.0.1:1234
1920 ForwardAgent yes
1921
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...'
1924 might help as well.
1925 </pre>
1926 <a name="173"></a><hr />
1927 <pre>
1928 Avoid automatical startup of init scripts via invoke-rc.d:
1929
1930 First of all make sure the package policyrcd-script-zg2 (which
1931 provides the /usr/sbin/policy-rc.d interface) is installed.
1932
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.
1936
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).
1941
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.
1945
1946 To restore the default behaviour set EXITSTATUS back to '0' in
1947 /etc/policy-rc.d.conf.
1948 </pre>
1949 <a name="174"></a><hr />
1950 <pre>
1951 Install VMware-Tools for grml:
1952
1953 First of all make sure a CD-ROM device in VMware is available.
1954
1955 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
1956 the tools running:
1957
1958 cd /tmp
1959 unp /mnt/cdrom/vmware-linux-tools.tar.gz
1960 cd vmware-tools-distrib
1961 ./vmware-install.pl
1962
1963 /etc/init.d/networking stop
1964 rmmod pcnet32
1965 rmmod vmxnet
1966 depmod -a
1967 modprobe vmxnet
1968 /etc/init.d/networking start
1969
1970 In an X terminal, launch the VMware Tools running:
1971
1972 vmware-toolbox
1973 </pre>
1974 <a name="175"></a><hr />
1975 <pre>
1976 Some important Postfix stuff
1977
1978 List mail queue:
1979
1980 # mailq
1981 or
1982 # postqueue -p
1983
1984 Send all messages in the queue:
1985
1986 # postqueue -f
1987
1988 Send all messages in the queue for a specific site:
1989
1990 # postqueue -s site
1991
1992 Delete a specific message
1993 # postsuper -d 12345678942
1994
1995 Deletes all messages held in the queue for later delivery
1996 # postsuper -d ALL deferred
1997
1998 Mail queues in postfix:
1999
2000     incoming -&gt; mail who just entered the system
2001     active   -&gt; mail to be delivered
2002     deferred -&gt; mail to be delivered later because there were problems
2003     hold     -&gt; mail that should not be delivered until released from hold
2004
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.
2009 </pre>
2010 <a name="176"></a><hr />
2011 <pre>
2012 File permissions
2013
2014 mode 4000 - set user ID (suid):
2015
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
2019
2020 mode 2000 - set group ID (guid):
2021
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
2026   created the file
2027
2028 mode 1000 - sticky bit:
2029
2030 - for files: not used
2031 - for directories: only the owner of a file can delete or rename the file
2032 </pre>
2033 <a name="177"></a><hr />
2034 <pre>
2035 Create MySQL database
2036
2037 # apt-get install mysql-client mysql-server
2038
2039 Run 'mysql' as root - create a database with:
2040
2041 create database grml
2042
2043 Give a user access to the database (without password):
2044
2045 grant all on grml.* to mika;
2046
2047 Give a user access to the database (with password):
2048
2049 grant all on grml.* to enrico identified by "PASSWORD";
2050 </pre>
2051 <a name="178"></a><hr />
2052 <pre>
2053 Setup an HTTPS website:
2054
2055 Create a certificate:
2056
2057 # mkdir /etc/apache2/ssl
2058 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
2059
2060 Create a virtual host on port 443:
2061
2062 &lt;VirtualHost www.foo.invalid:443&gt;
2063 [...]
2064 &lt;/VirtualHost&gt;
2065
2066 Enable SSL in the VirtualHost:
2067
2068 SSLEngine On
2069 SSLCertificateFile /etc/apache2/ssl/apache.pem
2070
2071 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
2072
2073 Listen 443
2074
2075 and make sure the SSL module is used:
2076
2077 # a2enmod ssl
2078 </pre>
2079 <a name="179"></a><hr />
2080 <pre>
2081 Useful Apache / Apache2 stuff
2082
2083 Check configuration file via running:
2084
2085 # apache2ctl configtest
2086
2087 Enable a site:
2088
2089 # a2ensite sitename
2090
2091 Enable a module
2092
2093 # a2enmod modulename
2094 </pre>
2095 <a name="180"></a><hr />
2096 <pre>
2097 Create tar archive and store it on remote machine:
2098
2099 % tar zcf - /sourcedir | ssh user@targethost "cat &gt;file.tgz"
2100 </pre>
2101 <a name="181"></a><hr />
2102 <pre>
2103 Pick out and displays images from network traffic:
2104
2105 # driftnet
2106 </pre>
2107 <a name="182"></a><hr />
2108 <pre>
2109 Install Flash plugin:
2110
2111 # dpkg-reconfigure flashplugin-nonfree
2112 </pre>
2113 <a name="183"></a><hr />
2114 <pre>
2115 To test a proxy, low level way:
2116
2117 % telnet proxy 8080
2118 [...]
2119 GET http://www.google.com HTTP/1.0 [press enter twice]
2120 </pre>
2121 <a name="184"></a><hr />
2122 <pre>
2123 Adjust system for use of qemu with kqemu:
2124
2125 Make sure you have all you need:
2126 # aptitude update ; aptitude install qemu kqemu-modules-$(uname -r)
2127
2128 Then set up kqemu:
2129
2130 modprobe kqemu
2131 mknod /dev/kqemu c 250 0
2132 chmod 666 /dev/kqemu
2133 chmod 666 /dev/net/tun
2134
2135 Check kqemu support via starting qemu, press
2136 Ctrl-Alt-2 and entering 'info kqemu'.
2137 </pre>
2138 <a name="185"></a><hr />
2139 <pre>
2140 (High-Load) Debugging related tools:
2141
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
2148
2149 Usage examples:
2150
2151 # mpstat -P ALL
2152 # iostat -x 1
2153 # iostat -xtc 5 3
2154 # vmstat 1
2155 # atsar -t 60 10
2156 # dstat -af
2157 </pre>
2158 <a name="186"></a><hr />
2159 <pre>
2160 Using WPA for network setup manually:
2161
2162 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
2163
2164 Adjust the options and configuration file to your needs.
2165 Also take a look at 'grml-network'.
2166 </pre>
2167 <a name="187"></a><hr />
2168 <pre>
2169 Start X and lock console via exiting:
2170
2171 % startx 2&gt;~/.xsession-errors &| exit
2172 </pre>
2173 <a name="188"></a><hr />
2174 <pre>
2175 Which process is writing to disk and/or causes the disk to spin up?
2176
2177 First of all use lsof to check what's going on. Does not help? -&gt;
2178
2179 # echo 1 &gt; /proc/sys/vm/block_dump
2180
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.
2185
2186 When you're done, disable block dump using:
2187 # echo 0 &gt; /proc/sys/vm/block_dump
2188
2189 Alternative:
2190 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
2191 which handles block_dump on its own.
2192
2193 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2194
2195 Also take a look at event-viewer(8) which is part of grml-debugtools.
2196 </pre>
2197 <a name="189"></a><hr />
2198 <pre>
2199 Install initrd via initramfs-tools for currently running kernel:
2200
2201 # update-initramfs -c -t -k $(uname -r)
2202 </pre>
2203 <a name="190"></a><hr />
2204 <pre>
2205 Install initrd via yaird for currently running kernel:
2206
2207 # yaird -o /boot/initrd.img-$(uname -r)
2208
2209 Install initrd via yaird for specific kernel:
2210
2211 # mount /proc
2212 # mount /sys
2213 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
2214 </pre>
2215 <a name="191"></a><hr />
2216 <pre>
2217 Reinstall package with its original configuration files:
2218
2219 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o   DPkg::Options::=--force-confnew package
2220 </pre>
2221 <a name="192"></a><hr />
2222 <pre>
2223 grml 0.8 funkenzutzler - rt2x00 drivers:
2224
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:
2229
2230 # dpkg -i /usr/src/rt2x00-modules-*.deb
2231 </pre>
2232 <a name="193"></a><hr />
2233 <pre>
2234 Use Java with jikes and jamvm on grml:
2235
2236 Simple demo:
2237
2238 % cp /usr/share/doc/grml-templates/template.java .
2239 % jikes template.java
2240 % jamvm HelloWorld
2241
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
2245 </pre>
2246 <a name="194"></a><hr />
2247 <pre>
2248 Online resizing of (Software-)RAID5:
2249
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
2252
2253 # Create filesystem, mount md0, create a testfile and save md5sum for
2254 # later check:
2255 mkfs.ext3 /dev/md0
2256 mount /dev/md0 /mnt/test
2257 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
2258 md5sum /mnt/test/dd &gt; md5sum
2259
2260 # Make sure the RAID is synched via checking:
2261 cat /proc/mdstat
2262
2263 # Now remove one partition:
2264 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
2265
2266 # Delete partition, create a new + bigger one and set partition type to fd
2267 # (Linux raid autodetect):
2268 cfdisk /dev/hdd
2269
2270 # And re-add the partition:
2271 mdadm -a /dev/md0 /dev/hdd1
2272
2273 # Make sure the RAID is synched via checking:
2274 cat /proc/mdstat
2275
2276 # Repeat the steps for all other disks/partitions as well:
2277 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2278 cfdisk /dev/hdb
2279 mdadm -a /dev/md0 /dev/hdb1
2280 cat /proc/mdstat
2281 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2282 cfdisk /dev/hda
2283 mdadm -a /dev/md0 /dev/hda1
2284 cat /proc/mdstat
2285
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'
2290
2291 # Last step - resize the filesystem (online again):
2292 resize2fs /dev/md0
2293 </pre>
2294 <a name="195"></a><hr />
2295 <pre>
2296 ext3 online resizing:
2297
2298 Starting with Linux kernel 2.6.10 you can resize ext3 online.  With
2299 e2fsprogs &gt;=1.39-1 new filesystems are created with directory indexing and
2300 on-line resizing enabled by default (see /etc/mke2fs.conf).
2301
2302 Demo:
2303
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
2314
2315 This also works for Software-RAID. Demo:
2316
2317 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
2318 mkfs.ext3 /dev/md0
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
2327 resize2fs /dev/md0
2328
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.
2333 </pre>
2334 <a name="196"></a><hr />
2335 <pre>
2336 Use vim as an outline editor:
2337
2338 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
2339 % vim ~/foo.otl
2340 :he vo
2341 </pre>
2342 <a name="197"></a><hr />
2343 <pre>
2344 Monitor directories/files for changes using iwatch
2345
2346 Monitor /tmp for changes:
2347 % iwatch /tmp/
2348
2349 Monitor files/directories specified in /etc/iwatch.xml
2350 and send mail on changes:
2351 % iwatch
2352 </pre>
2353 <a name="198"></a><hr />
2354 <pre>
2355 Some often used mdadm commands:
2356
2357 Set up RAID1:
2358 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
2359
2360 Display details of specific RAID:
2361 # mdadm --detail /dev/md0
2362 # cat /proc/mdstat
2363
2364 Simulating a drive failure by software:
2365 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
2366
2367 Remove disk from RAID:
2368 # mdadm /dev/md0 -r /dev/hda1
2369
2370 Set disk as faulty and remove from RAID:
2371 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2372
2373 Stop a RAID-device:
2374 # mdadm -S /dev/md0
2375
2376 Restart a RAID-device:
2377 # mdadm -R /dev/md0
2378
2379 Add another disk to existing RAID setup (hotadd):
2380 # mdadm /dev/md0 -a /dev/hde1
2381 # mdadm --grow /dev/md0 --raid-devices=4
2382
2383 Assemble and start all arrays:
2384 # mdadm --assemble --scan
2385
2386 Assemble a specific array:
2387 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
2388
2389 Resync:
2390 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
2391
2392 Stop and rebuild:
2393 # mdadm --stop --scan
2394
2395 Scan for and setup arrays automatically:
2396 # mdadm --assemble --scan --auto=yes --verbose
2397
2398 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
2399 DEVICE partitions
2400 CREATE owner=root group=disk mode=0660 auto=yes
2401 HOMEHOST &lt;system&gt;
2402 MAILADDR root
2403
2404 Running
2405 # /usr/share/mdadm/mkconf &gt; /etc/mdadm/mdadm.conf
2406 might help as well.
2407
2408 Monitoring the sw raid
2409 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
2410
2411 Producing /etc/mdadm/mdadm.conf:
2412 # mdadm --detail --scan &gt; /etc/mdadm/mdadm.conf
2413
2414 See also: man mdadm | less -p "^EXAMPLES"
2415           http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
2416 </pre>
2417 <a name="199"></a><hr />
2418 <pre>
2419 A quick summary of the most commonly used RAID levels:
2420
2421 RAID 0: Striped Set
2422  =&gt; 2 disks each 160 GB: 320 GB data
2423 RAID 1: Mirrored Set
2424  =&gt; 2 disks each 160 GB: 160 GB data
2425 RAID 5: Striped Set with Parity
2426  =&gt; 3 disks each 160 GB: 320 GB data; 160 GB redundancy
2427
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
2433
2434   -- http://en.wikipedia.org/wiki/RAID
2435 </pre>
2436 <a name="200"></a><hr />
2437 <pre>
2438 Logical Volume Management (LVM) with Linux
2439
2440 LVM setup layout:
2441 ~~~~~~~~~~~~~~~~~
2442
2443 |    hda1   hdc1      (PV:s on partitions or whole disks)
2444 |          /
2445 |         /
2446 |       diskvg        (VG)
2447 |       /  |  |      /   |   |  usrlv rootlv varlv (LV:s)
2448 |    |      |     |
2449 | ext3    ext3  xfs   (filesystems)
2450
2451 Often used commands:
2452 ~~~~~~~~~~~~~~~~~~~~
2453
2454 Create a physical volume:
2455 # pvcreate /dev/hda2
2456
2457 Create a volume group:
2458 # vgcreate testvg /dev/hda2
2459
2460 Create a logical volume:
2461 # lvcreate -n test_lv -L100 testvg
2462
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
2469
2470 Create a snapshot of a logical volume:
2471 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2472
2473 Deactivate a volume group:
2474 # vgchange -a n my_volume_group
2475
2476 Actually remove a volume group:
2477 # vgremove my_volume_group
2478
2479 Display information about physical volume:
2480 # pvdisplay /dev/hda1
2481
2482 Remove physical volume:
2483 # vgreduce my_volume_group /dev/hda1
2484
2485 Remove logical volume:
2486 # umount /dev/myvg/homevol
2487 # lvremove /dev/myvg/homevol
2488
2489 See also: man lvm
2490           http://www.tldp.org/HOWTO/LVM-HOWTO/
2491 </pre>
2492 <a name="201"></a><hr />
2493 <pre>
2494 How to use APT locally
2495
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:
2498
2499 mkdir debs
2500 dpkg-scanpackages debs /dev/null | gzip &gt; debs/Packages.gz
2501 echo "  deb file:/root debs/" &gt;> /etc/apt/sources.list
2502 dpkg-scansources debs | gzip &gt; debs/Sources.gz
2503 echo "  deb-src file:/root debs/" &gt;> /etc/apt/sources.list
2504
2505 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2506 </pre>
2507 <a name="202"></a><hr />
2508 <pre>
2509 Check filesystem's LABEL:
2510
2511 generic way:
2512 # vol_id -l /dev/sda1
2513
2514 ext2/3 without vol_id:
2515 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2516
2517 xfs without vol_id:
2518 # xfs_admin -l /dev/sda1
2519
2520 reiserfs without vol_id:
2521 # debugreiserfs /dev/sda1 | grep -i label
2522
2523 jfs without vol_id:
2524 # jfs_tune -l /dev/sda1 | grep -i label
2525
2526 reiser4 without vol_id:
2527 # debugfs.reiser4 /dev/sda1 | grep -i label
2528 </pre>
2529 <a name="203"></a><hr />
2530 <pre>
2531 Check filesystem's UUID:
2532
2533 generic way:
2534 # vol_id -u /dev/sda1
2535
2536 ext2/3 without vol_id:
2537 # dumpe2fs /dev/sda1 | grep -i UUID
2538
2539 xfs without vol_id:
2540 # xfs_admin -u /dev/sda1
2541
2542 reiserfs without vol_id:
2543 # debugreiserfs /dev/sda1 | grep -i UUID
2544
2545 reiser4 without vol_id:
2546 # debugfs.reiser4 /dev/sda1 | grep -i UUID
2547 </pre>
2548 <a name="204"></a><hr />
2549 <pre>
2550 Change a filesystem's LABEL:
2551
2552 swap:
2553 # mkswap -L $LABEL /dev/sda1
2554
2555 ext2/ext3:
2556 # e2label /dev/sda1 $LABEL
2557 # tune2fs -L $LABEL /dev/sda1
2558
2559 reiserfs:
2560 # reiserfstune -l $LABEL /dev/sda1
2561
2562 jfs:
2563 # jfs_tune -L $LABEL /dev/sda1
2564
2565 xfs:
2566 # xfs_admin -L $LABEL /dev/sda1
2567
2568 fat/vfat:
2569 # echo 'drive i: file="/dev/sda1"' &gt;> ~/.mtoolsrc
2570 # mlabel -s i:$LABEL
2571
2572 ntfs:
2573 # ntfslabel $LABEL /dev/sda1
2574 </pre>
2575 <a name="205"></a><hr />
2576 <pre>
2577 Disable pdiffs feature of APT:
2578
2579 Permanent:
2580 # echo 'Acquire::PDiffs "false";' &gt;> /etc/apt/apt.conf
2581
2582 Temporary:
2583 # apt-get update -o Acquire::Pdiffs=false
2584 </pre>
2585 <a name="206"></a><hr />
2586 <pre>
2587 Backup big devices or files and create compressed splitted
2588 image chunks of it using zsplit
2589
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
2594
2595 Restore the backup using unzsplit:
2596 # unzsplit -D /dev/sda -d archiveofsda
2597
2598 More usage examples: man zsplit + man unzsplit
2599 </pre>
2600 <a name="207"></a><hr />
2601 <pre>
2602 Measure network performance using iperf:
2603
2604 Server side:
2605 % iperf -s -V
2606
2607 Client side:
2608 % iperf -c &lt;server_address&gt; -V
2609
2610 or
2611
2612 Server with 128k TCP window size:
2613 % iperf -s -w128k
2614
2615 Client with running for 60 seconds and bidirectional test:
2616 % iperf -c &lt;server_address&gt; -r -w128k -t60
2617 </pre>
2618 <a name="208"></a><hr />
2619 <pre>
2620 Framebuffer resolutions:
2621
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
2628
2629 vga=0x... modes:
2630
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
2661 </pre>
2662 <a name="209"></a><hr />
2663 <pre>
2664 Portscan using netcat:
2665
2666 # netcat -v -w2 &lt;host|ip-addr.&gt; 1-1024
2667 </pre>
2668 <a name="210"></a><hr />
2669 <pre>
2670 Run apt-get but disable apt-listchanges:
2671
2672 APT_LISTCHANGES_FRONTEND=none apt-get ...
2673
2674 Upgrade system but disable apt-listbugs:
2675
2676 APT_LISTBUGS_FRONTEND=none apt-get ...
2677 </pre>
2678 <a name="211"></a><hr />
2679 <pre>
2680 Set up a Transparent Debian Proxy
2681
2682 Install of apt-cacher, the default config will do:
2683 # apt-get install apt-cacher
2684
2685 Check out the ip address of debian mirror(s).
2686 Then add this to your firewall script:
2687
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
2691 done
2692
2693 where ${IPTABLES} is the location of your iptables binary
2694 and $subnet is your internal subnet.
2695
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.
2699
2700 To use apt-cacher on the router itself, add the following
2701 line to your /etc/apt/apt.conf:
2702
2703 Acquire::http::Proxy "http://localhost:3142/";
2704 </pre>
2705 <a name="212"></a><hr />
2706 <pre>
2707 Version control using Mercurial
2708
2709 Setting up a Mercurial project:
2710
2711 % cd project
2712 % hg init           # creates .hg
2713 % hg add            # add all files
2714 % hg commit         # commit all changes, edit changelog entry
2715
2716 Branching and merging:
2717
2718 % hg clone linux linux-work  # create a new branch
2719 % cd linux-work
2720 &lt;make changes&gt;
2721 % hg commit
2722 % cd ../linux
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
2728
2729 Importing patches:
2730
2731 % cat ../p/patchlist | xargs hg import -p1 -b ../p
2732
2733 Exporting a patch:
2734
2735 (make changes)
2736 % hg commit
2737 % hg tip
2738 1234:af3b5cd57dd5
2739 % hg export 1234 &gt; foo.patch    # export changeset 1234
2740
2741 Export your current repo via HTTP with browsable interface:
2742
2743 % hg serve -n "My repo" -p 80
2744
2745 Pushing changes to a remote repo with SSH:
2746
2747 % hg push ssh://user@example.com/~/hg/
2748
2749 Merge changes from a remote machine:
2750
2751 host1% hg pull http://foo/
2752 host2% hg merge # merge changes into your working directory
2753
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
2757
2758 Mercurial repositories of grml can be found at http://hg.grml.org/
2759 </pre>
2760 <a name="213"></a><hr />
2761 <pre>
2762 Download binary codecs for mplayer:
2763
2764 # /usr/share/mplayer/scripts/win32codecs.sh
2765
2766 or
2767
2768 # /usr/share/mplayer/scripts/binary_codecs.sh install
2769
2770 (depending on the mplayer version you have).
2771
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.
2775 </pre>
2776 <a name="214"></a><hr />
2777 <pre>
2778 Read manpages of uninstalled packages with debman:
2779
2780 % debman -p git-core git
2781 </pre>
2782 <a name="215"></a><hr />
2783 <pre>
2784 Test network performance using netperf:
2785
2786 Server:
2787 # netserver
2788
2789 Client:
2790 # netperf -t TCP_STREAM -H 192.168.0.41
2791 </pre>
2792 <a name="216"></a><hr />
2793 <pre>
2794 Setup Xen within 20 minutes on Debian/grml
2795
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):
2798
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
2800 update-grub
2801
2802 Example for installation of Debian etch as DomU:
2803
2804 mkdir /mnt/md1/xen
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/
2806
2807 Start services:
2808
2809 /etc/init.d/xend start
2810 /etc/init.d/xendomains start
2811
2812 Setup a bridge for network, either manually:
2813
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
2819
2820 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
2821 without rebooting):
2822
2823 auto xenintbr
2824 iface xenintbr inet static
2825   pre-up brctl addbr xenintbr
2826   post-down brctl delbr xenintbr
2827   address 192.168.1.1
2828   netmask 255.255.255.0
2829   bridge_fd 0
2830   bridge_hello 0
2831   bridge_stp off
2832
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):
2835
2836 echo 1 &gt; /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
2839
2840 Adjust network configuration of Xend:
2841
2842 cat &gt;> /etc/xen/xend-config.sxp &lt;< EOF
2843 (network-script    network-route)
2844 (vif-bridge        xenintbr)
2845 (vif-script        vif-bridge)
2846 EOF
2847
2848 List domains, start up a DomU, shutdown later again:
2849
2850 xm create -c /etc/xen/xengrml1.cfg
2851 xm list
2852 xm shutdown 1
2853
2854 This HowTo is also available online at http://grml.org/xen/
2855 </pre>
2856 <a name="217"></a><hr />
2857 <pre>
2858 Play tetris with zsh:
2859
2860 autoload -U tetris
2861 zle -N tetris
2862 bindkey "^Xt" tetris
2863
2864 Now press 'ctrl-x t'.
2865 </pre>
2866 <a name="218"></a><hr />
2867 <pre>
2868 Set up a router with grml
2869
2870 Run grml-router script:
2871 # grml-router
2872
2873 Install dnsmasq if not already present:
2874 # apt-get update ; apt-get install dnsmasq
2875
2876 Adjust /etc/dnsmasq.conf according to your needs:
2877 # cat &gt;> /etc/dnsmasq.conf &lt;< EOF
2878 domain-needed
2879 bogus-priv
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
2883 EOF
2884
2885 Start dnsmasq finally:
2886 # Restart dnsmasq
2887 </pre>
2888 <a name="219"></a><hr />
2889 <pre>
2890 Display stats about memory allocations performed by a program:
2891
2892 Usage example for 'ls':
2893
2894 % LD_PRELOAD=/lib/libmemusage.so ls &gt; /dev/null
2895 </pre>
2896 <a name="220"></a><hr />
2897 <pre>
2898 Use KVM (Kernel-based Virtual Machine for Linux):
2899
2900 Make sure to install the relevant tools:
2901 # apt-get update ; apt-get install kvm
2902 # modprobe kvm
2903
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
2908 </pre>
2909 <a name="221"></a><hr />
2910 <pre>
2911 EEPROM data decoding for SDRAM DIMM modules:
2912
2913 # modprobe eeprom
2914 # /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl
2915 </pre>
2916 <a name="222"></a><hr />
2917 <pre>
2918 Set up and use DVB:
2919
2920 Make sure your device is supported by Linux and running.
2921 See http://www.linuxtv.org/ for more details.
2922
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:
2926
2927 # aptitude install dvb-utils
2928
2929 Then create a channels.conf configuration file:
2930
2931 % scan /usr/share/doc/dvb-utils/examples/scan/... &gt; ~/.mplayer/channels.conf
2932
2933 You can find some example configuration files on
2934 your grml system in ~/.channels. Usage example:
2935
2936 % ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf
2937
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
2940 details.
2941 </pre>
2942 <a name="223"></a><hr />
2943 <pre>
2944 Get the lastest mercurial snapshot:
2945
2946 Make sure you have the python-dev package available:
2947 # apt-get update ; apt-get install python-dev
2948
2949 Get and build the source:
2950 % hg clone http://selenic.com/repo/hg mercurial
2951 % cd mercurial
2952 % make local
2953 % export PYTHONPATH=$(pwd)
2954 % export PATH=$PATH:$(pwd)
2955
2956 now you should have the newest version of mercurial whenever you execute hg.
2957
2958 To update to the lastest development snapshot, additionally use
2959 the following commands:
2960 % hg pull -u http://hg.intevation.org/mercurial/crew
2961 % make local
2962 </pre>
2963 <a name="224"></a><hr />
2964 <pre>
2965 Configure timezone
2966 ==================
2967
2968 Available bootoptions relevant in live-cd mode:
2969 -----------------------------------------------
2970
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:
2974   tz=Europe/Vienna
2975
2976 Configuration options relevant on harddisk installation:
2977 --------------------------------------------------------
2978
2979 * Use the tzconfig utility to set the local timezone:
2980
2981   # tzconfig
2982
2983   which adjusts /etc/timezone and /etc/localtime according
2984   to the provided information. Running:
2985
2986   # dpkg-reconfigure tzdata
2987
2988   might be useful as well.
2989
2990 * /etc/default/rcS: set variable UTC according to your needs,
2991   whether your system clock is set to UTC (UTC='yes') or
2992   not (UTC='no')
2993
2994 * /etc/localtime: adjust zoneinfo according to your needs:
2995
2996   # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime
2997
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).
3003
3004 * /etc/adjtime: This file is used e.g. by the adjtimex function,
3005   which can smoothly adjust system time while the system runs
3006
3007 * If you change the time (using 'date --set ...', ntpdate,...)
3008   it is worth setting also the hardware clock to the correct time:
3009
3010   # hwclock --systohc [--utc]
3011
3012   Remember to add the --utc -option if the hardware clock is set
3013   to UTC!
3014
3015 Still problems?
3016 ---------------
3017
3018 Check your current settings via:
3019
3020   cat /etc/timezone
3021   zdump /etc/localtime
3022   echo $TZ
3023   hwclock --show
3024   grep hwclock /etc/runlevel.conf
3025   grep '^UTC' /etc/default/rc
3026
3027 Further information:
3028 --------------------
3029
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
3033 </pre>
3034 <a name="225"></a><hr />
3035 <pre>
3036 Recorder shellscript session using script:
3037
3038 % script -t 2&gt;~/upgrade.time -a ~/upgrade.script
3039 % scriptreplay ~/upgrade.time ~/upgrade.script
3040 </pre>
3041 <a name="226"></a><hr />
3042 <pre>
3043 Test UTF-8 capabilities of terminal:
3044
3045 wget http://melkor.dnp.fmph.uniba.sk/~garabik/debian-utf8/download/UTF-8-demo.txt.gz
3046 zcat UTF-8-demo.txt.gz
3047
3048 or:
3049
3050 wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
3051 cat UTF-8-test.txt
3052 </pre>
3053 <a name="227"></a><hr />
3054 <pre>
3055 UTF-8 at grml / some general information regarding Unicde/UTF-8:
3056
3057   http://wiki.grml.org/doku.php?id=utf8
3058 </pre>
3059 <a name="228"></a><hr />
3060 <pre>
3061
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.
3069
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.
3072
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
3075 </pre>
3076 <a name="229"></a><hr />
3077 <pre>
3078 Tunnel a specific connection via socat:
3079
3080 On the client:
3081 % socat TCP4-LISTEN:8003 TCP4:gateway:500
3082
3083 On the gateway:
3084 # socat TCP4-LISTEN:500,fork TCP4:target:$PORT
3085
3086 Using localhost:8003 on the client uses the tunnel now.
3087 </pre>
3088 <a name="230"></a><hr />
3089 <pre>
3090 Set date:
3091
3092 # date --set=060916102007
3093
3094 where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4)
3095
3096 Set date using a relative date:
3097
3098 # date -s '+3 mins'
3099
3100 or
3101
3102 # date -s '+tomorrow'
3103
3104 Display a specific relative date:
3105
3106 # date -d '+5 days -2 hours'
3107
3108 Don't forget to set hardware clock via:
3109
3110 # hwlock -w
3111 </pre>
3112 <a name="231"></a><hr />
3113 <pre>
3114 Booting grml via network / PXE:
3115
3116 Start grml-terminalserver on a system with network access
3117 and where grml is running:
3118
3119 # grml-terminalserver
3120
3121 Then booting your client(s) via PXE should work without
3122 any further work.
3123
3124 See: man grml-terminalserver + http://grml.org/terminalserver/
3125 </pre>
3126 <a name="232"></a><hr />
3127 <pre>
3128 Debugging SSL communications:
3129
3130 % openssl s_client -connect server.adress:993
3131
3132 or
3133
3134 # ssldump -a -A -H -i eth0
3135
3136 See http://prefetch.net/articles/debuggingssl.html for more details.
3137 </pre>
3138 <a name="233"></a><hr />
3139 <pre>
3140 Remove bootmanager from MBR:
3141
3142 # lilo -M /dev/hda -s /dev/null
3143 </pre>
3144 <a name="234"></a><hr />
3145 <pre>
3146 Rewrite grub to MBR:
3147
3148 # mount /mnt/sda1
3149 # grub-install --recheck --no-floppy --root-directory=/mnt/sda1 /dev/sda
3150 </pre>
3151 <a name="235"></a><hr />
3152 <pre>
3153 Rewrite lilo to MBR:
3154
3155 # mount /mnt/hda1
3156 # lilo -r /mnt/hda1
3157 </pre>
3158 <a name="236"></a><hr />
3159 <pre>
3160 Create screenshot of plain/real console - tty1:
3161
3162 # fbgrab -c 1 screeni.png
3163 </pre>
3164 <a name="237"></a><hr />
3165 <pre>
3166 Create screenshot when running X:
3167
3168 % scrot
3169
3170 Tip: use the gkrellshoot plugin when using gkrellm
3171 </pre>
3172 <a name="238"></a><hr />
3173 <pre>
3174 Redirect all connections to hostA:portA to hostB:portB, where hostA and hostB are
3175 different networks:
3176
3177 Run the following commands on hostA:
3178
3179 echo 1 &gt; /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
3184 </pre>
3185 <a name="239"></a><hr />
3186 <pre>
3187 Flash BIOS without DOS/Windows:
3188
3189 Dump flash info and set the flash chip to writable:
3190 # flashrom
3191
3192 Backup the original BIOS:
3193 # flashrom -r backup.bin
3194
3195 Notice: the following step will overwrite your current BIOS!
3196 So make sure you really know what you are doing.
3197
3198 Flash the BIOS image:
3199 # flashrom -wv newbios.bin
3200
3201 Also check out LinuxBIOS: http://linuxbios.org/
3202 </pre>
3203 <a name="240"></a><hr />
3204 <pre>
3205 Enable shadow passwords:
3206
3207 # shadowconfig on
3208 </pre>
3209 <a name="241"></a><hr />
3210 <pre>
3211 Set up an IPv6 tunneln on grml:
3212
3213 # ipv6-tunnel start
3214 </pre>
3215 <a name="242"></a><hr />
3216 <pre>
3217 Set up console newsreader slrn for use with Usenet:
3218
3219 % grml-slrn
3220 </pre>
3221 <a name="243"></a><hr />
3222 <pre>
3223 Calculate with IPv6 addresses:
3224
3225 % ipv6calc
3226
3227 For usage examples refer to manpage ipv6calc(8).
3228 </pre>
3229 <a name="244"></a><hr />
3230 <pre>
3231 Common network debugging tools for use with IPv6:
3232
3233 % ping6
3234 % tracepath6
3235 % traceroute6
3236 % tracert6
3237 % nc6
3238 % tcpspray6
3239 </pre>
3240 <a name="245"></a><hr />
3241 <pre>
3242 Set up NFS (Network File System):
3243
3244 Server-side
3245 ~~~~~~~~~~~
3246 Make sure the relevant services are running on the server side:
3247
3248 # /etc/init.d/portmap start
3249 # /etc/init.d/nfs-common start
3250 # /etc/init.d/nfs-kernel-server start
3251
3252 Export shares via /etc/exports:
3253
3254 /backups 192.168.1.100/24(rw,wdelay,no_root_squash,async,subtree_check)
3255
3256 ... or manually export a directory running:
3257
3258 # exportfs -o rw,wdelay,no_root_squash,async,subtree_check 192.168.1.100:/backups
3259
3260 and unexport a share running:
3261
3262 # exportfs -u 192.168.1.100:/backups
3263
3264 and every time when you modify /etc/exports file run
3265
3266 # exportfs -ra
3267
3268 Display what NFS components are running:
3269
3270 # rpcinfo -p
3271
3272 Display list of exported shares:
3273
3274 # exportfs -v
3275 or
3276 # showmount -e
3277
3278 Client-side
3279 ~~~~~~~~~~~
3280 Make sure the relevant services are running on the client side:
3281
3282 # /etc/init.d/portmap start
3283 # /etc/init.d/nfs-common start
3284
3285 Verify that the server allows you to access its RPC/NFS services:
3286
3287 # rpcinfo -p server_name
3288
3289 Check what directories the server exports:
3290
3291 # showmount -e server_name
3292
3293 On the client side you can use something like the following in /etc/fstab:
3294
3295 192.168.1.101:/backups /mnt/nfs nfs defaults,users,wsize=8192,rsize=8192 0 0
3296 </pre>
3297 <a name="246"></a><hr />
3298 <pre>
3299 Mount a cloop file:
3300
3301 # aptitude install cloop-src
3302 # m-a a-i cloop-src
3303
3304 # modprobe cloop file=/path/to/cloop/file
3305 # mount -r -t iso9660 /dev/cloop /mnt/test
3306 </pre>
3307 <a name="247"></a><hr />
3308 <pre>
3309 Create a PS/PDF of a plaintext file:
3310
3311 % a2ps --medium A4dj -E -o output.ps input_file
3312 % ps2pdf output.ps
3313 </pre>
3314 <a name="248"></a><hr />
3315 <pre>
3316 Print two pages on one in a PDF file:
3317
3318 % pdfnup --nup 2x1 input.pdf
3319
3320 Concatenate, extract pages/parts, encrypt/decrypt,
3321 compress PDFs using 'pdftk'.
3322 </pre>
3323 <a name="249"></a><hr />
3324 <pre>
3325 Read a PS/PDF file on console:
3326
3327 % pstotext file.pdf
3328
3329 or on plain framebuffer console in graphical mode:
3330
3331 % pdf2ps file.pdf ; ps2png file.ps file.png ; fbi file.png
3332
3333 or
3334
3335 % fbgs file.pdf
3336 </pre>
3337 <a name="250"></a><hr />
3338 <pre>
3339 Bypass the password of a PDF file:
3340
3341 % gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c quit
3342 </pre>
3343 <a name="251"></a><hr />
3344 <pre>
3345 Record sound:
3346
3347 % rec test.aiff
3348
3349 This will record a AIFF audio file.
3350 </pre>
3351 <a name="252"></a><hr />
3352 <pre>
3353 Change passphrase / password of an existing SSH key:
3354
3355 % ssh-keygen -p
3356 </pre>
3357 <a name="253"></a><hr />
3358 <pre>
3359 Enable syntax highlighting in nano:
3360
3361 Just uncomment the include directives for your respective
3362 language at the bottom of the file /etc/nanorc
3363 </pre>
3364 <a name="254"></a><hr />
3365 <pre>
3366 Create netboot package for grml-terminalserver:
3367
3368 # sh /usr/share/doc/grml-terminalserver/examples/create-netboot
3369 </pre>
3370 <a name="255"></a><hr />
3371 <pre>
3372 To boot grml via network (PXE) check out grml-terminalserver:
3373
3374 # grml-terminalserver
3375
3376 See http://grml.org/terminalserver/ for more details.
3377 </pre>
3378 <a name="256"></a><hr />
3379 <pre>
3380 Rotate pictures:
3381
3382 Using the 'Orientation' tag of the Exif header, rotate
3383 the image so that it is upright:
3384 % jhead -autorot *.jpg
3385
3386 Manually rotate a picture:
3387 % convert -rotate 270 input.jpg output.jpg
3388 </pre>
3389 <a name="257"></a><hr />
3390 <pre>
3391 Rename files based on the information inside their exif header:
3392
3393 % jhead -n%Y-%m-%d_%Hh%M_%f *.jpg
3394
3395 This will rename a file named img_2071.jpg to something like:
3396
3397 2007-08-17_10h38_img_2071.jpg
3398
3399 if it was shot at 10:38 o'clock on 2007-08-17 (according to
3400 the information inside the exif header).
3401 </pre>
3402 <a name="258"></a><hr />
3403 <pre>
3404 Calculate network / netmask:
3405
3406 Usage examples:
3407 % ipcalc 10.0.0.28 255.255.255.0
3408 % ipcalc 10.0.0.0/24
3409 </pre>
3410 <a name="259"></a><hr />
3411 <pre>
3412 Blacklist a kernel module:
3413
3414 # blacklist &lt;name_of_kernel_module&gt;
3415
3416 -&gt; running 'blacklist hostap_cs' for example will generate an
3417 entry like this in /etc/modprobe.d/grml:
3418
3419 blacklist hostap_cs
3420 alias hostap_cs off
3421
3422 To remove the module from the blacklist again just invoke:
3423
3424 # unblacklist &lt;name_of_kernel_module&gt;
3425
3426 or manually remove the entry from /etc/modprobe.d/grml.
3427 </pre>
3428 <a name="260"></a><hr />
3429 <pre>
3430 Create a Debian package of a perl module:
3431
3432 % dh-make-perl --cpan Acme::Smirch --build
3433 </pre>
3434 <a name="261"></a><hr />
3435 <pre>
3436 The Magic SysRq Keys (SysReq or Sys Req, short for System Request):
3437
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").
3441
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
3448
3449 Notice: use O instead of B for poweroff.
3450
3451 Or write the sequence to /proc/sysrq-trigger instead:
3452
3453 # for i in r e i s u b ; do echo $i &gt; /proc/sysrq-trigger ; done
3454
3455 To enable or disable SysRq calls:
3456
3457 # echo 0 &gt; /proc/sys/kernel/sysrq
3458 # echo 1 &gt; /proc/sys/kernel/sysrq
3459
3460 See http://en.wikipedia.org/wiki/Magic_SysRq_key for more details.
3461 </pre>
3462 <a name="262"></a><hr />
3463 <pre>
3464 Memtest / memcheck:
3465
3466 Just boot your grml Live-CD with "memtest" to execute a memcheck/memtest
3467 with Memtest86+.
3468 </pre>
3469 <a name="263"></a><hr />
3470 <pre>
3471 Tunnel TCP-Traffic through DNS using dns2tcp:
3472
3473 Server-side:
3474 ~~~~~~~~~~~~
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
3479
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 " " " "
3484 user = nobody
3485 chroot = /tmp
3486 domain = dnstun.example.com.  # the zone as specified inside dns
3487 ressources = ssh:127.0.0.1:22 # available resources
3488
3489 3. Start the daemon:
3490 # cat &gt; /etc/default/dns2tcp &lt;< EOF
3491 # Set ENABLED to 1 if you want the init script to start dns2tcpd.
3492 ENABLED=1
3493 USER=nobody
3494 EOF
3495 # /etc/init.d/dns2tcp start
3496
3497 Client-side:
3498 ~~~~~~~~~~~~
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) : 
3505         ssh
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:~#
3510
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) : 
3514         ssh
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:~#
3519
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".
3522 </pre>
3523 <a name="264"></a><hr />
3524 <pre>
3525
3526 </body>
3527 </html>