Merge remote-tracking branch 'origin/github/pr/45'
[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="Robots" content="index,follow" />
10 <meta name="Language" content="english" />
11 <meta name="identifier-url" content="https://grml.org/" />
12 <meta name="MSSmartTagsPreventParsing" content="true" />
13 <meta http-equiv="imagetoolbar" content="no" />
14 <link rel="home" href="/" title="grml.org" />
15 <link rel="help" href="/features/" title="About" />
16 <link rel="author" href="/team/" title="Team" />
17 <link rel="icon" href="/favicon.png" type="image/png" />
18 <link rel="stylesheet" href="/style.css" type="text/css" />
19 </head>
20 <body>
21
22 <a name="0"></a>
23 <pre>
24 Install grml to harddisk:
25
26 # grml2hd
27
28 Notice: You can pre-select the partition for the partition selector
29 and mbr dialogs inside grml2hd using:
30 # grml2hd /dev/hda1 -mbr /dev/hda
31
32 See: man grml2hd + http://grml.org/grml2hd/
33
34 Tags: grml2hd, installation
35 </pre>
36 <a name="1"></a><hr />
37 <pre>
38 Install grml on software RAID level 1:
39
40 Create /dev/md0 (and some more /dev/md* devices) first of all:
41 # cd /dev && MAKEDEV dev
42
43 Create RAID:
44 # mdadm --create --verbose /dev/md0 --level=raid1         --raid-devices=2   /dev/hda1  /dev/hdc1
45
46 Finally install grml on it:
47 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
48
49 See: man grml2hd + http://grml.org/grml2hd/
50
51 Tags: grml2hd, installation, mdadm, raid
52 </pre>
53 <a name="2"></a><hr />
54 <pre>
55 Install grml in non interactive mode with grml2hd:
56
57 Adjust configuration as needed:
58 # vim /etc/grml2hd/config
59
60 Then execute:
61
62 # GRML2HD_NONINTERACTIVE=yes grml2hd
63
64 or run:
65
66 # grml2hd -i
67
68 Use with care and only if you really know what you are doing!
69
70 See: man grml2hd + http://grml.org/grml2hd/
71
72 Tags: grml2hd, installation
73 </pre>
74 <a name="3"></a><hr />
75 <pre>
76 Configure network:
77
78 # grml-network
79
80 Tags: configuration, network
81 </pre>
82 <a name="4"></a><hr />
83 <pre>
84 Deactivate error correction of zsh:
85
86 % NOCOR=1 zsh
87
88 Run zsh-help for more information regarding zsh.
89
90 Tags: zsh, configuration
91 </pre>
92 <a name="5"></a><hr />
93 <pre>
94 Disable automatic setting of title in GNU screen:
95
96 % NOPRECMD=1 zsh
97
98 Set it manually e.g. via:
99
100 % screen -X title foobar
101
102 Run zsh-help for more information regarding zsh.
103
104 Tags: zsh, configuration
105 </pre>
106 <a name="6"></a><hr />
107 <pre>
108 Do not use menu completion in zsh:
109
110 % NOMENU=1 zsh
111
112 Run zsh-help for more information regarding zsh.
113
114 Tags: zsh, configuration
115 </pre>
116 <a name="7"></a><hr />
117 <pre>
118 Run GNU screen with grml-configuration:
119
120 % grml-screen
121
122 or
123
124 % screen -c /etc/grml/screenrc
125
126 Tags: screen, configuration
127 </pre>
128 <a name="8"></a><hr />
129 <pre>
130 Print out grml-version:
131
132 % grml-version
133
134 Tags: grml
135 </pre>
136 <a name="9"></a><hr />
137 <pre>
138 Configure mutt:
139
140 % grml-mutt
141
142 Tags: mutt
143 </pre>
144 <a name="10"></a><hr />
145 <pre>
146 Configure mutt-ng / muttng:
147
148 % grml-muttng
149
150 Tags: muttng
151 </pre>
152 <a name="11"></a><hr />
153 <pre>
154 Set up Inode-PPTP connection:
155
156 # grml-pptp-inode
157 or
158 # grml-pptp-xdsl-students
159
160 Tags: pptp, inode, xdsl
161 </pre>
162 <a name="12"></a><hr />
163 <pre>
164 Set up VPN / WLAN connection at TUG (TU Graz):
165
166 Set ESSID and request for ip-address via DHCP:
167 # iwconfig $DEVICE essid tug
168 # dhclient $DEVICE
169
170 Now run the main script:
171 # grml-vpnc-tugraz
172
173 After running the script an init script is available:
174
175 # /etc/init.d/vpnctug [start|stop]
176
177 Tags: tug
178 </pre>
179 <a name="13"></a><hr />
180 <pre>
181 Set up PPTP connection at VCG (Virtual Campus Graz):
182
183 # grml-pptp-vcgraz
184
185 Tags: pptp, vcg
186 </pre>
187 <a name="14"></a><hr />
188 <pre>
189 Set up VPN:
190
191 # grml-vpn &lt;options&gt;
192
193 Usage example:
194
195 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
196
197 See: man grml-vpn
198
199 Tags: grml, vpn, network
200 </pre>
201 <a name="15"></a><hr />
202 <pre>
203 Use encrypted files / partitions:
204
205 # grml-crypt &lt;options&gt;
206
207 Usage example:
208
209 Initialize:
210
211 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
212 # cp big_file /mnt/test
213 # grml-crypt stop /mnt/test
214
215 Use:
216
217 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
218 # grml-crypt stop /mnt/test
219
220 See: man grml-crypt
221
222 Tags: crypto, grml-crypt, dmcrypt, luks
223 </pre>
224 <a name="16"></a><hr />
225 <pre>
226 Change resolution of X:
227
228 % xrandr -s '1024x768'
229
230 Tags: x11, xorg, resolution
231 </pre>
232 <a name="17"></a><hr />
233 <pre>
234 Change resolution of framebuffer:
235
236 # fbset 800x600-60
237
238 Tags: resolution
239 </pre>
240 <a name="18"></a><hr />
241 <pre>
242 Configure newsreader slrn:
243
244 % grml-slrn
245
246 Tags: slrn
247 </pre>
248 <a name="19"></a><hr />
249 <pre>
250 Configure grml system:
251
252 # grml-config
253
254 Or directly run scripts:
255
256 # grml-config-root
257 % grml-config-user
258
259 Tags: grml, configuration
260 </pre>
261 <a name="20"></a><hr />
262 <pre>
263 Lock screen (X / console):
264
265 % grml-lock
266
267 Press ctrl-alt-x to lock a GNU screen session.
268
269 Tags: grml, lock, grml-lock, screen
270 </pre>
271 <a name="21"></a><hr />
272 <pre>
273 Change wallpaper in X:
274
275 % grml-wallpaper &lt;press-tab&gt;
276
277 Tags: grml, wallpaper
278 </pre>
279 <a name="22"></a><hr />
280 <pre>
281 Start X window system (XFree86 / Xorg / X.org):
282
283 % grml-x $WINDOWMANAGER
284
285 Usage examples:
286
287 % grml-x fluxbox
288 % grml-x -mode '1024x768' wmii
289 % grml-x -nosync wm-ng
290
291 Tags: grml-x, x11, xorg, graphic
292 </pre>
293 <a name="23"></a><hr />
294 <pre>
295 Collect hardware information:
296
297 % grml-hwinfo
298
299 or run as root to collect some more information:
300
301 # grml-hwinfo
302
303 will generate a file named info.tar.bz2.
304
305 Tags: grml, hardware, hwinfo, collect
306 </pre>
307 <a name="24"></a><hr />
308 <pre>
309 Configure hardware detection features of harddisk installation:
310
311 # grml-autoconfig
312
313 or manually edit /etc/grml/autoconfig[.small]
314
315 See: man grml-autoconfig
316
317 Tags: grml, installation, configuration
318 </pre>
319 <a name="25"></a><hr />
320 <pre>
321 Bootoptions / cheatcodes / bootparams for booting grml:
322
323 On the grml-ISO if not running grml:
324 % less /cdrom/GRML/grml-cheatcodes.txt
325
326 When running grml:
327 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
328
329 Tags: grml, cheatcodes, boot, bootoptions, bootparam
330 </pre>
331 <a name="26"></a><hr />
332 <pre>
333 Report bugs to Debian's Bug Tracking System (BTS):
334
335 % reportbug --bts debian
336
337 or adjust /etc/reportbug.conf to your needs.
338
339 See:
340
341   http://grml.org/bugs/
342   http://www.debian.org/Bugs/
343
344 Tags: bug, reportbug, bts, debian
345 </pre>
346 <a name="27"></a><hr />
347 <pre>
348 Offline documentation:
349
350 % grml-info
351
352 Online documentation:
353
354   http://grml.org/faq/
355   http://grml.org/docs/
356   http://wiki.grml.org/doku.php
357
358 Tags: info, grml, grml-info, documentation
359 </pre>
360 <a name="28"></a><hr />
361 <pre>
362 Mount NTFS partition (read-write):
363
364 # mount.ntfs-3g /dev/sda1 /mnt/sda1
365
366 Tags: ntfs, mount
367 </pre>
368 <a name="29"></a><hr />
369 <pre>
370 Overwrite specific file on an NTFS partition:
371
372 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
373 </pre>
374 <a name="30"></a><hr />
375 <pre>
376 Resize an NTFS partition:
377
378 # ntfsresize ..
379
380 Usage example:
381
382 ntfsresize -n -s 10G /dev/hda1 # testcase
383 ntfsresize -s 10G /dev/hda1    # testing was successfull, now really resize partition
384 cfdisk /dev/hda   # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
385
386 Tags: ntfs, resize, ntfsresize
387 </pre>
388 <a name="31"></a><hr />
389 <pre>
390 Modify resolution for intel graphic chipsets:
391
392 # 915resolution ..
393
394 Usage example:
395
396 # 915resolution 4d 1400 1050
397 </pre>
398 <a name="32"></a><hr />
399 <pre>
400 Connect bluetooth mouse:
401
402 # bt-hid start
403
404 ... and press 'connect' button on your bluetooth device.
405 </pre>
406 <a name="33"></a><hr />
407 <pre>
408 Connect bluetooth headset:
409
410 # bt-audio start
411
412 ... and press 'connect' button on your bluetooth device.
413 </pre>
414 <a name="34"></a><hr />
415 <pre>
416 Secure delete file / directory / partition:
417
418 # wipe -kq /dev/hda1
419
420 See: man wipe
421
422 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
423
424 Tags: delete, secure, wipe, shred
425 </pre>
426 <a name="35"></a><hr />
427 <pre>
428 Use grml on Samsung X20 laptop:
429
430 # apt-get install grml-samsung-x20
431
432 See: http://www.michael-prokop.at/computer/samsung_x20.html
433 </pre>
434 <a name="36"></a><hr />
435 <pre>
436 Development information regarding grml:
437
438   http://blog.grml.org/
439
440 Tags: blog, grml, developmnet
441 </pre>
442 <a name="37"></a><hr />
443 <pre>
444 Contact Grml team:
445
446 #grml on irc.oftc.net - https://grml.org/irc/
447 http://grml.org/contact/
448
449 Tags: contact, irc, oftc, email
450 </pre>
451 <a name="38"></a><hr />
452 <pre>
453 Join the grml mailinglist:
454
455 http://grml.org/mailinglist/
456
457 Tags: grml, mailinglist
458 </pre>
459 <a name="39"></a><hr />
460 <pre>
461 Help us - donate!
462
463 http://grml.org/donations/
464
465 Tags: grml, donation
466 </pre>
467 <a name="40"></a><hr />
468 <pre>
469 Commercial support / system administration / adjusted live-cds:
470
471 grml-solutions: http://grml.org/solutions/
472
473 Tags: grml, commercial, customize
474 </pre>
475 <a name="41"></a><hr />
476 <pre>
477 Information regarding the kernel provided by grml:
478
479   http://grml.org/kernel/
480
481 Tags: documentation, grml, kernel
482 </pre>
483 <a name="42"></a><hr />
484 <pre>
485 SMTP command-line test tool:
486
487 % swaks &lt;options&gt;
488
489 Usage example:
490
491 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
492
493 See: man swaks
494
495 Tags: swak, smtp, test
496 </pre>
497 <a name="43"></a><hr />
498 <pre>
499 NTFS related packages:
500
501 scrounge-ntfs
502 salvage-ntfs
503 ntfsprogs
504
505 Tags: utils, ntfs
506 </pre>
507 <a name="44"></a><hr />
508 <pre>
509 Modify service through init script:
510
511 # Start ssh
512 # Stop samba
513 # Restart apache
514 # Reload postfix
515 # service gpm start
516 # /etc/init.d/lvm start
517
518 Tags: init, script, start, stop
519 </pre>
520 <a name="45"></a><hr />
521 <pre>
522 Test joystick:
523
524 # jstest /dev/input/js0
525 </pre>
526 <a name="46"></a><hr />
527 <pre>
528 Play movie:
529
530 % mplayer /path/to/movie
531
532 Tags: movie, mplayer
533 </pre>
534 <a name="47"></a><hr />
535 <pre>
536 Use webcam with mplayer:
537
538 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
539
540 Tags: webcam, mplayer
541 </pre>
542 <a name="48"></a><hr />
543 <pre>
544 Powerful network discovery tool:
545
546 # scapy
547
548 Tags: network, python, tool
549 </pre>
550 <a name="49"></a><hr />
551 <pre>
552 Grab an entire CD and compress it to Ogg/Vorbis,
553 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
554
555 % abcde
556
557 Tags: rip, abcde, mp3, transcode, audio
558 </pre>
559 <a name="50"></a><hr />
560 <pre>
561 Show a console session in several terminals:
562
563 % gems
564 </pre>
565 <a name="51"></a><hr />
566 <pre>
567 Switch behaviour of caps lock key:
568
569 % caps-ctrl
570 </pre>
571 <a name="52"></a><hr />
572 <pre>
573 grep with Perl-compatible regular expressions:
574
575 % pcregrep
576 </pre>
577 <a name="53"></a><hr />
578 <pre>
579 ncp: a fast file copy tool for LANs
580
581 Local (send file):
582 % npush file_to_copy
583
584 Remote (receive file):
585 % npoll
586
587 Tags: copy, file, network
588 </pre>
589 <a name="54"></a><hr />
590 <pre>
591 utility for sorting records in complex ways:
592
593 % msort
594 </pre>
595 <a name="55"></a><hr />
596 <pre>
597 a smaller, cheaper, faster SED implementation:
598
599 % minised
600 </pre>
601 <a name="56"></a><hr />
602 <pre>
603 zsh tips:
604
605 % man zsh-lovers
606
607 See: http://grml.org/zsh/
608 </pre>
609 <a name="57"></a><hr />
610 <pre>
611 zsh reference card for grml system:
612
613 http://grml.org/zsh/
614 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
615 </pre>
616 <a name="58"></a><hr />
617 <pre>
618 Multiple rename:
619
620 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
621 % qmv foo*
622 % prename 's/foo/bar/' foo*
623 % mmv "foo*"   "bar#1"
624 % zmv 'foo(*)' 'bar$1'
625 </pre>
626 <a name="59"></a><hr />
627 <pre>
628 Test TFT / LCD display:
629
630 % lcdtest
631 </pre>
632 <a name="60"></a><hr />
633 <pre>
634 Test sound:
635
636 % soundtest
637 </pre>
638 <a name="61"></a><hr />
639 <pre>
640 Improved grep version:
641
642 % glark
643 </pre>
644 <a name="62"></a><hr />
645 <pre>
646 Grep with highlighting:
647
648 % grep --color=auto ...
649 % hgrep ...
650
651 Tags: grep, color, highlight
652 </pre>
653 <a name="63"></a><hr />
654 <pre>
655 Extract matches when grepping:
656
657 Usage examples:
658 % ifconfig | grepc 'inet addr:(.*?)s'
659 % ifconfig | glark --extract-matches 'inet addr:(.*?)s'
660 </pre>
661 <a name="64"></a><hr />
662 <pre>
663 Output text as sound:
664
665 % say 'ghroummel'
666 % xsay            # when running X and text selected via mouse
667 </pre>
668 <a name="65"></a><hr />
669 <pre>
670 Adjust a grml harddisk (grml2hd) installation:
671
672 # grml2hd-utils
673
674 Tags: grml2hd, configuration, installation
675 </pre>
676 <a name="66"></a><hr />
677 <pre>
678 Get information on movie files:
679
680 % tcprobe -i file.avi
681 </pre>
682 <a name="67"></a><hr />
683 <pre>
684 Get an overview of your image files:
685
686 % convert 'vid:*.jpg' thumbnails.jpg
687 </pre>
688 <a name="68"></a><hr />
689 <pre>
690 List all standard defines:
691
692 % gcc -dM -E - &lt; /dev/null
693 </pre>
694 <a name="69"></a><hr />
695 <pre>
696 Send a mail as reminder:
697
698 echo "mail -s 'check TODO-list' $MAILADDRESS &lt; /dev/null" | at 23:42
699 </pre>
700 <a name="70"></a><hr />
701 <pre>
702 ncurses-based presentation tool:
703
704 % tpp
705
706 See: man tpp and /usr/share/doc/tpp/examples/
707 </pre>
708 <a name="71"></a><hr />
709 <pre>
710 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
711
712 % centericq
713 </pre>
714 <a name="72"></a><hr />
715 <pre>
716 Use IRC on command line:
717
718 % irssi
719 </pre>
720 <a name="73"></a><hr />
721 <pre>
722 Diff / merge files:
723
724 % vimdiff file1 file2
725
726 Re-diffing:
727
728 :diffupdate
729
730 Moving between diffs:
731
732 [c
733 ]c
734
735 Synchronizing:
736
737 :diffget
738 :diffput
739 </pre>
740 <a name="74"></a><hr />
741 <pre>
742 Hardware monitoring without kernel dependencies:
743
744 % mbmon
745 </pre>
746 <a name="75"></a><hr />
747 <pre>
748 Install grml-iso to usb-stick:
749
750 % grml2usb grml.iso /mount/point
751
752 Tags: usbpen, usbstick, installation, grml2usb
753 </pre>
754 <a name="76"></a><hr />
755 <pre>
756 Use mplayer on framebuffer console:
757
758 % mplayer -vo fbdev ...
759 </pre>
760 <a name="77"></a><hr />
761 <pre>
762 Use links2 on framebuffer console:
763
764 % links2 -driver fb ...
765 </pre>
766 <a name="78"></a><hr />
767 <pre>
768 Switch language / keyboard:
769
770 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
771 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
772   Usage example: 'grml lang=us keyboard=de xkeyboard=de'
773
774 Or run one of the following commands:
775
776 % grml-lang de
777 or
778 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
779 % setxkbmap de                                      # X11
780
781 Tags: language, keyboard, configuration
782 </pre>
783 <a name="79"></a><hr />
784 <pre>
785 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
786
787 # caps-ctrl
788 </pre>
789 <a name="80"></a><hr />
790 <pre>
791 Mount usb device / usb stick:
792
793 % mount /mnt/external1   # corresponds to /dev/sda1
794 or
795 % mount /mnt/external    # corresponds to /dev/sda
796 </pre>
797 <a name="81"></a><hr />
798 <pre>
799 Install Sun Java packages:
800
801 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
802
803 # apt-get install java-package
804 # fakeroot make-jpkg j2re-*.bin
805 # dpkg -i sun-j2re*.deb
806 # update-alternatives --config java
807 </pre>
808 <a name="82"></a><hr />
809 <pre>
810 Improved dd version:
811
812 ddrescue is an improved version of dd which tries to read and
813 if it fails it will go on with the next sectors, where tools
814 like dd will fail.
815
816 % ddrescue ...
817
818 See: man ddrescue
819 </pre>
820 <a name="83"></a><hr />
821 <pre>
822 How to make an audio file (e.g. Musepack format) out of a DVD track:
823
824 % mkfifo /tmp/fifo.wav
825 % mppenc /tmp/fifo.wav track06.mpc &
826 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
827
828 Adjust the mppenc line with the encoder you would like to use,
829 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
830
831 Alternative:
832
833 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
834 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
835
836 Usage example for getting a PCM/wave file from audio channel 128:
837 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
838 </pre>
839 <a name="84"></a><hr />
840 <pre>
841 Create simple chroot:
842
843 # make_chroot_jail $USERNAME
844 </pre>
845 <a name="85"></a><hr />
846 <pre>
847 Convert DOS formated file to unix format:
848
849 sed 's/.$//'    dosfile &gt; unixfile       # assumes that all lines end with CR/LF
850 sed 's/^M$//'   dosfile &gt; unixfile       # in bash/tcsh, press Ctrl-V then Ctrl-M
851 sed 's/x0D$//' dosfile &gt; unixfile       # gsed 3.02.80, but top script is easier
852 awk '{sub(/r$/,"");print}'              # assumes EACH line ends with Ctrl-M
853 gawk -v BINMODE="w" '1' infile &gt;outfile  # in DOS environment; cannot be done with
854                                          # DOS versions of awk, other than gawk
855 tr -d r &lt; dosfile &gt; unixfile            # GNU tr version 1.22 or higher
856 tr -d '015' &lt; dosfile &gt; unixfile        # use octal value for "r" (see man ascii)
857 tr -d '[015032]' &lt; dosfile &gt; unixfile  # sometimes ^Z is appended to DOS-files
858 vim -c ":set ff=unix" -c ":wq" file      # convert using vim
859 vim -c "se ff=dos|x" file                # ... and even shorter ;)
860 recode ibmpc..lat1 file                  # convert using recode
861 echo -e "s/r//g" &gt; dos2unix.sed; sed -f dos2unix.sed &lt; dosfile > unixfile
862
863 Tags: windows, line, convert, recode, tr, line end,
864 </pre>
865 <a name="86"></a><hr />
866 <pre>
867 Save live audio stream to file:
868
869 % mplayer -ao pcm:file=$FILE $URL
870 </pre>
871 <a name="87"></a><hr />
872 <pre>
873 Save live stream to file:
874
875 % mplayer -dumpfile $FILE -dumpstream $STREAM
876
877 or
878
879 % mencoder mms://$URL -o $FILE -ovc copy -oac copy
880
881 or
882
883 % mimms mms://file.wmv
884 </pre>
885 <a name="88"></a><hr />
886 <pre>
887 Merge video files:
888
889 AVI:
890
891 % avimerge -i *.avi -o blub.avi
892
893 MPEG:
894
895 % cat *.mpg &gt; blub.mpg
896
897 WMV:
898
899 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
900 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
901 % avimerge -i file1.avi file2.avi -o blub.avi
902 </pre>
903 <a name="89"></a><hr />
904 <pre>
905 Display MS-Word file:
906
907 % strings file.doc | fmt | less
908
909 or
910
911 % antiword file.doc
912 </pre>
913 <a name="90"></a><hr />
914 <pre>
915 Convert MS-Word file to postscript:
916
917 % antiword -p a4 file.doc &gt; file.ps
918 </pre>
919 <a name="91"></a><hr />
920 <pre>
921 Convert manual to postscript:
922
923 % zcat /usr/share/man/man1/zsh.1.gz | groff -man &gt; zsh.1.ps
924 or
925 % man -t zsh &gt; zsh.ps
926 </pre>
927 <a name="92"></a><hr />
928 <pre>
929 Read BIOS:
930
931 % dd if=/dev/mem bs=1k skip=768 count=256 2&gt;/dev/null | strings -n 8
932 </pre>
933 <a name="93"></a><hr />
934 <pre>
935 Read HTTP via netcat:
936
937 echo -e "GET / HTTP/1.1rnHost: $DOMAINrnrn" | netcat $DOMAIN 80
938 </pre>
939 <a name="94"></a><hr />
940 <pre>
941 Get X ressources for specific program:
942
943 % xrdb -q |grep -i xterm
944 </pre>
945 <a name="95"></a><hr />
946 <pre>
947 Get windowid of specific X-window:
948
949 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
950 </pre>
951 <a name="96"></a><hr />
952 <pre>
953 Get titel of specific X-window:
954
955 % xprop WM_CLASS
956 </pre>
957 <a name="97"></a><hr />
958 <pre>
959 check locale - LC_MESSAGES:
960
961 % locale -ck LC_MESSAGES
962 </pre>
963 <a name="98"></a><hr />
964 <pre>
965 Create random password:
966
967 % pwgen
968 or
969 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
970 </pre>
971 <a name="99"></a><hr />
972 <pre>
973 Get tarballs of various Linux Kernel trees:
974
975 % ketchup 2.6
976 to get the current stable 2.6 release
977
978 % ketchup -l
979 to get a list of all supported trees
980 </pre>
981 <a name="100"></a><hr />
982 <pre>
983 Transfer your SSH public key to another host:
984
985 % ssh-keygen   # ssh-keygen / ssh-key-gen: if you don't have a key yet
986 [...]
987 % ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
988 or
989 % cat $HOME/.ssh/id_rsa.pub  | ssh user@remote-system 'cat &gt;> .ssh/authorized_keys'
990
991 Tags: ssh, ssh key, public key, ssh-copy-id, ssh-keygen
992 </pre>
993 <a name="101"></a><hr />
994 <pre>
995 Update /etc/fstab entries:
996
997 # grml-rebuildfstab
998
999 See "man grml-rebuildfstab" for more details about
1000 generation of /etc/fstab (including stuff like
1001 fs LABELs / UUIDs,...).
1002 </pre>
1003 <a name="102"></a><hr />
1004 <pre>
1005 Fetch and potentially change SCSI device parameters:
1006
1007 # sdparm /dev/sda
1008
1009 See: man sdparm
1010 </pre>
1011 <a name="103"></a><hr />
1012 <pre>
1013 reclaim disk space by linking identical files together:
1014
1015 % dupmerge...
1016 </pre>
1017 <a name="104"></a><hr />
1018 <pre>
1019 Find and remove duplicate files:
1020
1021 % dupseek ...
1022 </pre>
1023 <a name="105"></a><hr />
1024 <pre>
1025 Perform layer 2 attacks:
1026
1027 # yersinia ...
1028
1029 Tags: network, attack, security
1030 </pre>
1031 <a name="106"></a><hr />
1032 <pre>
1033 rootsh
1034 </pre>
1035 <a name="107"></a><hr />
1036 <pre>
1037 Guess PC-type hard disk partitions / partition table:
1038
1039 # gpart &lt;options&gt;
1040
1041 Perform a standard scan:
1042 # gpart /dev/ice
1043
1044 Write back the guessed table:
1045 # gpart -W /dev/ice /dev/ice
1046
1047 Tags: partition, recovery, disk
1048 </pre>
1049 <a name="108"></a><hr />
1050 <pre>
1051 Develop, test and use exploit code with the Metasploit Framework:
1052
1053 cd /tmp
1054 wget http://spool.metasploit.com/releases/framework-3.2.tar.gz
1055 unp framework-3.2.tar.gz
1056 cd framework-3.2
1057 ./msfcli
1058 </pre>
1059 <a name="109"></a><hr />
1060 <pre>
1061 Useful documentation:
1062
1063 % w3m   /usr/share/doc/Debian/reference/reference.en.html
1064 or
1065 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
1066
1067 http://grml.org/docs/           grml Documentation
1068 http://wiki.grml.org/           grml Wiki
1069 http://www.debian.org/doc/      Debian Documentation
1070 http://wiki.debian.org/         Debian Wiki
1071 http://www.gentoo.org/doc/en/   Gentoo Documentation
1072 http://gentoo-wiki.com/         Gentoo Wiki
1073 http://www.tldp.org/            The Linux Documentation Project
1074
1075 Tips and tricks:
1076
1077 % fortune debian-hints
1078
1079 Tags: documentation
1080 </pre>
1081 <a name="110"></a><hr />
1082 <pre>
1083 Fun stuff:
1084
1085 % fortune debian-hints
1086 % dpkg -L funny-manpages
1087 </pre>
1088 <a name="111"></a><hr />
1089 <pre>
1090 Backup master boot record (MBR):
1091
1092 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
1093
1094 Tags: backup, mbr
1095 </pre>
1096 <a name="112"></a><hr />
1097 <pre>
1098 Backup partition table:
1099
1100 # sfdisk -d /dev/hda &gt; hda.out
1101
1102 Restore partition table:
1103
1104 # sfdisk /dev/hda &lt; hda.out
1105
1106 Tags: backup, partition, sfdisk, recovery
1107 </pre>
1108 <a name="113"></a><hr />
1109 <pre>
1110 Clone disk via network using netcat:
1111
1112 Listener:
1113 # nc -vlp 30000 &gt; hda1.img
1114 Source:
1115 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
1116
1117 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
1118 to tune speed:
1119
1120 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
1121
1122 Tags: network, backup, dd, netcat
1123 </pre>
1124 <a name="114"></a><hr />
1125 <pre>
1126 Backup specific directories via cpio and ssh:
1127
1128 # for f in directory_list; do find $f &gt;> backup.list done
1129 # cpio -v -o --format=newc &lt; backup.list | ssh user@host "cat &gt; backup_device"
1130
1131 Tags: backup
1132 </pre>
1133 <a name="115"></a><hr />
1134 <pre>
1135 Clone disk via ssh:
1136
1137 This one uses CPU cycles on the remote server to compare the files:
1138 # ssh target_address cat remotefile | diff - localfile
1139 # cat localfile | ssh target_address diff - remotefile
1140
1141 This one uses CPU cycles on the local server to compare the files:
1142 # ssh target_address cat &lt;localfile "|" diff - remotefile
1143
1144 Tags: network, backup, ssh
1145 </pre>
1146 <a name="116"></a><hr />
1147 <pre>
1148 Useful tools for cloning / backups:
1149
1150 * dd: convert and copy a file
1151 * dd_rescue: copies data from one file (or block device) to another
1152 * pcopy: a replacement for dd
1153 * partimage: back up and restore disk partitions
1154 * dirvish: Disk based virtual image network backup system
1155 * devclone: in-place filesystem conversion -- device cloning
1156 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
1157 * dump: ext2/3 filesystem backup
1158 * udpcast: multicast file transfer tool
1159 * cpio: copy files to and from archives
1160 * pax: read and write file archives and copy directory hierarchies
1161 * netcat / ssh / tar / gzip / bzip2: additional helper tools
1162
1163 Tags: network, backup, ssh, udp, rescue, recovery
1164 </pre>
1165 <a name="117"></a><hr />
1166 <pre>
1167 Use grml as a rescue system:
1168
1169 Different tools:
1170
1171   * dd: convert and copy a file
1172   * ddrescue: copies data from one file or block device to another
1173   * partimage: Linux/UNIX utility to save partitions in a compressed image file
1174   * cfdisk: Partition a hard drive
1175   * nparted: Newt and GNU Parted based disk partition table manipulator
1176   * parted-bf: The GNU Parted disk partition resizing program, small version
1177   * testdisk: Partition scanner and disk recovery tool
1178   * gpart: Guess PC disk partition table, find lost partitions
1179
1180 ext2/ext3:
1181
1182   * e2fsprogs: ext2 file system utilities and libraries
1183   * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
1184   * e2undel: Undelete utility for the ext2 file system
1185   * ext2resize: an ext2 filesystem resizer
1186   * recover: Undelete files on ext2 partitions
1187
1188 ReiserFS/Reiser4:
1189
1190   * reiser4progs: administration utilities for the Reiser4 filesystem
1191   * reiserfsprogs: User-level tools for ReiserFS filesystems
1192
1193 XFS:
1194
1195   * xfsdump: Administrative utilities for the XFS filesystem
1196   * xfsprogs: Utilities for managing the XFS filesystem
1197
1198 JFS:
1199
1200   * jfsutils: utilities for managing the JFS filesystem
1201
1202 NTFS:
1203
1204   * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
1205   * salvage-ntfs: free NTFS data recovery tools
1206   * scrounge-ntfs: data recovery program for NTFS file systems
1207   * ntfsresize: resize ntfs partitions
1208
1209 Tags: ntfs, jfs, xfs, ext3, rescue, recovery, backup, filesystem, tools
1210 </pre>
1211 <a name="118"></a><hr />
1212 <pre>
1213 Get ASCII value of a character with zsh:
1214
1215 % char=N ; print $((#char))
1216 </pre>
1217 <a name="119"></a><hr />
1218 <pre>
1219 Convert a collection of mp3 files to wave or cdr using zsh:
1220
1221 % for i (./*.mp3){mpg321 --w - $i &gt; ${i:r}.wav}
1222 </pre>
1223 <a name="120"></a><hr />
1224 <pre>
1225 Convert images (foo.gif to foo.png) using zsh:
1226
1227 % for i in **/*.gif; convert $i $i:r.png
1228 </pre>
1229 <a name="121"></a><hr />
1230 <pre>
1231 Remove all "non txt" files using zsh:
1232
1233 % rm ./^*.txt
1234 </pre>
1235 <a name="122"></a><hr />
1236 <pre>
1237 Remote Shell Using SSH:
1238
1239 remote host:
1240 % ssh -NR 3333:localhost:22 user@yourhost
1241
1242 local host:
1243 % ssh user@localhost -p 3333
1244
1245 Tags: port forwarding, ssh, remote port, network
1246 </pre>
1247 <a name="123"></a><hr />
1248 <pre>
1249 Reverse Shell with Netcat:
1250
1251 local host:
1252 % netcat -v -l -p 3333 -e /bin/sh
1253
1254 remote host:
1255 % netcat 192.168.0.1 3333
1256
1257 TagS: port forwarding, ssh, remote, network
1258 </pre>
1259 <a name="124"></a><hr />
1260 <pre>
1261 Reverse Shell via SSH:
1262
1263 local host (inside the network):
1264 % ssh -NR 1234:localhost:22 remote_host
1265
1266 remote host (outside the network):
1267 % ssh localhost -p 1234
1268
1269 Tags: port forwarding, ssh, remote port, network
1270 </pre>
1271 <a name="125"></a><hr />
1272 <pre>
1273 Remove empty directories with zsh:
1274
1275 % rmdir ./**/*(/od) 2&gt; /dev/null
1276 </pre>
1277 <a name="126"></a><hr />
1278 <pre>
1279 Find all the empty directories in a tree with zsh:
1280
1281 % ls -ld *(/^F)
1282 </pre>
1283 <a name="127"></a><hr />
1284 <pre>
1285 Find all files without a valid owner and change ownership with zsh:
1286
1287 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(&lt;/etc/passwd)"}%%:*}:)
1288 </pre>
1289 <a name="128"></a><hr />
1290 <pre>
1291 Display the 5-10 last modified files with zsh:
1292
1293 % print -rl -- /path/to/dir/**/*(D.om[5,10])
1294 </pre>
1295 <a name="129"></a><hr />
1296 <pre>
1297 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
1298
1299 % print -rl -- **/*(Dom[1,10])
1300 </pre>
1301 <a name="130"></a><hr />
1302 <pre>
1303 Find most recent file in a directory with zsh:
1304
1305 % setopt dotglob ; print directory/**/*(om[1])
1306 </pre>
1307 <a name="131"></a><hr />
1308 <pre>
1309 Tunnel all traffic through an external server:
1310
1311 % ssh -ND 3333 username@external.machine
1312
1313 Then set the SOCKS4/5 proxy to localhost:3333.
1314 Check whether it's working by surfing e.g. to checkip.dyndns.org
1315
1316 Tags: ssh, network, proxy, socks, tunnel
1317 </pre>
1318 <a name="132"></a><hr />
1319 <pre>
1320 Tunnel everything through SSH via tsocks:
1321
1322 set up the SSH proxy on the client side:
1323
1324 % ssh -ND 3333 user@remote.host.example.com
1325
1326 Adjust /etc/tsocks.conf afterwards (delete all other lines):
1327
1328 server = 127.0.0.1
1329 server_port = 3333
1330
1331 For programs who natively support proxying connections (e.g. Mozilla
1332 Firefox) you can now set the proxy address to localhost port 3333.
1333
1334 All other programs which's connections you want to tunnel through your
1335 external host are prefixed with tsocks, e.g.:
1336
1337 % tsocks netcat example.com 80
1338 % tsocks irssi -c irc.quakenet.eu.org -p 6667
1339
1340 If you call tsocks without parameters it executes a shell witht the
1341 LD_PRELOAD environment variable already set and exported.
1342
1343 Tags: ssh, network, proxy, socks, tunnel, tsocks
1344 </pre>
1345 <a name="133"></a><hr />
1346 <pre>
1347 smartctl - control and monitor utility for harddisks using Self-Monitoring,
1348 Analysis and Reporting Technology (SMART):
1349
1350 # smartctl --all /dev/ice
1351
1352 If you want to use smartctl on S-ATA (sata) disks use:
1353
1354 # smartctl -d ata --all /dev/sda
1355
1356 Start offline test:
1357 # smartctl -t offline /dev/ice
1358
1359 Start short test:
1360 # smartctl -t short /dev/ice
1361
1362 Display results of test:
1363 # smartctl -l selftest /dev/ice
1364
1365 Query device information:
1366 # smartctl -i /dev/ice
1367
1368 Tags: smart, s.m.a.r.t, info, test, hardware
1369 </pre>
1370 <a name="134"></a><hr />
1371 <pre>
1372 Mount a BSD / Solaris partition:
1373
1374 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
1375
1376 Use ufstype 44bsd  for FreeBSD, NetBSD, OpenBSD (read-write).
1377 Use ufstype ufs2   for &gt;= FreeBSD 5.x (read-only).
1378 Use ufstype sun    for SunOS (Solaris) (read-write).
1379 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
1380
1381 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
1382 for more details.
1383
1384 Tags: ufs, bsd, mount, solaris
1385 </pre>
1386 <a name="135"></a><hr />
1387 <pre>
1388 Read BIOS (and or BIOS) password:
1389
1390 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
1391 </pre>
1392 <a name="136"></a><hr />
1393 <pre>
1394 Clone one of the kernel trees via git:
1395
1396  git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
1397                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1398 This path defines the tree. See http://kernel.org/git/ for an overview.
1399 </pre>
1400 <a name="137"></a><hr />
1401 <pre>
1402 Mount filesystems over ssh protocol:
1403
1404 % sshfs user@host:/remote_dir /mnt/test
1405
1406 Unmount via:
1407
1408 % fusermount -u /mnt/test
1409
1410 (Notice: requires fuse kernel module)
1411
1412 Tags: ssh, sshfs, network, mount, directory, remote, fuse
1413 </pre>
1414 <a name="138"></a><hr />
1415 <pre>
1416 Install Gentoo using grml:
1417
1418 See http://www.gentoo.org/doc/en/altinstall.xml
1419 </pre>
1420 <a name="139"></a><hr />
1421 <pre>
1422 Install (plain) Debian (sarge release) via grml:
1423
1424 Assuming you want to install Debian to sda1:
1425
1426 mkfs.ext3 /dev/sda1           # make an ext3 filesystem on /dev/sda1
1427 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1428 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1429 chroot /mnt/test /bin/bash    # let's chroot into the new system
1430 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
1431 mount -t proc   none /proc    # make sure we also have a mounted /proc
1432 base-config                   # now configure some main settings
1433 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
1434 cd /dev ; ./MAKEDEV generic                                # make sure we have all necessary devices for lilo
1435 apt-get install lilo linux-image-2.6.12-1-386              # install lilo and a kernel which fits your needs
1436 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
1437 vi /etc/lilo.conf && lilo                                  # adjust the file for your needs and run lilo afterwards
1438 umount /proc ; umount /dev/pts                             # we do not need them any more
1439 exit                                                       # now leave chroot
1440 cp /etc/hosts /etc/fstab /mnt/test/etc/           # you might want to take the existing files...
1441 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
1442 umount /mnt/test && reboot    # unmount partition and reboot...
1443
1444 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1445 Avoid all of the above steps - use grml-debootstrap(8) instead!
1446
1447 Tags: manual, installation, debian, debootstrap
1448 </pre>
1449 <a name="140"></a><hr />
1450 <pre>
1451 Install (plain) Debian (etch release) via grml
1452
1453 Assuming you want to install Debian to sda1:
1454
1455 mkfs.ext3 /dev/sda1           # make an ext3 filesystem on /dev/sda1
1456 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1457 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1458 chroot /mnt/test /bin/bash    # let's chroot into the new system
1459 mount -t proc   none /proc    # make sure we have a mounted /proc
1460 apt-get install locales console-data  # install locales
1461 dpkg-reconfigure locales console-data # adjust locales to your needs
1462 apt-get install vim most zsh screen less initrd-tools file grub             usbutils pciutils bzip2 sysfsutils dhcp3-client resolvconf          strace lsof w3m # install useful software
1463 apt-get install linux-headers-2.6-686 linux-image-686  # install current kernel
1464
1465 echo "127.0.0.1       localhost" &gt; /etc/hosts   # adjust /etc/hosts and network:
1466 cat &gt;> /etc/network/interfaces &lt;< EOF
1467 iface lo inet loopback
1468 iface eth0 inet dhcp
1469 auto lo
1470 auto eth0
1471 EOF
1472
1473 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1474 cat &gt;> /etc/fstab &lt;< EOF
1475 sysfs          /sys         sysfs   auto                       0   0
1476 proc           /proc        proc    defaults                   0   0
1477 /dev/sda1      /            ext3    defaults,errors=remount-ro 0   1
1478 /dev/sda2      none         swap    sw                         0   0
1479 /dev/cdrom     /mnt/cdrom0  iso9660 ro,user,noauto             0   0
1480 EOF
1481 passwd             # set password of user root
1482
1483 mkdir /boot/grub   # setup grub
1484 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1485 cat &gt;> /boot/grub/menu.lst &lt;< EOF
1486 title           Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1487 root            (hd0,0)
1488 kernel          /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1489 initrd          /boot/initrd.img-2.6.18-3-686
1490 EOF
1491 vim /boot/grub/menu.lst               # adjust grub configuration to your needs
1492 cd /dev && MAKEDEV generic            # create default devices
1493 cp -i /usr/lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1494 grub install  # now install grub, run in grub-cmdline following commands:
1495 &gt; root (hd0,0)
1496 &gt; setup (hd0)
1497 &gt; quit
1498 umount -a # unmount all filesystems in chroot and finally:
1499 exit      # exit the chroot and:
1500 reboot
1501
1502 If you want to use lilo instead of grub take a look at
1503 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1504
1505 cat &gt; /etc/lilo.conf &lt;< EOF
1506 # This allows booting from any partition on disks with more than 1024 cylinders.
1507 lba32
1508
1509 # Specifies the boot device
1510 boot=/dev/sda1
1511
1512 # Specifies the device that should be mounted as root.
1513 root=/dev/sda1
1514
1515 # use Debian on software raid:
1516 # raid-extra-boot=mbr-only
1517
1518 install=text
1519 # prompt
1520 timeout=1
1521 map=/boot/map
1522 vga=normal
1523
1524 image=/boot/vmlinuz-2.6.18-grml
1525         label="2.6.18-grml"
1526         #append="...."
1527         read-only
1528         initrd=/boot/initrd.img-2.6.18-grml
1529 EOF
1530
1531 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1532 Avoid all of the above steps - use grml-debootstrap(8) instead!
1533
1534 Tags: manual, installation, debian, debootstrap, howto
1535 </pre>
1536 <a name="141"></a><hr />
1537 <pre>
1538 Convert files from Unicode / UTF-8 to ISO:
1539
1540 % iconv -c -f utf8 -t iso-8859-15 &lt; utffile &gt; isofile
1541
1542 and vice versa:
1543
1544 % iconv -f iso-8859-15 -t utf8 &lt; isofile &gt; utffile
1545
1546 Tags: utf-8, iso, unicode, utf8
1547 </pre>
1548 <a name="142"></a><hr />
1549 <pre>
1550 Assign static setup for network cards (NICs) via udev:
1551
1552 Retrieve information for address (corresponding to MAC address):
1553
1554   # udevadm info -a -p /sys/class/net/eth0/ | grep -i 'ATTR{address}'
1555
1556 Execute /lib/udev/write_net_rules with according values (INTERFACE
1557 is old NIC name, INTERFACE_NAME is new NIC name and MATCHADDR
1558 is the MAC address retrieved with udevadm info command):
1559
1560   # INTERFACE=eth0 INTERFACE_NAME=lan0  MATCHADDR=00:00:00:00:00:01 /lib/udev/write_net_rules
1561
1562 This will generate file /etc/udev/rules.d/70-persistent-net.rules with content:
1563
1564 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:01", KERNEL=="eth*", NAME="lan0"
1565
1566 Finally take down the interface (ifdown/ifconfig) and execute:
1567
1568   # udevadm trigger --action=add --subsystem-match=net
1569
1570 so the interface will be renamed. (Rebooting or
1571 unloading drivers/restart udev/loading drivers again
1572 works as well of course.)
1573
1574 Tags: udev, configuration, name, eth0, howto
1575 </pre>
1576 <a name="143"></a><hr />
1577 <pre>
1578 Change the suffix from *.sh to *.pl using zsh:
1579
1580 % autoload zmv
1581 % zmv -W '*.sh' '*.pl'
1582 </pre>
1583 <a name="144"></a><hr />
1584 <pre>
1585 Generate SSL certificate:
1586
1587 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1588 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1589
1590 Check certfile:
1591 # openssl x509 -in certfile -text
1592
1593 Verify against CA certificate:
1594 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1595
1596 Generate 2048bit RSA-key:
1597 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1598
1599 As before but add request to existing key pub-sec-key.pem:
1600 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1601
1602 Show request request.pem:
1603 # openssl req -text -noout -in request.pem
1604
1605 Verify signature of request request.pem:
1606 # openssl req -verify -noout -in request.pem
1607
1608 Generate SHA1 fingerprint (modulo key) of request.pem:
1609 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1610
1611 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1612 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1613
1614 As before but create self signed certificate based on existing key pub-sec-key.pem:
1615 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1616
1617 Generate new request out of existing self signed certificate:
1618 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1619
1620 Display certificate self-signed-certificate.pem in plaintext:
1621 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1622
1623 Check self signed certificate:
1624 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1625
1626 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1627 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1628
1629 Generate ssl-certificate for use with apache2:
1630
1631 export RANDFILE=/dev/random
1632 mkdir /etc/apache2/ssl/
1633 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
1634 chmod 600 /etc/apache2/ssl/apache.pem
1635
1636 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1637
1638 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1639
1640 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1641
1642 Tags: openssl, howto
1643 </pre>
1644 <a name="145"></a><hr />
1645 <pre>
1646 Change Windows NT password(s):
1647
1648 # mount -o rw /mnt/hda1
1649 # cd /mnt/hda1/WINDOWS/system32/config/
1650 # chntpw SAM SECURITY system
1651
1652 Notice: if mounting the partition read-write did not work (check syslog!)
1653 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1654
1655 (Be careful with deactivating syskey!)
1656
1657 Tags: password, windows, recovery, chntpw, howto
1658 </pre>
1659 <a name="146"></a><hr />
1660 <pre>
1661 glark - replacement for grep written in Ruby:
1662
1663 A replacement for (or supplement to) the grep family, glark offers:
1664 Perl compatible regular expressions, highlighting of matches,
1665 context around matches, complex expressions and automatic exclusion
1666 of non-text files.
1667
1668 Usage examples:
1669
1670 % glark -y keyword file      # display only the region that matched, not the entire line
1671 % glark -o format print *.h  # search for either "printf" or "format"
1672
1673 More information: man glark
1674 </pre>
1675 <a name="147"></a><hr />
1676 <pre>
1677 Find CD burning device(s):
1678
1679 General information on CD-ROM:
1680 % cat /proc/sys/dev/cdrom/info
1681
1682 Scan using ATA Packet specific SCSI transport:
1683 # cdrecord -dev=ATA -scanbus
1684 # cdrecord-prodvd -s -scanbus dev=ATA
1685
1686 Get specific information for /dev/ice:
1687 # cdrecord dev=/dev/ice -scanbus
1688
1689 Tags: hardware, info, cd burn
1690 </pre>
1691 <a name="148"></a><hr />
1692 <pre>
1693 Create devices in /dev on udev:
1694
1695 For example create md devices (/dev/md0, /dev/md1,...):
1696 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1697
1698 Tags: raid, device
1699 </pre>
1700 <a name="149"></a><hr />
1701 <pre>
1702 Identify network device (NIC):
1703
1704 # ethtool -i $DEVICE
1705
1706 Show NIC statistics:
1707
1708 # ethtool -S $DEVICE
1709
1710 If your NIC shows some aging signs, you may want to be sure:
1711
1712 # ethtool -t $DEVICE
1713
1714 Disable TCP/UDP checksums:
1715
1716 # ethtool -K $DEVICE tx off
1717
1718 Tags: configuration, network, device
1719 </pre>
1720 <a name="150"></a><hr />
1721 <pre>
1722 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1723
1724 Switch to tty12 and take a look at the syslog. If you see something like:
1725
1726   SQUASHFS error: zlib_fs returned unexpected result 0x........
1727   SQUASHFS error: Unable to read cache block [.....]
1728   SQUASHFS error: Unable to read inode [.....]
1729
1730 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1731 Check your CD low-level via running:
1732
1733 # readcd -c2scan dev=/dev/cdrom
1734
1735 If the medium really is ok and it still fails try to boot with deactivated DMA
1736 via using grml nodma at the bootprompt.
1737
1738 Tags: grml2hd, installation, verify, squashfs, error
1739 </pre>
1740 <a name="151"></a><hr />
1741 <pre>
1742 Write a Microsoft compatible boot record (MBR) using ms-sys
1743
1744 Write a Windows 2000/XP/2003 MBR to a device:
1745
1746 # ms-sys -m /dev/ice
1747
1748 Notice: grab ms-sys from http://ms-sys.sourceforge.net/ - demo:
1749
1750  wget http://surfnet.dl.sourceforge.net/sourceforge/ms-sys/ms-sys-2.1.3.tgz
1751  unp ms-sys-2.1.3.tgz
1752  cd ms-sys-2.1.3
1753  make
1754  ./bin/ms-sys ...
1755
1756 Tags: mbr, windows, ms-sys, recovery
1757 </pre>
1758 <a name="152"></a><hr />
1759 <pre>
1760 Use a Vodafone 3G Datacard (UMTS) with Linux:
1761
1762 Plug in your vodafone card and check in syslog whether the appropriate
1763 (probably /dev/ttyUSB0 or /dev/noz0) has been created. If so run:
1764
1765 # comgt -d $DEVICE
1766 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1767
1768 Usage examples:
1769 # comgt -d /dev/ttyUSB0
1770 # wvdial --config /etc/wvdial.conf.umts a1usb
1771
1772 # comgt -d /dev/noz0
1773 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1774
1775 # comgt -d /dev/noz0
1776 # wvdial --config /etc/wvdial.conf.umts dreiusb
1777
1778 # comgt -d /dev/ttyACM0
1779 # wvdial --config /etc/wvdial.conf.umts yesss
1780
1781 If you receive invalid DNS nameservers when connecting, like:
1782
1783 [...]
1784 --&gt; primary   DNS address 10.11.12.13
1785 --&gt; secondary DNS address 10.11.12.14
1786
1787 just provide a working nameserver to resolvconf via:
1788
1789 # echo "nameserver 80.120.17.70" | resolvconf -a ppp0
1790
1791 Notice: some vodafone cards require the nozomi driver (run 'modprobe nozomi' on
1792 your grml system), some other ones require the sierra driver (run
1793 'modprobe sierra').
1794
1795 If your device isn't supported by usbserial yet, manually provide vendor and
1796 product ID when loading the usbserial module. Usage example:
1797
1798 % lsusb
1799 [...]
1800 Bus 004 Device 008: ID 1199:6813 Sierra Wireless, Inc.
1801
1802 # modprobe usbserial vendor=0x1199 product=0x6813
1803
1804 To get a list of available providers execute:
1805
1806 # comgt -s -d /dev/ttyUSB0 /etc/comgt/operator
1807
1808 Tags: umts, 3g, vodafone, sierra, wvdial, ppp, howto
1809 </pre>
1810 <a name="153"></a><hr />
1811 <pre>
1812 hdparm - get/set hard disk parameters
1813
1814 Display the identification info that was obtained from the drive at boot time,
1815 if available:
1816 # hpdarm -i /dev/ice
1817
1818 Request identification info directly from the drive:
1819 # hpdarm -I /dev/ice
1820
1821 Perform timings of device + cache reads for benchmark and comparison purposes:
1822 # hdparm -tT /dev/ice
1823
1824 Tags: hardware, performance, configuration, harddisk
1825 </pre>
1826 <a name="154"></a><hr />
1827 <pre>
1828 bonnie++ - program to test hard drive performance.
1829
1830 # mkdir /mnt/benchmark
1831 # mount /dev/ice /mnt/benchmark
1832 # chmod go+w /mnt/benchmark
1833 # bonnie -u grml -d /mnt/benchmark -s 2000M
1834
1835 Tags: benchmark, harddisk
1836 </pre>
1837 <a name="155"></a><hr />
1838 <pre>
1839 Use gizmo with a bluetooth headset:
1840
1841 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1842 % gizmo --mic $DEVICE --speaker $DEVICE
1843 </pre>
1844 <a name="156"></a><hr />
1845 <pre>
1846 Scan a v4l device for TV stations:
1847
1848 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1849
1850 Then running xawtv should work:
1851
1852 % xawtv
1853 </pre>
1854 <a name="157"></a><hr />
1855 <pre>
1856 Run apt-get with timeout of 3 seconds:
1857
1858 # apt-get -o acquire::http::timeout=3  update
1859
1860 Tags: apt-get
1861 </pre>
1862 <a name="158"></a><hr />
1863 <pre>
1864 Debian GNU/Linux device driver check page
1865
1866 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1867 </pre>
1868 <a name="159"></a><hr />
1869 <pre>
1870 Use dd with status line:
1871
1872 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1873 </pre>
1874 <a name="160"></a><hr />
1875 <pre>
1876 Generate a 512k file of random data with status bar:
1877
1878 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1879 </pre>
1880 <a name="161"></a><hr />
1881 <pre>
1882 Install Grub instead of lilo on grml installation (grml2hd):
1883
1884 install grml:
1885 # grml2hd ....
1886
1887 adjust grub's configuration file menu.lst:
1888 # $EDITOR /boot/grub/menu.lst
1889
1890 now install grub (usage example for /dev/sda1):
1891 # grub install
1892 root (hd0,0)
1893 setup (hd0)
1894
1895 Tags: grml2hd, grub
1896 </pre>
1897 <a name="162"></a><hr />
1898 <pre>
1899 Install Ubuntu using grml:
1900
1901 See https://wiki.ubuntu.com/Installation/FromKnoppix
1902
1903 Tags: ubuntu, installation
1904 </pre>
1905 <a name="163"></a><hr />
1906 <pre>
1907 Resize ext2 / ext3 partition:
1908
1909 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1910 # fsck.ext2 -v -y -f /dev/iceX        # check the filesystem
1911 # resize2fs -p /dev/iceX  $SIZE       # resize it (adjust $SIZE)
1912 # fdisk /dev/ice                      # adjust partition in partition table
1913 # fsck.ext2 -v -y -f /dev/iceX        # check filesystem again
1914 # resize2fs -p /dev/iceX              # resize it to maximum
1915 # tune2fs -j /dev/iceX                # re-enable journal
1916
1917 Tags: resize, ext2, ext3, ext4, partition, howto
1918 </pre>
1919 <a name="164"></a><hr />
1920 <pre>
1921 Tune ext2 / ext3 filesystem:
1922
1923 Check partition first:
1924
1925 # tune2fs -l /dev/iceX
1926
1927 If you don't see dir_index in the list, then enable it:
1928
1929 # tune2fs -O dir_index /dev/iceX
1930
1931 Now run e2fsck with the -D option to have the directories optimized:
1932
1933 # e2fsck -D /dev/iceX
1934
1935 Notice: since e2fsprogs (1.39-1) filesystems are created with
1936 directory indexing and on-line resizing enabled by default.
1937
1938 Tags: configuration, ext2, ext3, ext4, partition
1939 </pre>
1940 <a name="165"></a><hr />
1941 <pre>
1942 Search for printers via network:
1943
1944 # pconf_detect -m NETWORK -i 192.168.0.1/24
1945
1946 Tags: printer, network, scan
1947 </pre>
1948 <a name="166"></a><hr />
1949 <pre>
1950 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1951
1952 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1953
1954 Tags: webdav, mount, mediacenter, gmx
1955 </pre>
1956 <a name="167"></a><hr />
1957 <pre>
1958 System-Profiling using oprofile:
1959
1960 Prepare setup:
1961
1962 # opcontrol --reset
1963 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1964
1965 Start logging:
1966 # opcontrol --start
1967
1968 Now $DO_SOME_TASKS...
1969
1970 Stop logging:
1971 # opcontrol --shutdown
1972
1973 Then take a look at the reports using something like e.g.:
1974 # opreport -t 0.5 --exclude-dependent
1975 # opreport -t 0.5 /path/to/executable_to_check
1976 # opannotate -t 0.5 --source --assembly
1977
1978 Tags: profile, profiling, opcontrol, howto
1979 </pre>
1980 <a name="168"></a><hr />
1981 <pre>
1982 Install ATI's fglrx driver for Xorg / X.org:
1983
1984 Usually there already exist drivers for the grml-system:
1985 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1986
1987 After installing adjust xorg.conf via running:
1988 # aticonfig --initial --input=/etc/X11/xorg.conf
1989
1990 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1991
1992 Tags: xorg, x11, driver, ati
1993 </pre>
1994 <a name="169"></a><hr />
1995 <pre>
1996 Install nvidia driver for Xorg / X.org:
1997
1998 Usually there already exist drivers for the grml-system:
1999 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
2000
2001 Then switch from module nv to nvidia:
2002
2003 # sed -i 's/Driver.*nv.*/Driver      "nvidia"/' /etc/X11/xorg.conf
2004
2005 Tags: xorg, x11, driver, nvidia
2006 </pre>
2007 <a name="170"></a><hr />
2008 <pre>
2009 glxgears - a GLX demo that draws three rotating gears
2010
2011 To print frames per second (fps) use:
2012 % glxgears -printfps
2013
2014 Tags: xorg, x11, glx,
2015 </pre>
2016 <a name="171"></a><hr />
2017 <pre>
2018 You forgot to boot with 'grml noeject noprompt' to avoid
2019 ejecting and prompting for CD removal when rebooting/halting
2020 the system?
2021
2022 Either run:
2023
2024 # noeject reboot
2025
2026 or:
2027
2028 # noeject halt
2029
2030 If you want to avoid only the prompting part, run:
2031
2032 # noprompt reboot
2033
2034 or:
2035
2036 # noprompt halt
2037
2038 Tags: bootparam, fix, grml
2039 </pre>
2040 <a name="172"></a><hr />
2041 <pre>
2042 Mount wikipedia local via fuse:
2043
2044 Adjust configuration:
2045 % cat ~/.wikipediafs/config.xml
2046 &lt;wfs-config&gt;
2047     &lt;general&gt;
2048        &lt;article-cache-time&gt;300</article-cache-time>
2049     &lt;/general&gt;
2050     &lt;sites&gt;
2051       &lt;site&gt;
2052         &lt;dirname&gt;wikipedia-de</dirname>
2053         &lt;host&gt;de.wikipedia.org</host>
2054         &lt;basename&gt;/w/index.php</basename>
2055       &lt;/site&gt;
2056       &lt;site&gt;
2057         &lt;dirname&gt;wikipedia-en</dirname>
2058         &lt;host&gt;en.wikipedia.org</host>
2059         &lt;basename&gt;/w/index.php</basename>
2060       &lt;/site&gt;
2061     &lt;/sites&gt;
2062 &lt;/wfs-config&gt;
2063
2064 Mount it (/wiki must exist of course):
2065 % mount.wikipediafs /wiki
2066 % cat /wiki/wikipedia-en/Cat
2067
2068 Unmount via:
2069 % fusermount -u /wiki
2070
2071 Tags: fuse, wikipedia, mount
2072 </pre>
2073 <a name="173"></a><hr />
2074 <pre>
2075 Remote notification on X via osd (on screen display):
2076
2077 Start osd_server.py at your local host (listens on port 1234 by default):
2078 % osd_server.py
2079
2080 Then login to a $REMOTEHOST
2081 % ssh -R 1234:localhost:1234 $REMOTEHOST
2082
2083 Now send the text to your local display via running something like:
2084 % echo "text to send" | nc localhost 1234
2085
2086 Very useful when you are waiting for a long running job
2087 but want to do something else in the meanwhile:
2088
2089 % ./configure && make && echo "finished compiling" | netcat localhost 1234
2090
2091 You can use this in external programs as well of course. Examples:
2092
2093 Use osd in centericq:
2094
2095 % cat ~/.centericq/external
2096 [...]
2097 %action osd notify
2098 event msg
2099 proto all
2100 status all
2101 options nowait
2102 %exec
2103 #!/bin/bash
2104 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
2105   CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
2106   osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
2107   if echo | socat - TCP4:localhost:1234 &&gt;/dev/null ; then
2108     echo "${osd_msg}" | netcat localhost 1234
2109   fi
2110 fi
2111
2112 Use it in the IRC console client irssi via running:
2113
2114 /script load osd.pl
2115
2116 You can even activate the port forwarding by default globally:
2117
2118 % cat ~/.ssh/config
2119 [...]
2120 Host *
2121 RemoteForward 1234 127.0.0.1:1234
2122 ForwardAgent yes
2123
2124 Notice: if you get 'ABORT: Requested font not found' make sure the
2125 requested font is available, running 'LANG=C LC_ALL=C osd_server.py...'
2126 might help as well.
2127
2128 Tags: osd, notification, ssh, network, port-forwarding
2129 </pre>
2130 <a name="174"></a><hr />
2131 <pre>
2132 Avoid automatical startup of init scripts via invoke-rc.d:
2133
2134 First of all make sure the package policyrcd-script-zg2 (which
2135 provides the /usr/sbin/policy-rc.d interface) is installed.
2136
2137 In policyrcd-script-zg2's configuration file named
2138 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
2139 defined as the interface for handling invoke-rc.d's startup policy.
2140
2141 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf.  By
2142 default you won't notice any differences to Debian's default
2143 behaviour, except that invoke-rc.d won't be executed if a chroot has
2144 been detected (detection: /proc is missing).
2145
2146 If you want to disable automatical startup of newly installed packages
2147 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
2148 /etc/policy-rc.d.conf.
2149
2150 To restore the default behaviour set EXITSTATUS back to '0' in
2151 /etc/policy-rc.d.conf.
2152
2153 Tags: policy, init, script, invode-rc.d
2154 </pre>
2155 <a name="175"></a><hr />
2156 <pre>
2157 Install VMware-Tools for grml:
2158
2159 First of all make sure a CD-ROM device in VMware is available.
2160
2161 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
2162 the tools running:
2163
2164 cd /tmp
2165 unp /mnt/cdrom/vmware-linux-tools.tar.gz
2166 cd vmware-tools-distrib
2167 ./vmware-install.pl
2168
2169 /etc/init.d/networking stop
2170 rmmod pcnet32
2171 rmmod vmxnet
2172 depmod -a
2173 modprobe vmxnet
2174 /etc/init.d/networking start
2175
2176 In an X terminal, launch the VMware Tools running:
2177
2178 vmware-toolbox
2179
2180 Tags: vmware, tool, vmware-toolbox, howto
2181 </pre>
2182 <a name="176"></a><hr />
2183 <pre>
2184 Some important Postfix stuff
2185
2186 List mail queue:
2187
2188 # mailq
2189 or
2190 # postqueue -p
2191
2192 Send all messages in the queue:
2193
2194 # postqueue -f
2195
2196 Send all messages in the queue for a specific site:
2197
2198 # postqueue -s site
2199
2200 Delete a specific message
2201 # postsuper -d 12345678942
2202
2203 Deletes all messages held in the queue for later delivery
2204 # postsuper -d ALL deferred
2205
2206 Mail queues in postfix:
2207
2208     incoming -&gt; mail who just entered the system
2209     active   -&gt; mail to be delivered
2210     deferred -&gt; mail to be delivered later because there were problems
2211     hold     -&gt; mail that should not be delivered until released from hold
2212
2213 For configuration of postfix take a look at
2214 /etc/postfix/master.cf  - man 5 master
2215 /etc/postfix/main.cf    - man 5 postconf
2216 and http://www.postfix.org/documentation.html.
2217 </pre>
2218 <a name="177"></a><hr />
2219 <pre>
2220 File permissions
2221
2222 mode 4000 - set user ID (suid):
2223
2224 - for executable files: run as the user who owns the file, instead of the
2225   user who runs the file
2226 - for directories: not used
2227
2228 mode 2000 - set group ID (guid):
2229
2230 - for executable files: run as the group who owns the file, instead of the
2231   group of the user who runs the file
2232 - for directories: when a file is created inside the directory, it belongs
2233   to the group of the directory instead of the default group of the user who
2234   created the file
2235
2236 mode 1000 - sticky bit:
2237
2238 - for files: not used
2239 - for directories: only the owner of a file can delete or rename the file
2240
2241 Tags: postix, mailq, postsuper, queue, delete, smtp
2242 </pre>
2243 <a name="178"></a><hr />
2244 <pre>
2245 Create MySQL database
2246
2247 # apt-get install mysql-client mysql-server
2248
2249 Run 'mysql' as root - create a database with:
2250
2251 create database grml
2252
2253 Give a user access to the database (without password):
2254
2255 grant all on grml.* to mika;
2256
2257 Give a user access to the database (with password):
2258
2259 grant all on grml.* to enrico identified by "PASSWORD";
2260
2261 Tags: mysql, database
2262 </pre>
2263 <a name="179"></a><hr />
2264 <pre>
2265 Setup an HTTPS website:
2266
2267 Create a certificate:
2268
2269 # mkdir /etc/apache2/ssl
2270 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
2271
2272 Create a virtual host on port 443:
2273
2274 &lt;VirtualHost www.foo.invalid:443&gt;
2275 [...]
2276 &lt;/VirtualHost&gt;
2277
2278 Enable SSL in the VirtualHost:
2279
2280 SSLEngine On
2281 SSLCertificateFile /etc/apache2/ssl/apache.pem
2282
2283 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
2284
2285 Listen 443
2286
2287 and make sure the SSL module is used:
2288
2289 # a2enmod ssl
2290
2291 Tags: ssl, https, configuration, apache
2292 </pre>
2293 <a name="180"></a><hr />
2294 <pre>
2295 Useful Apache / Apache2 stuff
2296
2297 Check configuration file via running:
2298
2299 # apache2ctl configtest
2300
2301 Enable a site:
2302
2303 # a2ensite sitename
2304
2305 Enable a module
2306
2307 # a2enmod modulename
2308
2309 Tags: apache, configuration
2310 </pre>
2311 <a name="181"></a><hr />
2312 <pre>
2313 Create tar archive and store it on remote machine:
2314
2315 % tar zcf - /sourcedir | ssh user@targethost "cat &gt;file.tgz"
2316
2317 Tags: tar, backup, remote, network, ssh
2318 </pre>
2319 <a name="182"></a><hr />
2320 <pre>
2321 Pick out and displays images from network traffic:
2322
2323 # driftnet
2324
2325 Tags: remote, network, sniff, image
2326 </pre>
2327 <a name="183"></a><hr />
2328 <pre>
2329 Install Flash plugin:
2330
2331 # dpkg-reconfigure flashplugin-nonfree
2332
2333 Tags: flash, plugin
2334 </pre>
2335 <a name="184"></a><hr />
2336 <pre>
2337 To test a proxy, low level way:
2338
2339 % telnet proxy 8080
2340 [...]
2341 GET http://www.google.com HTTP/1.0 [press enter twice]
2342
2343 Tags: proxy
2344 </pre>
2345 <a name="185"></a><hr />
2346 <pre>
2347 Adjust system for use of qemu with kqemu:
2348
2349 Make sure you have all you need:
2350 # aptitude update ; aptitude install qemu kqemu-modules-$(uname -r)
2351
2352 Then set up kqemu:
2353
2354 modprobe kqemu
2355 mknod /dev/kqemu c 250 0
2356 chmod 666 /dev/kqemu
2357 chmod 666 /dev/net/tun
2358
2359 Check kqemu support via starting qemu, press
2360 Ctrl-Alt-2 and entering 'info kqemu'.
2361 </pre>
2362 <a name="186"></a><hr />
2363 <pre>
2364 (High-Load) Debugging related tools:
2365
2366 mpstat  # report processors related statistics
2367 iostat  # report CPU statistics and input/output statistics for devices and partitions
2368 vmstat  # report virtual memory statistics
2369 slabtop # display kernel slab cache information in real time
2370 atsar   # system activity report
2371 dstat   # versatile tool for generating system resource statistics
2372
2373 Usage examples:
2374
2375 # mpstat -P ALL
2376 # iostat -x 1
2377 # iostat -xtc 5 3
2378 # vmstat 1
2379 # atsar -t 60 10
2380 # dstat -af
2381
2382 Tags: test, debug, information, hardware, statistic
2383 </pre>
2384 <a name="187"></a><hr />
2385 <pre>
2386 Using WPA for network setup manually:
2387
2388 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
2389
2390 Adjust the options and configuration file to your needs.
2391 Also take a look at 'grml-network'.
2392
2393 Tags: wireless, wpa, network, configuration
2394 </pre>
2395 <a name="188"></a><hr />
2396 <pre>
2397 Start X and lock console via exiting:
2398
2399 % startx 2&gt;~/.xsession-errors &| exit
2400
2401 Tags: xorg, x11, startx, graphical
2402 </pre>
2403 <a name="189"></a><hr />
2404 <pre>
2405 Which process is writing to disk and/or causes the disk to spin up?
2406
2407 First of all use lsof to check what's going on. Does not help? -&gt;
2408
2409 # echo 1 &gt; /proc/sys/vm/block_dump
2410
2411 The command sets a sysctl to cause the kernel to log all disk
2412 writes. Please notice that there is a lot of data.  So please
2413 disable syslogd/syslog-ng before you do this, or you must make
2414 sure that kernel output is not logged.
2415
2416 When you're done, disable block dump using:
2417 # echo 0 &gt; /proc/sys/vm/block_dump
2418
2419 Alternative:
2420 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
2421 which handles block_dump on its own.
2422
2423 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2424
2425 Also take a look at event-viewer(8) which is part of grml-debugtools.
2426
2427 Tags: debug, device, block, partition
2428 </pre>
2429 <a name="190"></a><hr />
2430 <pre>
2431 Install initrd via initramfs-tools for currently running kernel:
2432
2433 # update-initramfs -c -t -k $(uname -r)
2434
2435 Tags: initrd
2436 </pre>
2437 <a name="191"></a><hr />
2438 <pre>
2439 Install initrd via yaird for currently running kernel:
2440
2441 # yaird -o /boot/initrd.img-$(uname -r)
2442
2443 Install initrd via yaird for specific kernel:
2444
2445 # mount /proc
2446 # mount /sys
2447 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
2448 </pre>
2449 <a name="192"></a><hr />
2450 <pre>
2451 Reinstall package with its original configuration files:
2452
2453 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o   DPkg::Options::=--force-confnew package
2454 </pre>
2455 <a name="193"></a><hr />
2456 <pre>
2457 grml 0.8 funkenzutzler - rt2x00 drivers:
2458
2459 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
2460 includes beta-version drivers) is not installed by default. If you want to
2461 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
2462 rt73usb please install the package manually running:
2463
2464 # dpkg -i /usr/src/rt2x00-modules-*.deb
2465 </pre>
2466 <a name="194"></a><hr />
2467 <pre>
2468 Use Java with jikes and jamvm on grml:
2469
2470 Simple demo:
2471
2472 % cp /usr/share/doc/grml-templates/template.java .
2473 % jikes template.java
2474 % jamvm HelloWorld
2475
2476 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
2477 so you do not have to manually run
2478 jikes --bootclasspath /usr/share/classpath/glibj.zip
2479 </pre>
2480 <a name="195"></a><hr />
2481 <pre>
2482 Online resizing of (Software-)RAID5:
2483
2484 # Initiate a RAID5 setup for testing purposes:
2485 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
2486
2487 # Create filesystem, mount md0, create a testfile and save md5sum for
2488 # later check:
2489 mkfs.ext3 /dev/md0
2490 mount /dev/md0 /mnt/test
2491 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
2492 md5sum /mnt/test/dd &gt; md5sum
2493
2494 # Make sure the RAID is synched via checking:
2495 cat /proc/mdstat
2496
2497 # Now remove one partition:
2498 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
2499
2500 # Delete partition, create a new + bigger one and set partition type to fd
2501 # (Linux raid autodetect):
2502 cfdisk /dev/hdd
2503
2504 # And re-add the partition:
2505 mdadm -a /dev/md0 /dev/hdd1
2506
2507 # Make sure the RAID is synched via checking:
2508 cat /proc/mdstat
2509
2510 # Repeat the steps for all other disks/partitions as well:
2511 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2512 cfdisk /dev/hdb
2513 mdadm -a /dev/md0 /dev/hdb1
2514 cat /proc/mdstat
2515 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2516 cfdisk /dev/hda
2517 mdadm -a /dev/md0 /dev/hda1
2518 cat /proc/mdstat
2519
2520 # Now resize the RAID5 system online [see 'man mdadm' for details]:
2521 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
2522 mdadm --grow /dev/md0 -z max
2523 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
2524
2525 # Last step - resize the filesystem (online again):
2526 resize2fs /dev/md0
2527
2528 Tags: raid, resize, raid5, mdadm
2529 </pre>
2530 <a name="196"></a><hr />
2531 <pre>
2532 ext3 online resizing:
2533
2534 Starting with Linux kernel 2.6.10 you can resize ext3 online.  With
2535 e2fsprogs &gt;=1.39-1 new filesystems are created with directory indexing and
2536 on-line resizing enabled by default (see /etc/mke2fs.conf).
2537
2538 Demo:
2539
2540 cfdisk /dev/hda                           # create a partition with type 8e (lvm)
2541 pvcreate /dev/hda2                        # create a physical volume
2542 vgcreate resize_me /dev/hda2              # create volume group
2543 lvcreate -n resize_me -L100 resize_me     # create a logical volume
2544 mkfs.ext3 /dev/resize_me/resize_me        # now create a new filesystem
2545 mount /dev/resize_me/resize_me /mnt/test  # mount the new fs for demonstrating online resizing
2546 df -h                                     # check the size of the partition
2547 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
2548 resize2fs /dev/resize_me/resize_me        # and finally resize the filesystem
2549 df -h                                     # recheck the size of the partition
2550
2551 This also works for Software-RAID. Demo:
2552
2553 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
2554 mkfs.ext3 /dev/md0
2555 mount /dev/md0 /mnt/test
2556 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
2557 cfdisk /dev/hda                                  # adjust partition size for hda2
2558 mdadm /dev/md0 --add /dev/hda2
2559 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2560 cfdisk /dev/hdb                                  # adjust partition size for hdb1
2561 mdadm /dev/md0 --add /dev/hdb1
2562 mdadm --grow /dev/md0 --size=max
2563 resize2fs /dev/md0
2564
2565 Notice: online resizing works as soon as the kernel can re-read the
2566 partition table. So it works for example with LVM and SW-RAID but not with
2567 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
2568 table if the device is already mounted.
2569
2570 Tags: resize, raid, lvm, ext2, ext3, ext4, raid1
2571 </pre>
2572 <a name="197"></a><hr />
2573 <pre>
2574 Use vim as an outline editor:
2575
2576 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
2577 % vim ~/foo.otl
2578 :he vo
2579 </pre>
2580 <a name="198"></a><hr />
2581 <pre>
2582 Monitor directories/files for changes using iwatch
2583
2584 Monitor /tmp for changes:
2585 % iwatch /tmp/
2586
2587 Monitor files/directories specified in /etc/iwatch.xml
2588 and send mail on changes:
2589 % iwatch
2590
2591 Tags: inotify, watch, file, directory
2592 </pre>
2593 <a name="199"></a><hr />
2594 <pre>
2595 Some often used mdadm commands:
2596
2597 Set up RAID1:
2598 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
2599
2600 Display details of specific RAID:
2601 # mdadm --detail /dev/md0
2602 # cat /proc/mdstat
2603
2604 Simulating a drive failure by software:
2605 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
2606
2607 Remove disk from RAID:
2608 # mdadm /dev/md0 -r /dev/hda1
2609
2610 Set disk as faulty and remove from RAID:
2611 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2612
2613 Stop a RAID-device:
2614 # mdadm -S /dev/md0
2615
2616 Restart a RAID-device:
2617 # mdadm -R /dev/md0
2618
2619 Add another disk to existing RAID setup (hotadd):
2620 # mdadm /dev/md0 -a /dev/hde1
2621 # mdadm --grow /dev/md0 --raid-devices=4
2622
2623 Assemble and start all arrays:
2624 # mdadm --assemble --scan
2625
2626 Assemble a specific array:
2627 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
2628
2629 Resync:
2630 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
2631
2632 Stop and rebuild:
2633 # mdadm --stop --scan
2634
2635 Scan for and setup arrays automatically:
2636 # mdadm --assemble --scan --auto=yes --verbose
2637
2638 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
2639 DEVICE partitions
2640 CREATE owner=root group=disk mode=0660 auto=yes
2641 HOMEHOST &lt;system&gt;
2642 MAILADDR root
2643
2644 Running
2645 # /usr/share/mdadm/mkconf &gt; /etc/mdadm/mdadm.conf
2646 might help as well.
2647
2648 Monitoring the sw raid
2649 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
2650
2651 Producing /etc/mdadm/mdadm.conf:
2652 # mdadm --detail --scan &gt; /etc/mdadm/mdadm.conf
2653
2654 See also: man mdadm | less -p "^EXAMPLES"
2655           http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
2656
2657 Tags: raid, raid1, raid5, configuration, mdadm, howto
2658 </pre>
2659 <a name="200"></a><hr />
2660 <pre>
2661 A quick summary of the most commonly used RAID levels:
2662
2663 RAID 0: Striped Set
2664  =&gt; 2 disks each 160 GB: 320 GB data
2665 RAID 1: Mirrored Set
2666  =&gt; 2 disks each 160 GB: 160 GB data
2667 RAID 5: Striped Set with Parity
2668  =&gt; 3 disks each 160 GB: 320 GB data; 160 GB redundancy
2669
2670 Common nested RAID levels:
2671 RAID 01: A mirror of stripes
2672 RAID 10: A stripe of mirrors
2673 RAID 30: A stripe across dedicated parity RAID systems
2674 RAID 100: A stripe of a stripe of mirrors
2675
2676   -- http://en.wikipedia.org/wiki/RAID
2677
2678 Tags: raid, raid1, raid5, raid01, raid10, raid100
2679 </pre>
2680 <a name="201"></a><hr />
2681 <pre>
2682 Logical Volume Management (LVM) with Linux
2683
2684 LVM setup layout:
2685 ~~~~~~~~~~~~~~~~~
2686
2687 |    hda1   hdc1      (PV:s on partitions or whole disks)
2688 |          /
2689 |         /
2690 |       diskvg        (VG)
2691 |       /  |  |      /   |   |  usrlv rootlv varlv (LV:s)
2692 |    |      |     |
2693 | ext3    ext3  xfs   (filesystems)
2694
2695 Often used commands:
2696 ~~~~~~~~~~~~~~~~~~~~
2697
2698 Create a physical volume:
2699 # pvcreate /dev/hda2
2700
2701 Create a volume group:
2702 # vgcreate testvg /dev/hda2
2703
2704 Create a logical volume:
2705 # lvcreate -n test_lv -L100 testvg
2706
2707 Resize a logical volume:
2708 # lvextend -L+100M /dev/resize_me/resize_me
2709 # resize2fs /dev/resize_me/resize_me               # ext2/3
2710 # xfs_growfs  /dev/resize_me/resize_me             # xfs
2711 # resize_reiserfs -f /dev/resize_me/resize_me      # reiserfs online
2712 # mount -o remount,resize /dev/resize_me/resize_me # jfs
2713
2714 Create a snapshot of a logical volume:
2715 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2716
2717 Deactivate a volume group:
2718 # vgchange -a n my_volume_group
2719
2720 Actually remove a volume group:
2721 # vgremove my_volume_group
2722
2723 Display information about physical volume:
2724 # pvdisplay /dev/hda1
2725
2726 Remove physical volume:
2727 # vgreduce my_volume_group /dev/hda1
2728
2729 Remove logical volume:
2730 # umount /dev/myvg/homevol
2731 # lvremove /dev/myvg/homevol
2732
2733 See also: man lvm
2734           http://www.tldp.org/HOWTO/LVM-HOWTO/
2735
2736 Tags: lvm, howto, pvcreate, lvcreate
2737 </pre>
2738 <a name="202"></a><hr />
2739 <pre>
2740 How to use APT locally
2741
2742 Sometimes you have lots of packages .deb that you would like to use APT to
2743 install so that the dependencies would be automatically solved. Solution:
2744
2745 mkdir debs
2746 dpkg-scanpackages debs /dev/null | gzip &gt; debs/Packages.gz
2747 echo "  deb file:/root debs/" &gt;> /etc/apt/sources.list
2748 dpkg-scansources debs | gzip &gt; debs/Sources.gz
2749 echo "  deb-src file:/root debs/" &gt;> /etc/apt/sources.list
2750
2751 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2752
2753 Tags: mirror, local
2754 </pre>
2755 <a name="203"></a><hr />
2756 <pre>
2757 Check filesystem's LABEL:
2758
2759 generic way:
2760 # blkid /dev/sda1
2761
2762 ext2/3 without blkid:
2763 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2764
2765 xfs without blkid:
2766 # xfs_admin -l /dev/sda1
2767
2768 reiserfs without blkid:
2769 # debugreiserfs /dev/sda1 | grep -i label
2770
2771 jfs without blkid:
2772 # jfs_tune -l /dev/sda1 | grep -i label
2773
2774 reiser4 without blkid:
2775 # debugfs.reiser4 /dev/sda1 | grep -i label
2776
2777 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, label
2778 </pre>
2779 <a name="204"></a><hr />
2780 <pre>
2781 Check filesystem's UUID:
2782
2783 generic way:
2784 # blkid /dev/sda1
2785
2786 ext2/3 without blkid:
2787 # dumpe2fs /dev/sda1 | grep -i UUID
2788
2789 xfs without blkid:
2790 # xfs_admin -u /dev/sda1
2791
2792 reiserfs without blkid:
2793 # debugreiserfs /dev/sda1 | grep -i UUID
2794
2795 reiser4 without blkid:
2796 # debugfs.reiser4 /dev/sda1 | grep -i UUID
2797
2798 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, uuid
2799 </pre>
2800 <a name="205"></a><hr />
2801 <pre>
2802 Change a filesystem's LABEL:
2803
2804 swap:
2805 # mkswap -L $LABEL /dev/sda1
2806
2807 ext2/ext3:
2808 # e2label /dev/sda1 $LABEL
2809 # tune2fs -L $LABEL /dev/sda1
2810
2811 reiserfs:
2812 # reiserfstune -l $LABEL /dev/sda1
2813
2814 jfs:
2815 # jfs_tune -L $LABEL /dev/sda1
2816
2817 xfs:
2818 # xfs_admin -L $LABEL /dev/sda1
2819
2820 fat/vfat:
2821 # echo 'drive i: file="/dev/sda1"' &gt;> ~/.mtoolsrc
2822 # mlabel -s i:$LABEL
2823
2824 ntfs:
2825 # ntfslabel $LABEL /dev/sda1
2826
2827 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs
2828 </pre>
2829 <a name="206"></a><hr />
2830 <pre>
2831 Disable pdiffs feature of APT:
2832
2833 Permanent:
2834 # echo 'Acquire::PDiffs "false";' &gt;> /etc/apt/apt.conf
2835
2836 Temporary:
2837 # apt-get update -o Acquire::Pdiffs=false
2838 </pre>
2839 <a name="207"></a><hr />
2840 <pre>
2841 Backup big devices or files and create compressed splitted
2842 image chunks of it using zsplit
2843
2844 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2845 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2846 read/write buffer to 256kB:
2847 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2848
2849 Restore the backup using unzsplit:
2850 # unzsplit -D /dev/sda -d archiveofsda
2851
2852 More usage examples: man zsplit + man unzsplit
2853
2854 Tags: backup, reocvery, spllt, limit, howto
2855 </pre>
2856 <a name="208"></a><hr />
2857 <pre>
2858 Measure network performance using iperf:
2859
2860 Server side:
2861 % iperf -s -V
2862
2863 Client side:
2864 % iperf -c &lt;server_address&gt; -V
2865
2866 or
2867
2868 Server with 128k TCP window size:
2869 % iperf -s -w128k
2870
2871 Client with running for 60 seconds and bidirectional test:
2872 % iperf -c &lt;server_address&gt; -r -w128k -t60
2873
2874 Tags: network, benchmark
2875 </pre>
2876 <a name="209"></a><hr />
2877 <pre>
2878 Framebuffer resolutions:
2879
2880                               Resolution in pixels
2881 Color depth      |   640x480      800x600      1024x768      1280x1024
2882 256        (8bit)|     769          771           773           775
2883 32000     (15bit)|     784          787           790           793
2884 65000     (16bit)|     785          788           791           794
2885 16.7 Mill.(24bit)|     786          789           792           795
2886
2887 vga=0x... modes:
2888
2889   Mode 0x0300: 640x400 (+640), 8 bits
2890   Mode 0x0301: 640x480 (+640), 8 bits
2891   Mode 0x0303: 800x600 (+800), 8 bits
2892   Mode 0x0303: 800x600 (+832), 8 bits
2893   Mode 0x0305: 1024x768 (+1024), 8 bits
2894   Mode 0x0307: 1280x1024 (+1280), 8 bits
2895   Mode 0x030e: 320x200 (+640), 16 bits
2896   Mode 0x030f: 320x200 (+1280), 24 bits
2897   Mode 0x0311: 640x480 (+1280), 16 bits
2898   Mode 0x0312: 640x480 (+2560), 24 bits
2899   Mode 0x0314: 800x600 (+1600), 16 bits
2900   Mode 0x0315: 800x600 (+3200), 24 bits
2901   Mode 0x0317: 1024x768 (+2048), 16 bits
2902   Mode 0x0318: 1024x768 (+4096), 24 bits
2903   Mode 0x031a: 1280x1024 (+2560), 16 bits
2904   Mode 0x031b: 1280x1024 (+5120), 24 bits
2905   Mode 0x0330: 320x200 (+320), 8 bits
2906   Mode 0x0331: 320x400 (+320), 8 bits
2907   Mode 0x0332: 320x400 (+640), 16 bits
2908   Mode 0x0333: 320x400 (+1280), 24 bits
2909   Mode 0x0334: 320x240 (+320), 8 bits
2910   Mode 0x0335: 320x240 (+640), 16 bits
2911   Mode 0x0336: 320x240 (+1280), 24 bits
2912   Mode 0x033c: 1400x1050 (+1408), 8 bits
2913   Mode 0x033d: 640x400 (+1280), 16 bits
2914   Mode 0x033e: 640x400 (+2560), 24 bits
2915   Mode 0x0345: 1600x1200 (+1600), 8 bits
2916   Mode 0x0346: 1600x1200 (+3200), 16 bits
2917   Mode 0x034d: 1400x1050 (+2816), 16 bits
2918   Mode 0x035c: 1400x1050 (+5632), 24 bits
2919
2920 Tags: framebuffer, resolution
2921 </pre>
2922 <a name="210"></a><hr />
2923 <pre>
2924 Portscan using netcat:
2925
2926 # netcat -v -w2 &lt;host|ip-addr.&gt; 1-1024
2927 </pre>
2928 <a name="211"></a><hr />
2929 <pre>
2930 Run apt-get but disable apt-listchanges:
2931
2932 APT_LISTCHANGES_FRONTEND=none apt-get ...
2933
2934 Upgrade system but disable apt-listbugs:
2935
2936 APT_LISTBUGS_FRONTEND=none apt-get ...
2937 </pre>
2938 <a name="212"></a><hr />
2939 <pre>
2940 Set up a Transparent Debian Proxy
2941
2942 Install of apt-cacher, the default config will do:
2943 # apt-get install apt-cacher
2944
2945 Check out the ip address of debian mirror(s).
2946 Then add this to your firewall script:
2947
2948 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2949 for ip in ${DEBIAN_MIRRORS} ; do
2950   ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2951 done
2952
2953 where ${IPTABLES} is the location of your iptables binary
2954 and $subnet is your internal subnet.
2955
2956 Now everybody in your subnet who does access either
2957 ftp.de.debian.org or ftp.at.debian.org will actually
2958 access your apt-cacher instead.
2959
2960 To use apt-cacher on the router itself, add the following
2961 line to your /etc/apt/apt.conf:
2962
2963 Acquire::http::Proxy "http://localhost:3142/";
2964
2965 Tags: proxy, debian, apt-get, howto
2966 </pre>
2967 <a name="213"></a><hr />
2968 <pre>
2969 Version control using Mercurial
2970
2971 Setting up a Mercurial project:
2972
2973 % cd project
2974 % hg init           # creates .hg
2975 % hg add            # add all files
2976 % hg commit         # commit all changes, edit changelog entry
2977
2978 Branching and merging:
2979
2980 % hg clone linux linux-work  # create a new branch
2981 % cd linux-work
2982 &lt;make changes&gt;
2983 % hg commit
2984 % cd ../linux
2985 % hg pull ../linux-work     # pull changesets from linux-work
2986 % hg merge                  # merge the new tip from linux-work into
2987                             # (old versions used "hg update -m" instead)
2988                             # our working directory
2989 % hg commit                 # commit the result of the merge
2990
2991 Importing patches:
2992
2993 % cat ../p/patchlist | xargs hg import -p1 -b ../p
2994
2995 Exporting a patch:
2996
2997 (make changes)
2998 % hg commit
2999 % hg tip
3000 1234:af3b5cd57dd5
3001 % hg export 1234 &gt; foo.patch    # export changeset 1234
3002
3003 Export your current repo via HTTP with browsable interface:
3004
3005 % hg serve -n "My repo" -p 80
3006
3007 Pushing changes to a remote repo with SSH:
3008
3009 % hg push ssh://user@example.com/~/hg/
3010
3011 Merge changes from a remote machine:
3012
3013 host1% hg pull http://foo/
3014 host2% hg merge # merge changes into your working directory
3015
3016 Set up a CGI server on your webserver:
3017 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
3018 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
3019 </pre>
3020 <a name="214"></a><hr />
3021 <pre>
3022 Download binary codecs for mplayer:
3023
3024 # /usr/share/mplayer/scripts/win32codecs.sh
3025
3026 or
3027
3028 # /usr/share/mplayer/scripts/binary_codecs.sh install
3029
3030 (depending on the mplayer version you have).
3031
3032 To play encrypted DVDs and if you are living in a country where using
3033 libdvdcss code is not illegal can install Debian package libdvdread3
3034 and use the script /usr/share/doc/libdvdread3/install-css.sh.
3035 </pre>
3036 <a name="215"></a><hr />
3037 <pre>
3038 Read manpages of uninstalled packages with debman:
3039
3040 % debman -p git-core git
3041 </pre>
3042 <a name="216"></a><hr />
3043 <pre>
3044 Test network performance using netperf:
3045
3046 Server:
3047 # netserver
3048
3049 Client:
3050 # netperf -t TCP_STREAM -H 192.168.0.41
3051
3052 Tags: benchmark, network
3053 </pre>
3054 <a name="217"></a><hr />
3055 <pre>
3056 Setup Xen within 20 minutes on Debian/grml
3057
3058 Install relevant software und update grub's menu.lst (Xen does not work with
3059 usual lilo so install grub instead if not done already):
3060
3061 apt-get install linux-image-2.6.18-1-xen-686 xen-hypervisor-3.0.3-1-i386                  xen-utils-3.0.3-1 xen-tools bridge-utils
3062 update-grub
3063
3064 Example for installation of Debian etch as DomU:
3065
3066 mkdir /mnt/md1/xen
3067 xen-create-image --debootstrap --dir=/mnt/md1/xen --size=2Gb --memory=512Mb --fs=ext3    --cache=yes --dist=etch --hostname=xengrml1 --ip 192.168.1.2 --netmask 255.255.255.0   --gateway 192.168.1.1 --initrd=/boot/initrd.img-2.6.18-1-xen-686   --kernel=/boot/vmlinuz-2.6.18-1-xen-686 --mirror=http://ftp.at.debian.org/debian/
3068
3069 Start services:
3070
3071 /etc/init.d/xend start
3072 /etc/init.d/xendomains start
3073
3074 Setup a bridge for network, either manually:
3075
3076 brctl addbr xenintbr
3077 brctl stp xenintbr off
3078 brctl sethello xenintbr 0
3079 brctl setfd xenintbr 0
3080 ifconfig xenintbr 192.168.1.1 netmask 255.255.255.0 up
3081
3082 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
3083 without rebooting):
3084
3085 auto xenintbr
3086 iface xenintbr inet static
3087   pre-up brctl addbr xenintbr
3088   post-down brctl delbr xenintbr
3089   address 192.168.1.1
3090   netmask 255.255.255.0
3091   bridge_fd 0
3092   bridge_hello 0
3093   bridge_stp off
3094
3095 Setup forwarding (adjust $PUBLIC_IP; for permanet setup use /etc/sysctl.conf and
3096 add the iptables commands to a startup script like /etc/init.d/rc.local):
3097
3098 echo 1 &gt; /proc/sys/net/ipv4/ip_forward
3099 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to $PUBLIC_IP
3100 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $PUBLIC_IP
3101
3102 Adjust network configuration of Xend:
3103
3104 cat &gt;> /etc/xen/xend-config.sxp &lt;< EOF
3105 (network-script    network-route)
3106 (vif-bridge        xenintbr)
3107 (vif-script        vif-bridge)
3108 EOF
3109
3110 List domains, start up a DomU, shutdown later again:
3111
3112 xm create -c /etc/xen/xengrml1.cfg
3113 xm list
3114 xm shutdown 1
3115
3116 This HowTo is also available online at http://grml.org/xen/
3117
3118 Tags: howto, xen, grml
3119 </pre>
3120 <a name="218"></a><hr />
3121 <pre>
3122 Play tetris with zsh:
3123
3124 autoload -U tetris
3125 zle -N tetris
3126 bindkey "^Xt" tetris
3127
3128 Now press 'ctrl-x t'.
3129 </pre>
3130 <a name="219"></a><hr />
3131 <pre>
3132 Set up a router with grml
3133
3134 Run grml-router script:
3135 # grml-router
3136
3137 Install dnsmasq if not already present:
3138 # apt-get update ; apt-get install dnsmasq
3139
3140 Adjust /etc/dnsmasq.conf according to your needs:
3141 # cat &gt;> /etc/dnsmasq.conf &lt;< EOF
3142 domain-needed
3143 bogus-priv
3144 dhcp-range=19.168.0.124,192.168.0.254,1m # dhcp range
3145 dhcp-option=3,192.168.0.1   # dns server
3146 dhcp-option=1,255.255.255.0 # netmask
3147 EOF
3148
3149 Start dnsmasq finally:
3150 # Restart dnsmasq
3151
3152 Tags: network, router, grml
3153 </pre>
3154 <a name="220"></a><hr />
3155 <pre>
3156 Display stats about memory allocations performed by a program:
3157
3158 Usage example for 'ls':
3159
3160 % LD_PRELOAD=/lib/libmemusage.so ls &gt; /dev/null
3161 </pre>
3162 <a name="221"></a><hr />
3163 <pre>
3164 Use KVM (Kernel-based Virtual Machine for Linux):
3165
3166 Make sure to install the relevant tools:
3167 # apt-get update ; apt-get install kvm
3168 # modprobe kvm
3169
3170 Test it with a minimal system like ttylinux:
3171 # wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz
3172 # gzip -d bootcd-i386-5.3.iso.gz
3173 # kvm -cdrom bootcd-i386-5.3.iso
3174 </pre>
3175 <a name="222"></a><hr />
3176 <pre>
3177 EEPROM data decoding for SDRAM DIMM modules:
3178
3179 # modprobe eeprom
3180 # /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl
3181 </pre>
3182 <a name="223"></a><hr />
3183 <pre>
3184 Set up and use DVB:
3185
3186 Make sure your device is supported by Linux and running.
3187 See http://www.linuxtv.org/ for more details.
3188
3189 If the DVB device works on your system (see 'hwinfo --usb'
3190 when using a DVB usb device for example), then make sure you
3191 have the scan util from dvb-utils available:
3192
3193 # aptitude install dvb-utils
3194
3195 Then create a channels.conf configuration file:
3196
3197 % scan /usr/share/doc/dvb-utils/examples/scan/... &gt; ~/.mplayer/channels.conf
3198
3199 You can find some example configuration files on
3200 your grml system in ~/.channels. Usage example:
3201
3202 % ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf
3203
3204 Tip: w_scan (see http://free.pages.at/wirbel4vdr/w_scan/index2.html)
3205 might be useful if you do not know the initial configuration
3206 details.
3207 </pre>
3208 <a name="224"></a><hr />
3209 <pre>
3210 Get the lastest mercurial snapshot:
3211
3212 Make sure you have the python-dev package available:
3213 # apt-get update ; apt-get install python-dev
3214
3215 Get and build the source:
3216 % hg clone http://selenic.com/repo/hg mercurial
3217 % cd mercurial
3218 % make local
3219 % export PYTHONPATH=$(pwd)
3220 % export PATH=$PATH:$(pwd)
3221
3222 now you should have the newest version of mercurial whenever you execute hg.
3223
3224 To update to the lastest development snapshot, additionally use
3225 the following commands:
3226 % hg pull -u http://hg.intevation.org/mercurial/crew
3227 % make local
3228 </pre>
3229 <a name="225"></a><hr />
3230 <pre>
3231 Configure timezone
3232 ==================
3233
3234 Available bootoptions relevant in live-cd mode:
3235 -----------------------------------------------
3236
3237 * utc: set UTC, if your system clock is set to UTC (GMT)
3238 * gmt: set UTC, if your system clock is set to UTC (GMT) [like bootoption utc]
3239 * tz=$option: set timezone to corresponding $option, usage example:
3240   tz=Europe/Vienna
3241
3242 Configuration options relevant on harddisk installation:
3243 --------------------------------------------------------
3244
3245 * Use the tzconfig utility to set the local timezone:
3246
3247   # tzconfig
3248
3249   which adjusts /etc/timezone and /etc/localtime according
3250   to the provided information. Running:
3251
3252   # dpkg-reconfigure tzdata
3253
3254   might be useful as well.
3255
3256 * /etc/default/rcS: set variable UTC according to your needs,
3257   whether your system clock is set to UTC (UTC='yes') or
3258   not (UTC='no')
3259
3260 * /etc/localtime: adjust zoneinfo according to your needs:
3261
3262   # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime
3263
3264   The zoneinfo directory contains the time zone files that were
3265   compiled by zic. The files contain information such as rules
3266   about DST. They allow the kernel to convert UTC UNIX time into
3267   appropriate local dates and times. Use the zdump utility to
3268   print current time and date (in the specified time zone).
3269
3270 * /etc/adjtime: This file is used e.g. by the adjtimex function,
3271   which can smoothly adjust system time while the system runs
3272
3273 * If you change the time (using 'date --set ...', ntpdate,...)
3274   it is worth setting also the hardware clock to the correct time:
3275
3276   # hwclock --systohc [--utc]
3277
3278   Remember to add the --utc -option if the hardware clock is set
3279   to UTC!
3280
3281 Still problems?
3282 ---------------
3283
3284 Check your current settings via:
3285
3286   cat /etc/timezone
3287   zdump /etc/localtime
3288   echo $TZ
3289   hwclock --show
3290   grep hwclock /etc/runlevel.conf
3291   grep '^UTC' /etc/default/rc
3292
3293 Further information:
3294 --------------------
3295
3296   hwclock(8) tzselect(1) tzconfig(8)
3297   http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html
3298   http://wiki.debian.org/TimeZoneChanges
3299
3300 Tags: timezone, rtc, configuration
3301 </pre>
3302 <a name="226"></a><hr />
3303 <pre>
3304 Recorder shellscript session using script:
3305
3306 % script -t 2&gt;~/upgrade.time -a ~/upgrade.script
3307 % scriptreplay ~/upgrade.time ~/upgrade.script
3308 </pre>
3309 <a name="227"></a><hr />
3310 <pre>
3311 Test UTF-8 capabilities of terminal:
3312
3313 wget http://www.linux-cjk.net/Console/garabik/UTF-8-demo.txt.gz
3314 zcat UTF-8-demo.txt.gz
3315
3316 or:
3317
3318 wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
3319 cat UTF-8-test.txt
3320 </pre>
3321 <a name="228"></a><hr />
3322 <pre>
3323 UTF-8 at grml / some general information regarding Unicde/UTF-8:
3324
3325   http://wiki.grml.org/doku.php?id=utf8
3326 </pre>
3327 <a name="229"></a><hr />
3328 <pre>
3329
3330 This allows one ssh connection attepmt per minute per source ip, with a initial
3331 burst of 10.  The available burst is like a counter which is initialised with
3332 10. Every connection attempt decrements the counter, and every minute where the
3333 connection limit of one per minute is not overstepped the counter is
3334 incremented by one.  If the burst counter is exhausted the real rate limit
3335 comes into play. This gives you 11 connectionattepmts in the first minute
3336 before blocked for 10minutes.  After 10 minutes block the game restarts.
3337
3338 Hint: you could set the burst value to 5 and the block time to only 5 minutes
3339 to achive the same average connection rate but with halve the block time.
3340
3341 iptables -A inet_in -p tcp --syn --dport 22 -m hashlimit --hashlimit-name ssh          --hashlimit 1/minute  --hashlimit-burst 10 --hashlimit-mode srcip            --hashlimit-htable-expire 600000 -j ACCEPT
3342 iptables -A inet_in -p tcp --dport 22 -m state --state NEW -j REJECT
3343 </pre>
3344 <a name="230"></a><hr />
3345 <pre>
3346 Tunnel a specific connection via socat:
3347
3348 On the client:
3349 % socat TCP4-LISTEN:8003 TCP4:gateway:500
3350
3351 On the gateway:
3352 # socat TCP4-LISTEN:500,fork TCP4:target:$PORT
3353
3354 Using localhost:8003 on the client uses the tunnel now.
3355 </pre>
3356 <a name="231"></a><hr />
3357 <pre>
3358 Set date:
3359
3360 # date --set=060916102007
3361
3362 where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4)
3363
3364 Set date using a relative date:
3365
3366 # date -s '+3 mins'
3367
3368 or
3369
3370 # date -s '+tomorrow'
3371
3372 Display a specific relative date:
3373
3374 # date -d '+5 days -2 hours'
3375
3376 Don't forget to set hardware clock via:
3377
3378 # hwlock -w
3379 </pre>
3380 <a name="232"></a><hr />
3381 <pre>
3382 Booting grml via network / PXE:
3383
3384 Start grml-terminalserver on a system with network access
3385 and where grml is running:
3386
3387 # grml-terminalserver
3388
3389 Then booting your client(s) via PXE should work without
3390 any further work.
3391
3392 See: man grml-terminalserver + http://grml.org/terminalserver/
3393
3394 Tags: howto, pxe, network, boot
3395 </pre>
3396 <a name="233"></a><hr />
3397 <pre>
3398 Debugging SSL communications:
3399
3400 % openssl s_client -connect server.adress:993 &gt; output_file
3401 % openssl x509 -noout -text -in output_file
3402
3403 or
3404
3405 # ssldump -a -A -H -i eth0
3406
3407 See http://prefetch.net/articles/debuggingssl.html for more details.
3408
3409 Tags: debug, ssl, openssl
3410 </pre>
3411 <a name="234"></a><hr />
3412 <pre>
3413 Remove bootmanager from MBR:
3414
3415 # lilo -M /dev/hda -s /dev/null
3416
3417 Tags: mbr, lilo
3418 </pre>
3419 <a name="235"></a><hr />
3420 <pre>
3421 Rewrite grub to MBR:
3422
3423 # mount /mnt/sda1
3424 # grub-install --recheck --no-floppy --root-directory=/mnt/sda1 /dev/sda
3425
3426 Tags: mbr, grub
3427 </pre>
3428 <a name="236"></a><hr />
3429 <pre>
3430 Rewrite lilo to MBR:
3431
3432 # mount /mnt/hda1
3433 # lilo -r /mnt/hda1
3434
3435 Tags: mbr, lilo
3436 </pre>
3437 <a name="237"></a><hr />
3438 <pre>
3439 Create screenshot of plain/real console - tty1:
3440
3441 # fbgrab -c 1 screeni.png
3442 </pre>
3443 <a name="238"></a><hr />
3444 <pre>
3445 Create screenshot when running X:
3446
3447 % scrot
3448
3449 Tip: use the gkrellshoot plugin when using gkrellm
3450
3451 Tags: screenshot, xorg
3452 </pre>
3453 <a name="239"></a><hr />
3454 <pre>
3455 Redirect all connections to hostA:portA to hostB:portB, where hostA and hostB are
3456 different networks:
3457
3458 Run the following commands on hostA:
3459
3460 echo 1 &gt; /proc/sys/net/ipv4/ip_forward
3461 iptables -t nat -A PREROUTING -p tcp --dport portA -j DNAT --to hostB:portB
3462 iptables -A FORWARD -i eth0 -o eth0 -d hostB -p tcp --dport portB -j ACCEPT
3463 iptables -A FORWARD -i eth0 -o eth0 -s hostB -p tcp --sport portB -j ACCEPT
3464 iptables -t nat -A POSTROUTING -p tcp -d hostB --dport portB -j SNAT --to-source hostA
3465
3466 Tags: howto, network, redirect, port
3467 </pre>
3468 <a name="240"></a><hr />
3469 <pre>
3470 Flash BIOS without DOS/Windows:
3471
3472 Dump flash info and set the flash chip to writable:
3473 # flashrom
3474
3475 Backup the original BIOS:
3476 # flashrom -r backup.bin
3477
3478 Notice: the following step will overwrite your current BIOS!
3479 So make sure you really know what you are doing.
3480
3481 Flash the BIOS image:
3482 # flashrom -wv newbios.bin
3483
3484 Also check out LinuxBIOS: http://linuxbios.org/
3485 </pre>
3486 <a name="241"></a><hr />
3487 <pre>
3488 Enable shadow passwords:
3489
3490 # shadowconfig on
3491 </pre>
3492 <a name="242"></a><hr />
3493 <pre>
3494 Set up an IPv6 tunnel on grml:
3495
3496 # ipv6-tunnel start
3497 </pre>
3498 <a name="243"></a><hr />
3499 <pre>
3500 Set up console newsreader slrn for use with Usenet:
3501
3502 % grml-slrn
3503 </pre>
3504 <a name="244"></a><hr />
3505 <pre>
3506 Calculate with IPv6 addresses:
3507
3508 % ipv6calc
3509
3510 For usage examples refer to manpage ipv6calc(8).
3511
3512 Tags: ipv6
3513 </pre>
3514 <a name="245"></a><hr />
3515 <pre>
3516 Common network debugging tools for use with IPv6:
3517
3518 % ping6
3519 % tracepath6
3520 % traceroute6
3521 % tracert6
3522 % nc6
3523 % tcpspray6
3524
3525 Tags: ipv6
3526 </pre>
3527 <a name="246"></a><hr />
3528 <pre>
3529 Set up NFS (Network File System):
3530
3531 Server-side
3532 ~~~~~~~~~~~
3533 Make sure the relevant services are running on the server side:
3534
3535 # /etc/init.d/portmap start
3536 # /etc/init.d/nfs-common start
3537 # /etc/init.d/nfs-kernel-server start
3538
3539 Export shares via /etc/exports:
3540
3541 /backups 192.168.1.100/24(rw,wdelay,no_root_squash,async,subtree_check)
3542
3543 ... or manually export a directory running:
3544
3545 # exportfs -o rw,wdelay,no_root_squash,async,subtree_check 192.168.1.100:/backups
3546
3547 and unexport a share running:
3548
3549 # exportfs -u 192.168.1.100:/backups
3550
3551 and every time when you modify /etc/exports file run
3552
3553 # exportfs -ra
3554
3555 Display what NFS components are running:
3556
3557 # rpcinfo -p
3558
3559 Display list of exported shares:
3560
3561 # exportfs -v
3562 or
3563 # showmount -e
3564
3565 Client-side
3566 ~~~~~~~~~~~
3567 Make sure the relevant services are running on the client side:
3568
3569 # /etc/init.d/portmap start
3570 # /etc/init.d/nfs-common start
3571
3572 Verify that the server allows you to access its RPC/NFS services:
3573
3574 # rpcinfo -p server_name
3575
3576 Check what directories the server exports:
3577
3578 # showmount -e server_name
3579
3580 On the client side you can use something like the following in /etc/fstab:
3581
3582 192.168.1.101:/backups /mnt/nfs nfs defaults,users,wsize=8192,rsize=8192 0 0
3583
3584 Tags: nfs, howto, network
3585 </pre>
3586 <a name="247"></a><hr />
3587 <pre>
3588 Mount a cloop file:
3589
3590 # aptitude install cloop-src
3591 # m-a a-i cloop-src
3592
3593 # modprobe cloop file=/path/to/cloop/file
3594 # mount -r -t iso9660 /dev/cloop /mnt/test
3595 </pre>
3596 <a name="248"></a><hr />
3597 <pre>
3598 Create a PS/PDF of a plaintext file:
3599
3600 % a2ps --medium A4dj -E -o output.ps input_file
3601 % ps2pdf output.ps
3602 </pre>
3603 <a name="249"></a><hr />
3604 <pre>
3605 Print two pages on one in a PDF file:
3606
3607 % pdfnup --nup 2x1 input.pdf
3608
3609 Concatenate, extract pages/parts, encrypt/decrypt,
3610 compress PDFs using 'pdftk'.
3611 </pre>
3612 <a name="250"></a><hr />
3613 <pre>
3614 Read a PS/PDF file on console:
3615
3616 % pstotext file.pdf
3617
3618 or on plain framebuffer console in graphical mode:
3619
3620 % pdf2ps file.pdf ; ps2png file.ps file.png ; fbi file.png
3621
3622 or
3623
3624 % fbgs file.pdf
3625 </pre>
3626 <a name="251"></a><hr />
3627 <pre>
3628 Bypass the password of a PDF file:
3629
3630 % gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c quit
3631 </pre>
3632 <a name="252"></a><hr />
3633 <pre>
3634 Record sound:
3635
3636 % rec test.aiff
3637
3638 This will record a AIFF audio file.
3639 </pre>
3640 <a name="253"></a><hr />
3641 <pre>
3642 Change passphrase / password of an existing SSH key:
3643
3644 % ssh-keygen -p
3645 </pre>
3646 <a name="254"></a><hr />
3647 <pre>
3648 Enable syntax highlighting in nano:
3649
3650 Just uncomment the include directives for your respective
3651 language at the bottom of the file /etc/nanorc
3652 </pre>
3653 <a name="255"></a><hr />
3654 <pre>
3655 Create netboot package for grml-terminalserver:
3656
3657 # bash /usr/share/doc/grml-terminalserver/examples/create-netboot
3658 </pre>
3659 <a name="256"></a><hr />
3660 <pre>
3661 To boot grml via network (PXE) check out grml-terminalserver:
3662
3663 # grml-terminalserver
3664
3665 See http://grml.org/terminalserver/ for more details.
3666 </pre>
3667 <a name="257"></a><hr />
3668 <pre>
3669 Rotate pictures:
3670
3671 Using the 'Orientation' tag of the Exif header, rotate
3672 the image so that it is upright:
3673 % jhead -autorot *.jpg
3674
3675 Manually rotate a picture:
3676 % convert -rotate 270 input.jpg output.jpg
3677 </pre>
3678 <a name="258"></a><hr />
3679 <pre>
3680 Rename files based on the information inside their exif header:
3681
3682 % jhead -n%Y-%m-%d_%Hh%M_%f *.jpg
3683
3684 This will rename a file named img_2071.jpg to something like:
3685
3686 2007-08-17_10h38_img_2071.jpg
3687
3688 if it was shot at 10:38 o'clock on 2007-08-17 (according to
3689 the information inside the exif header).
3690 </pre>
3691 <a name="259"></a><hr />
3692 <pre>
3693 Calculate network / netmask:
3694
3695 Usage examples:
3696 % ipcalc 10.0.0.28 255.255.255.0
3697 % ipcalc 10.0.0.0/24
3698 </pre>
3699 <a name="260"></a><hr />
3700 <pre>
3701 Blacklist a kernel module:
3702
3703 # blacklist &lt;name_of_kernel_module&gt;
3704
3705 -&gt; running 'blacklist hostap_cs' for example will generate an
3706 entry like this in /etc/modprobe.d/grml:
3707
3708 blacklist hostap_cs
3709 alias hostap_cs off
3710
3711 To remove the module from the blacklist again just invoke:
3712
3713 # unblacklist &lt;name_of_kernel_module&gt;
3714
3715 or manually remove the entry from /etc/modprobe.d/grml.
3716 </pre>
3717 <a name="261"></a><hr />
3718 <pre>
3719 Create a Debian package of a perl module:
3720
3721 % dh-make-perl --cpan Acme::Smirch --build
3722 </pre>
3723 <a name="262"></a><hr />
3724 <pre>
3725 The Magic SysRq Keys (SysReq or Sys Req, short for System Request):
3726
3727 To reboot your system using the SysRq keys just hold down the Alt and
3728 SysRq (Print Screen) key while pressing the keys REISUB ("Raising
3729 Elephants Is So Utterly Boring").
3730
3731 R = take the keyboard out of raw mode
3732 E = terminates all processes (except init)
3733 I = kills all processes (except init)
3734 S = synchronizes the disk(s)
3735 U = remounts all filesystems read-only
3736 B = reboot the system
3737
3738 Notice: use O instead of B for poweroff.
3739
3740 Or write the sequence to /proc/sysrq-trigger instead:
3741
3742 # for i in r e i s u b ; do echo $i &gt; /proc/sysrq-trigger ; done
3743
3744 To enable or disable SysRq calls:
3745
3746 # echo 0 &gt; /proc/sys/kernel/sysrq
3747 # echo 1 &gt; /proc/sys/kernel/sysrq
3748
3749 See http://en.wikipedia.org/wiki/Magic_SysRq_key for more details.
3750
3751 Tags: reboot, documentation, sysrq, magic
3752 </pre>
3753 <a name="263"></a><hr />
3754 <pre>
3755 Memtest / memcheck:
3756
3757 Just boot your grml Live-CD with "memtest" to execute a memcheck/memtest
3758 with Memtest86+.
3759 </pre>
3760 <a name="264"></a><hr />
3761 <pre>
3762 Tunnel TCP-Traffic through DNS using dns2tcp:
3763
3764 Server-side:
3765 ~~~~~~~~~~~~
3766 1. Create necessary DNS-Records:
3767 dnstun.example.com.     3600    IN      NS      host.example.com.
3768 dnstun.example.com.     3600    IN      A       192.168.1.1
3769 host.example.com.       3600    IN      A       192.168.1.1
3770
3771 2. Configure dns2tcpd on host.example.com.:
3772 # cat /etc/dns2tcpd.conf 
3773 listen = 192.168.1.1          #the ip dns2tcpd should listen on
3774 port = 53                     #" port " " " "
3775 user = nobody
3776 chroot = /tmp
3777 domain = dnstun.example.com.  # the zone as specified inside dns
3778 ressources = ssh:127.0.0.1:22 # available resources
3779
3780 3. Start the daemon:
3781 # cat &gt; /etc/default/dns2tcp &lt;< EOF
3782 # Set ENABLED to 1 if you want the init script to start dns2tcpd.
3783 ENABLED=1
3784 USER=nobody
3785 EOF
3786 # /etc/init.d/dns2tcp start
3787
3788 Client-side:
3789 ~~~~~~~~~~~~
3790 You have two possibilities:
3791 - Use the DNS inside your network (DNS must allow resolving for external domains)
3792 # grep nameserver /etc/resolv.conf 
3793 nameserver 172.16.42.1
3794 # dns2tcpc -z dnstun.example.com 172.16.42.1
3795 Available connection(s) : 
3796         ssh
3797 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com 172.16.42.1 &
3798 Listening on port : 2222
3799 # ssh localhost -p 2222
3800 user@host.example.com:~#
3801
3802 - Directly contact the endpoint (port 53 UDP must be allowed outgoing)
3803 # dns2tcpc -z dnstun.example.com dnstun.example.com
3804 Available connection(s) : 
3805         ssh
3806 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com dnstun.example.com &
3807 Listenning on port : 2222
3808 # ssh localhost -p 2222
3809 user@host.example.com:~#
3810
3811 Notice: using 'ssh -D 8080 ..' you will get a socks5-proxy listening on
3812 localhost:8080 which you can use to tunnel everything through your "dns-uplink".
3813
3814 Tags: howto, network, tunnel
3815 </pre>
3816 <a name="265"></a><hr />
3817 <pre>
3818 Configure a MadWifi device for adhoc mode:
3819
3820 Disable the autocreation of athX devices:
3821 # echo "options ath_pci autocreate=none" &gt; /etc/modprobe.d/madwifi
3822
3823 Remove the autocreated device for now:
3824 # wlanconfig ath0 destroy
3825
3826 Configuration in /etc/network/interfaces:
3827
3828 iface ath0 inet static
3829   madwifi-base wifi0
3830   madwifi-mode adhoc
3831   ...
3832
3833 Hints:
3834   - Do not use interface names without ending 0 (otherwise startup fails).
3835   - Only chooss unique names for interfaces.
3836 </pre>
3837 <a name="266"></a><hr />
3838 <pre>
3839 Find dangling symlinks using zsh:
3840
3841 % ls **/*(-@)
3842 </pre>
3843 <a name="267"></a><hr />
3844 <pre>
3845 Use approx with runit supervision
3846 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3847
3848 Install the packages:
3849 # apt-get install approx runit
3850
3851 Add user approxlog for the logging daemon:
3852 # adduser --system --home /nonexistent --no-create-home approxlog
3853
3854 Create config directory:
3855 # mkdir /etc/sv/approx
3856
3857 Use /var/run/sv.approx as supervise directory:
3858 # ln -s /var/run/sv.approx /etc/sv/approx/supervise
3859
3860 # cat &gt; /etc/sv/approx/run &lt;< EOF
3861 #!/bin/sh
3862 echo 'approx starting'
3863 exec approx -f 2&gt;&1
3864 EOF
3865
3866 You normally do not need a logging service for approx because it logs
3867 to syslog too. So just for completion:
3868 # mkdir -p /etc/sv/approx/log
3869 # ln -s /var/run/sv.approx.log /etc/sv/approx/log/supervise
3870 # cat &gt; /etc/sv/approx/log/run &lt;< EOF
3871 #!/bin/sh
3872 set -e
3873 LOG="/var/log/approx"
3874 test -d "$LOG" || mkdir -p -m2750 "$LOG" && chown approxlog:adm "$LOG"
3875 exec chpst -uapproxlog svlogd -tt -v "$LOG"
3876 EOF
3877
3878 Now activate the new approx service (will be started within 5s):
3879 # ln -s /etc/sv/approx/ /var/service/
3880
3881 Make approx managed via runit available via init-script interface:
3882 # dpkg-divert --local --rename /etc/init.d/approx
3883 # ln -s /usr/bin/sv /etc/init.d/approx
3884 </pre>
3885 <a name="268"></a><hr />
3886 <pre>
3887 Remote-reboot a grml system using SysRQ via /proc (execute as root):
3888
3889 eject &&gt;/dev/null
3890 umount -l /cdrom
3891 eject /dev/cdrom
3892 echo b &gt; /proc/sysrq-trigger
3893
3894 Tags: reboot, howto, grml, network
3895 </pre>
3896 <a name="269"></a><hr />
3897 <pre>
3898 Show what happens on /dev/sda0:
3899
3900 # mount the debugfs to relay kernel info to userspace
3901 mount -t debugfs none /sys/kernel/debug
3902
3903 # is a convenient wrapper arround blktrace and blkparse
3904 btrace /dev/sda0
3905
3906 Tags: debug, block, partition, trace
3907 </pre>
3908 <a name="270"></a><hr />
3909 <pre>
3910 Convert Flash to Avi:
3911
3912 % ffmpeg -i input.flv output.avi
3913
3914 Extract MP3 from Flash file:
3915
3916 % for i in *.flv; do ffmpeg -i $i -acodec copy ${i%.flv}.mp3 ; done
3917 </pre>
3918 <a name="271"></a><hr />
3919 <pre>
3920 Usage example for cryptsetup / -luks encrypted partition on LVM:
3921
3922 volume group name:   x61
3923 logical volume name: home
3924
3925 echo "grml-crypt_home /dev/mapper/x61-home none luks" &gt;> /etc/crypttab
3926 Start cryptdisks
3927 mount /dev/mapper/grml-crypt_home /mnt/test
3928 </pre>
3929 <a name="272"></a><hr />
3930 <pre>
3931 fdisk/parted/... complains with something like
3932 'unable to open /dev/sda - unrecognised disk label'?!
3933
3934 See http://grml.org/faq/#fdisk =&gt;
3935
3936 * use /sbin/fdisk.distrib from util-linux
3937 * switch to sfdisk, cfdisk,...
3938 * use parted's mklabel command (but please read the
3939   parted manual before executing this command)
3940 </pre>
3941 <a name="273"></a><hr />
3942 <pre>
3943 dmraid - support for SW-RAID / FakeRAID controllers
3944 like Highpoint HPT and Promise FastTrack
3945
3946 Activate all software RAID sets discovered:
3947 # dmraid -ay
3948
3949 Deactivates all active software RAID sets:
3950 # dmraid  -an
3951
3952 Discover all software RAID devices supported on the system:
3953 # dmraid -r
3954 </pre>
3955 <a name="274"></a><hr />
3956 <pre>
3957 Extract winmail.dat:
3958
3959 List content:
3960 % ytnef winmail.dat
3961
3962 Extract files to current directory:
3963 % ytnef -f . winmail.dat
3964 </pre>
3965 <a name="275"></a><hr />
3966 <pre>
3967 Approx - Debian package proxy/cacher howto
3968
3969 % apt-get install approx
3970 % echo 'debian  http://ftp.de.debian.org/debian' &gt;>/etc/approx/approx.conf
3971 % Restart approx
3972
3973 Add your new approx to sources.list
3974
3975 eg.
3976 deb http://localhost:9999/debian  unstable  main contrib non-free
3977
3978 use approx in grml-debootstrap like:
3979 % grml-debootstrap -r lenny -t /dev/sda1 -m http://127.0.0.1:9999/debian
3980 </pre>
3981 <a name="276"></a><hr />
3982 <pre>
3983 Simple webserver with python:
3984
3985 % python -m SimpleHTTPServer
3986 </pre>
3987 <a name="277"></a><hr />
3988 <pre>
3989 Upgrade only packages from the grml-stable Debian repository:
3990
3991 echo 'deb http://deb.grml.org/ grml-stable main' &gt; /etc/apt/grml-stable.list
3992 apt-get -o Dir::Etc::sourcelist=/etc/apt/grml-stable.list -o Dir::Etc::sourceparts=/doesnotexist update
3993 apt-get upgrade
3994 </pre>
3995 <a name="278"></a><hr />
3996 <pre>
3997 Install Centos into a directory:
3998
3999 % febootstrap centos-5 directory http://mirror.centos.org/centos-5/5.3/os/i386/
4000 </pre>
4001 <a name="279"></a><hr />
4002 <pre>
4003 Install Fedora into a directory:
4004
4005 % febootstrap fedora-11 target_directory
4006 </pre>
4007 <a name="280"></a><hr />
4008 <pre>
4009 Use Nessus / OpenVAS (remote network security auditor):
4010
4011 Install software packages:
4012 # apt-get update
4013 # apt-get install openvas-client openvas-server openvas-plugins-base openvas-plugins-dfsg
4014
4015 Add a user:
4016 # openvas-adduser
4017
4018 Start openvas server (takes a while):
4019 # Start openvas-server
4020
4021 Invoke client as user:
4022 % OpenVAS-Client
4023 </pre>
4024 <a name="281"></a><hr />
4025 <pre>
4026 Find packages not available from any active apt repository:
4027
4028 % apt-show-versions | awk '/No available version in archive/{print $1}'
4029 </pre>
4030 <a name="282"></a><hr />
4031 <pre>
4032 Simple mailserver with python:
4033
4034 % python -m smtpd -n -c DebuggingServer localhost:1025
4035 </pre>
4036 <a name="283"></a><hr />
4037 <pre>
4038 finger via netcat:
4039
4040 echo $USER | nc $HOST 79
4041 </pre>
4042 <a name="284"></a><hr />
4043 <pre>
4044 Install Archlinux using Grml:
4045
4046 https://wiki.archlinux.org/index.php/Install_from_Existing_Linux
4047 or
4048 wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh
4049 </pre>
4050 <a name="285"></a><hr />
4051 <pre>
4052 Export blockdevices via AoE (ATA over Ethernet):
4053
4054 % vblade -m 11:22:33:44:55:66 160 2 eth0 /dev/sdb1
4055
4056 Allow the host with the mac address 11:22:33:44:55:66 to access /dev/sdb1
4057 via eth0, using the shelf and slot numbers 160 and 2. These numbers are
4058 arbitrary but should be unique within the network.
4059
4060 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4061 especially arp spoofing. Do not use in hostile networks.
4062
4063 Tags: aoe, blockdevice, export, server
4064 </pre>
4065 <a name="286"></a><hr />
4066 <pre>
4067 Access blockdevices via AoE (ATA over Ethernet):
4068
4069 % sudo aoe-discover
4070
4071 and the device should show up under /dev/etherd/. If your shelf and
4072 slot numbers re 160 and 2 the device will be /dev/etherd/e160.2
4073
4074 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4075 especially arp spoofing. Do not use in hostile networks.
4076
4077 Tags: aoe, blockdevice, export, client
4078 </pre>
4079 <a name="287"></a><hr />
4080 <pre>
4081
4082 </body>
4083 </html>