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