added reverse shell via ssh and kvm
[grml-tips.git] / grml_tips
1 Install grml to harddisk:
2
3 # grml2hd
4
5 Notice: You can pre-select the partition for the partition selector
6 and mbr dialogs inside grml2hd using:
7 # grml2hd /dev/hda1 -mbr /dev/hda
8
9 See: man grml2hd + http://grml.org/grml2hd/
10 -- 
11 Install grml on software RAID level 1:
12
13 Create /dev/md0 (and some more /dev/md* devices) first of all:
14 # cd /dev && MAKEDEV dev
15
16 Create RAID:
17 # mdadm --create --verbose /dev/md0 --level=raid1 \
18         --raid-devices=2   /dev/hda1  /dev/hdc1
19
20 Finally install grml on it:
21 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
22
23 See: man grml2hd + http://grml.org/grml2hd/
24 -- 
25 Install grml in non interactive mode with grml2hd:
26
27 Adjust configuration as needed:
28 # vim /etc/grml2hd/config
29
30 Then execute:
31
32 # GRML2HD_NONINTERACTIVE=yes grml2hd
33
34 or run:
35
36 # grml2hd -i
37
38 Use with care and only if you really know what you are doing!
39
40 See: man grml2hd + http://grml.org/grml2hd/
41 -- 
42 Configure network:
43
44 # grml-network
45 -- 
46 Boot grml via network:
47
48 # grml-terminalserver
49
50 See: man grml-terminalserver + http://grml.org/terminalserver/
51 -- 
52 Deactivate error correction of zsh:
53
54 % NOCOR=1 zsh
55
56 Run zsh-help for more information regarding zsh.
57 -- 
58 Disable automatic setting of title in GNU screen:
59
60 % NOPRECMD=1 zsh
61
62 Set it manually e.g. via:
63
64 % screen -X title foobar
65
66 Run zsh-help for more information regarding zsh.
67 -- 
68 Do not use menu completion in zsh:
69
70 % NOMENU=1 zsh
71
72 Run zsh-help for more information regarding zsh.
73 -- 
74 Run GNU screen with grml-configuration:
75
76 % grml-screen
77
78 or
79
80 % screen -c /etc/grml/screenrc
81 -- 
82 Print out grml-version:
83
84 % grml-version
85 -- 
86 Configure mutt:
87
88 % grml-mutt
89 -- 
90 Configure mutt-ng / muttng:
91
92 % grml-muttng
93 -- 
94 Set up Inode-PPTP connection:
95
96 # grml-pptp-inode
97 or
98 # grml-pptp-xdsl-students
99 -- 
100 Set up VPN / WLAN connection at TUG (TU Graz):
101
102 Set ESSID and request for ip-address via DHCP:
103 # iwconfig $DEVICE essid tug
104 # dhclient $DEVICE
105
106 Now run the main script:
107 # grml-vpnc-tugraz
108
109 After running the script an init script is available:
110
111 # /etc/init.d/vpnctug [start|stop]
112 -- 
113 Set up PPTP connection at VCG (Virtual Campus Graz):
114
115 # grml-pptp-vcgraz
116 -- 
117 Set up VPN:
118
119 # grml-vpn <options>
120
121 Usage example:
122
123 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
124
125 See: man grml-vpn
126 -- 
127 Use encrypted files / partitions:
128
129 # grml-crypt <options>
130
131 Usage example:
132
133 Initialize:
134
135 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
136 # cp big_file /mnt/test
137 # grml-crypt stop /mnt/test
138
139 Use:
140
141 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
142 # grml-crypt stop /mnt/test
143
144 See: man grml-crypt
145 -- 
146 Change resolution of X:
147
148 % xrandr -s '1024x768'
149 -- 
150 Change resolution of framebuffer:
151
152 # fbset 800x600-60
153 -- 
154 Configure newsreader slrn:
155
156 % grml-slrn
157 -- 
158 Configure grml system:
159
160 # grml-config
161
162 Or directly run scripts:
163
164 # grml-config-root
165 % grml-config-user
166 -- 
167 Lock screen (X / console):
168
169 % grml-lock
170
171 Press ctrl-alt-x to lock a GNU screen session.
172 -- 
173 Change wallpaper in X:
174
175 % grml-wallpaper <press-tab>
176 -- 
177 Start X window system (XFree86 / Xorg / X.org):
178
179 % grml-x $WINDOWMANAGER
180
181 Usage examples:
182
183 % grml-x fluxbox
184 % grml-x -mode '1024x768' wmii
185 % grml-x -nosync wm-ng
186 -- 
187 Collect hardware information:
188
189 % grml-hwinfo
190
191 or run as root to collect some more information:
192
193 # grml-hwinfo
194
195 will generate a file named info.tar.bz2.
196 -- 
197 Configure hardware detection features of harddisk installation:
198
199 # grml-autoconfig
200
201 or manually edit /etc/grml/autoconfig[.small]
202
203 See: man grml-autoconfig
204 -- 
205 Bootoptions / cheatcodes / bootparams for booting grml:
206
207 On the grml-ISO if not running grml:
208 % less /cdrom/GRML/grml-cheatcodes.txt
209
210 When running grml:
211 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
212 -- 
213 Report bugs to Debian's Bug Tracking System (BTS):
214
215 % reportbug --bts debian
216
217 or adjust /etc/reportbug.conf to your needs.
218
219 See:
220
221   http://grml.org/bugs/
222   http://www.debian.org/Bugs/
223 -- 
224 Offline documentation:
225
226 % grml-info
227
228 Online documentation:
229
230   http://grml.org/faq/
231   http://grml.org/docs/
232   http://wiki.grml.org/doku.php
233 -- 
234 Mount ntfs partition (read-write):
235
236 # modprobe fuse
237 # ntfsmount /dev/hda1 /mnt/hda1
238 -- 
239 Overwrite specific file on an NTFS partition:
240
241 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
242 -- 
243 Resize an NTFS partition:
244
245 # ntfsresize ..
246
247 Usage example:
248
249 ntfsresize -n -s 10G /dev/hda1 # testcase
250 ntfsresize -s 10G /dev/hda1    # testing was successfull, now really resize partition
251 cfdisk /dev/hda   # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
252 -- 
253 Modify resolution for intel graphic chipsets:
254
255 # 915resolution ..
256
257 Usage example:
258
259 # 915resolution 4d 1400 1050
260 -- 
261 Connect bluetooth mouse:
262
263 # bt-hid start
264
265 ... and press 'connect' button on your bluetooth device.
266 -- 
267 Connect bluetooth headset:
268
269 # bt-audio start
270
271 ... and press 'connect' button on your bluetooth device.
272 -- 
273 Secure delete file / directory / partition:
274
275 # wipe -kq /dev/hda1
276
277 See: man wipe
278
279 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
280 -- 
281 Use grml on Samsung X20 laptop:
282
283 # apt-get install grml-samsung-x20
284
285 See: http://www.michael-prokop.at/computer/samsung_x20.html
286 -- 
287 Development information regarding grml:
288
289   http://grml.supersized.org/
290 -- 
291 Contact grml team:
292
293 #grml on irc.freenode.org - http://grml.org/irc/
294 http://grml.org/contact/
295 -- 
296 Join the grml mailinglist:
297
298 http://grml.org/mailinglist/
299 -- 
300 Help us - donate!
301
302 http://grml.org/donations/
303 -- 
304 Commercial support / system administration / adjusted live-cds:
305
306 grml-solutions: http://grml.org/solutions/
307 -- 
308 Information regarding the kernel provided by grml:
309
310   http://grml.org/kernel/
311 -- 
312 SMTP command-line test tool:
313
314 % swaks <options>
315
316 Usage example:
317
318 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
319
320 See: man swaks
321 -- 
322 NTFS related packages:
323
324 scrounge-ntfs
325 salvage-ntfs
326 ntfsprogs
327 -- 
328 Modify service through init script:
329
330 # Start ssh
331 # Stop samba
332 # Restart apache
333 # Reload postfix
334 # service gpm start
335 # /etc/init.d/lvm start
336 -- 
337 Test joystick:
338
339 # jstest /dev/input/js0
340 -- 
341 Play movie:
342
343 % mplayer /path/to/movie
344 -- 
345 Use webcam with mplayer:
346
347 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
348 -- 
349 Powerful network discovery tool:
350
351 # scapy
352 -- 
353 Grab an entire CD and compress it to Ogg/Vorbis,
354 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
355
356 % abcde
357 -- 
358 Show a console session in several terminals:
359
360 % gems
361 -- 
362 Switch behaviour of caps lock key:
363
364 % caps-ctrl
365 -- 
366 grep with Perl-compatible regular expressions:
367
368 % pcregrep
369 -- 
370 ncp: a fast file copy tool for LANs
371
372 Local (send file):
373 % npush file_to_copy
374
375 Remote (receive file):
376 % npoll
377 -- 
378 utility for sorting records in complex ways:
379
380 % msort
381 -- 
382 a smaller, cheaper, faster SED implementation:
383
384 % minised
385 -- 
386 zsh tips:
387
388 % man zsh-lovers
389
390 See: http://grml.org/zsh/
391 -- 
392 zsh reference card for grml system:
393
394 http://grml.org/zsh/
395 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
396 -- 
397 Multiple rename:
398
399 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
400 % qmv foo*
401 % prename 's/foo/bar/' foo*
402 % mmv "foo*"   "bar#1"
403 % zmv 'foo(*)' 'bar$1'
404 -- 
405 Test TFT / LCD display:
406
407 % lcdtest
408 -- 
409 Test sound:
410
411 % soundtest
412 -- 
413 Improved grep version:
414
415 % glark
416
417 glark grep extract-matches
418 -- 
419 Highlith
420
421 grepc
422 hgrep
423 -- 
424 Output text as sound:
425
426 % say 'ghroummel'
427 % xsay            # when running X and text selected via mouse
428 -- 
429 Adjust a grml harddisk (grml2hd) installation:
430
431 # grml2hd-utils
432 -- 
433 Get information on movie files:
434
435 % tcprobe -i file.avi
436 -- 
437 Get an overview of your image files:
438
439 % convert 'vid:*.jpg' thumbnails.jpg
440 -- 
441 List all standard defines:
442
443 % gcc -dM -E - < /dev/null
444 -- 
445 Send a mail as reminder:
446
447 echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
448 -- 
449 ncurses-based presentation tool:
450
451 % tpp
452
453 See: man tpp and /usr/share/doc/tpp/examples/
454 -- 
455 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
456
457 % centericq
458 -- 
459 Use IRC on command line:
460
461 % irssi
462 -- 
463 Diff / merge files:
464
465 % vimdiff file1 file2
466
467 Re-diffing:
468
469 :diffupdate
470
471 Moving between diffs:
472
473 [c
474 ]c
475
476 Synchronizing:
477
478 :diffget
479 :diffput
480 -- 
481 Hardware monitoring without kernel dependencies:
482
483 % mbmon
484 -- 
485 Install grml-iso to usb-stick:
486
487 % grml2usb grml.iso /mount/point
488 -- 
489 Use mplayer on framebuffer console:
490
491 % mplayer -vo fbdev ...
492 -- 
493 Use links2 on framebuffer console:
494
495 % links2 -driver fb ...
496 -- 
497 Switch language / keyboard:
498
499 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
500 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
501   Usage example: 'grml lang=us keyboard=de xkeyboard=de'
502
503 Or run one of the following commands:
504
505 % grml-lang de
506 or
507 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
508 % setxkbmap de                                      # X11
509 -- 
510 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
511
512 # caps-ctrl
513 -- 
514 Mount usb device / usb stick:
515
516 % mount /mnt/external1   # corresponds to /dev/sda1
517 or
518 % mount /mnt/external    # corresponds to /dev/sda
519 -- 
520 Install Sun Java packages:
521
522 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
523
524 # apt-get install java-package
525 # fakeroot make-jpkg j2re-*.bin
526 # dpkg -i sun-j2re*.deb
527 # update-alternatives --config java
528 -- 
529 Improved dd version:
530
531 ddrescue is an improved version of dd which tries to read and
532 if it fails it will go on with the next sectors, where tools
533 like dd will fail.
534
535 % ddrescue ...
536
537 See: man ddrescue
538 -- 
539 How to make an audio file (e.g. Musepack format) out of a DVD track:
540
541 % mkfifo /tmp/fifo.wav
542 % mppenc /tmp/fifo.wav track06.mpc &
543 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
544
545 Adjust the mppenc line with the encoder you would like to use,
546 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
547
548 Alternative:
549
550 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
551 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
552
553 Usage example for getting a PCM/wave file from audio channel 128:
554 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
555 -- 
556 Create simple chroot:
557
558 # make_chroot_jail $USERNAME
559 -- 
560 Convert DOS formated file to unix format:
561
562 sed 's/.$//'    dosfile > unixfile       # assumes that all lines end with CR/LF
563 sed 's/^M$//'   dosfile > unixfile       # in bash/tcsh, press Ctrl-V then Ctrl-M
564 sed 's/\x0D$//' dosfile > unixfile       # gsed 3.02.80, but top script is easier
565 awk '{sub(/\r$/,"");print}'              # assumes EACH line ends with Ctrl-M
566 gawk -v BINMODE="w" '1' infile >outfile  # in DOS environment; cannot be done with
567                                          # DOS versions of awk, other than gawk
568 tr -d \r < dosfile > unixfile            # GNU tr version 1.22 or higher
569 tr -d '\015' < dosfile > unixfile        # use octal value for "\r" (see man ascii)
570 tr -d '[\015\032]' < dosfile > unixfile  # sometimes ^Z is appended to DOS-files
571 vim -c ":set ff=unix" -c ":wq" file      # convert using vim
572 vim -c "se ff=dos|x" file                # ... and even shorter ;)
573 recode ibmpc..lat1 file                  # convert using recode
574 echo -e "s/\r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
575 -- 
576 Save live audio stream to file:
577
578 % mplayer -ao pcm:file=$FILE
579
580 or
581
582 % mencoder mms://file.wmv -o $FILE -ovc copy -oac copy
583 -- 
584 Merge video files:
585
586 AVI:
587
588 % avimerge -i *.avi -o blub.avi
589
590 MPEG:
591
592 % cat *.mpg > blub.mpg
593
594 WMV:
595
596 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
597 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
598 % avimerge -i file1.avi file2.avi -o blub.avi
599 -- 
600 Display MS-Word file:
601
602 % strings file.doc | fmt | less
603
604 or
605
606 % antiword file.doc
607 -- 
608 Convert MS-Word file to postscript:
609
610 % antiword -p a4 file.doc > file.ps
611 -- 
612 Convert manual to postscript:
613
614 % zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
615 or
616 % man -t zsh > zsh.ps
617 -- 
618 Read BIOS:
619
620 % dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
621 -- 
622 Read HTTP via netcat:
623
624 echo "GET / HTTP/1.0\r\n\r\n" | netcat $DOMAIN 80
625 -- 
626 Get X ressources for specific program:
627
628 % xrdb -q |grep -i xterm
629 -- 
630 Get windowid of specific X-window:
631
632 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
633 -- 
634 Get titel of specific X-window:
635
636 % xprop WM_CLASS
637 -- 
638 check locale - LC_MESSAGES:
639
640 % locale -ck LC_MESSAGES
641 -- 
642 Create random password:
643
644 % pwgen
645 or
646 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
647 -- 
648 Get tarballs of various Linux Kernel trees:
649
650 % ketchup 2.6
651 to get the current stable 2.6 release
652
653 % ketchup -l
654 to get a list of all supported trees
655 -- 
656 Transfer your SSH public key to another host:
657
658 % ssh-copy-id -i ~/.ssh/id_dsa.pub user@remote-system
659 or
660 % cat $HOME/.ssh/id_rsa.pub  | ssh user@remote-system 'cat >> .ssh/authorized_keys'
661 -- 
662 Update /etc/fstab entries:
663
664 # grml-rebuildfstab
665
666 See "man grml-rebuildfstab" for more details about
667 generation of /etc/fstab (including stuff like
668 fs LABELs / UUIDs,...).
669 -- 
670 Fetch and potentially change SCSI device parameters:
671
672 # sdparm /dev/sda
673
674 See: man sdparm
675 -- 
676 reclaim disk space by linking identical files together:
677
678 % dupmerge...
679 -- 
680 Find and remove duplicate files:
681
682 % dupseek ...
683 -- 
684 Perform layer 2 attacks:
685
686 # yersinia ...
687 -- 
688 rootsh
689 -- 
690 Guess PC-type hard disk partitions / partition table:
691
692 # gpart <options>
693
694 Perform a standard scan:
695 # gpart /dev/ice
696
697 Write back the guessed table:
698 # gpart -W /dev/ice /dev/ice
699 -- 
700 Develop, test and use exploit code with the Metasploit Framework:
701
702 cd /tmp
703 wget http://www.metasploit.com/tools/framework-2.7-snapshot.tar.gz
704 unp framework-2.7-snapshot.tar.gz
705 cd framework*
706 ./msfcli
707 -- 
708 Useful documentation:
709
710 % w3m   /usr/share/doc/Debian/reference/reference.en.html
711 or
712 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
713
714 http://grml.org/docs/           grml Documentation
715 http://wiki.grml.org/           grml Wiki
716 http://www.debian.org/doc/      Debian Documentation
717 http://wiki.debian.org/         Debian Wiki
718 http://www.gentoo.org/doc/en/   Gentoo Documentation
719 http://gentoo-wiki.com/         Gentoo Wiki
720 http://www.tldp.org/            The Linux Documentation Project
721
722 Tips and tricks:
723
724 % fortune debian-hints
725 -- 
726 Fun stuff:
727
728 % fortune debian-hints
729 % dpkg -L funny-manpages
730 -- 
731 Backup master boot record (MBR):
732
733 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
734 -- 
735 Backup partition table:
736
737 # sfdisk -d /dev/hda > hda.out
738
739 Restore partition table:
740
741 # sfdisk /dev/hda < hda.out
742 -- 
743 Clone disk via network using netcat:
744
745 Listener:
746 # nc -vlp 30000 > hda1.img
747 Source:
748 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
749
750 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
751 to tune speed:
752
753 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
754 -- 
755 Backup specific directories via cpio and ssh:
756
757 # for f in directory_list; do find $f >> backup.list done
758 # cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
759 -- 
760 Clone disk via ssh:
761
762 This one uses CPU cycles on the remote server to compare the files:
763 # ssh target_address cat remotefile | diff - localfile
764 # cat localfile | ssh target_address diff - remotefile
765
766 This one uses CPU cycles on the local server to compare the files:
767 # ssh target_address cat <localfile "|" diff - remotefile
768 -- 
769 Useful tools for cloning / backups:
770
771 * dd: convert and copy a file
772 * dd_rescue: copies data from one file (or block device) to another
773 * pcopy: a replacement for dd
774 * partimage: back up and restore disk partitions
775 * dirvish: Disk based virtual image network backup system
776 * devclone: in-place filesystem conversion -- device cloning
777 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
778 * dump: ext2/3 filesystem backup
779 * udpcast: multicast file transfer tool
780 * cpio: copy files to and from archives
781 * pax: read and write file archives and copy directory hierarchies
782 * netcat / ssh / tar / gzip / bzip2: additional helper tools
783 -- 
784 Use grml as a rescue system:
785
786 Different tools:
787
788   * dd: convert and copy a file
789   * ddrescue: copies data from one file or block device to another
790   * partimage: Linux/UNIX utility to save partitions in a compressed image file
791   * cfdisk: Partition a hard drive
792   * nparted: Newt and GNU Parted based disk partition table manipulator
793   * parted-bf: The GNU Parted disk partition resizing program, small version
794   * testdisk: Partition scanner and disk recovery tool
795   * gpart: Guess PC disk partition table, find lost partitions
796
797 ext2/ext3:
798
799   * e2fsprogs: ext2 file system utilities and libraries
800   * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
801   * e2undel: Undelete utility for the ext2 file system
802   * ext2resize: an ext2 filesystem resizer
803   * recover: Undelete files on ext2 partitions
804
805 ReiserFS/Reiser4:
806
807   * reiser4progs: administration utilities for the Reiser4 filesystem
808   * reiserfsprogs: User-level tools for ReiserFS filesystems
809
810 XFS:
811
812   * xfsdump: Administrative utilities for the XFS filesystem
813   * xfsprogs: Utilities for managing the XFS filesystem
814
815 JFS:
816
817   * jfsutils: utilities for managing the JFS filesystem
818
819 NTFS:
820
821   * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
822   * salvage-ntfs: free NTFS data recovery tools
823   * scrounge-ntfs: data recovery program for NTFS file systems
824   * ntfsresize: resize ntfs partitions
825 -- 
826 Get ASCII value of a character with zsh:
827
828 % char=N ; print $((#char))
829 -- 
830 Convert a collection of mp3 files to wave or cdr using zsh:
831
832 % for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
833 -- 
834 Convert images (foo.gif to foo.png) using zsh:
835
836 % for i in **/*.gif; convert $i $i:r.png
837 -- 
838 Remove all "non txt" files using zsh:
839
840 % rm ./^*.txt
841 -- 
842 Remote Shell Using SSH:
843
844 remote host:
845 % ssh -NR 3333:localhost:22 user@yourhost
846
847 local host:
848 % ssh user@localhost -p 3333
849 -- 
850 Reverse Shell with Netcat:
851
852 local host:
853 % netcat -v -l -p 3333 -e /bin/sh
854
855 remote host:
856 % netcat 192.168.0.1 3333
857 -- 
858 Reverse Shell via SSH:
859
860 local host (inside the network):
861 % ssh -NR 1234:localhost:22 remote_host
862
863 remote host (outside the network):
864 % ssh localhost -p 1234
865 -- 
866 Remove empty directories with zsh:
867
868 % rmdir ./**/*(/od) 2> /dev/null
869 -- 
870 Find all the empty directories in a tree with zsh:
871
872 % ls -ld *(/^F)
873 -- 
874 Find all files without a valid owner and change ownership with zsh:
875
876 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
877 -- 
878 Display the 5-10 last modified files with zsh:
879
880 % print -rl -- /path/to/dir/**/*(D.om[5,10])
881 -- 
882 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
883
884 % print -rl -- **/*(Dom[1,10])
885 -- 
886 Find most recent file in a directory with zsh:
887
888 % setopt dotglob ; print directory/**/*(om[1])
889 -- 
890 Tunnel all traffic through an external server:
891
892 % ssh -ND 3333 username@external.machine
893
894 Then set the SOCKS4/5 proxy to localhost:3333.
895 Check whether it's working by surfing e.g. to checkip.dyndns.org
896 -- 
897 Tunnel everything through SSH via tsocks:
898
899 set up the SSH proxy on the client side:
900
901 % ssh -ND 3333 user@remote.host.example.com
902
903 Adjust /etc/tsocks.conf afterwards (delete all other lines):
904
905 server = 127.0.0.1
906 server_port = 3333
907
908 For programs who natively support proxying connections (e.g. Mozilla
909 Firefox) you can now set the proxy address to localhost port 3333.
910
911 All other programs which's connections you want to tunnel through your
912 external host are prefixed with tsocks, e.g.:
913
914 % tsocks netcat example.com 80
915 % tsocks irssi -c irc.quakenet.eu.org -p 6667
916
917 If you call tsocks without parameters it executes a shell witht the
918 LD_PRELOAD environment variable already set and exported.
919 -- 
920 smartctl - control and monitor utility for harddisks using Self-Monitoring,
921 Analysis and Reporting Technology (SMART):
922
923 # smartctl --all /dev/ice
924
925 If you want to use smartctl on S-ATA (sata) disks use:
926
927 # smartctl -d ata --all /dev/sda
928
929 Start offline test:
930 # smartctl -t offline /dev/ice
931
932 Start short test:
933 # smartctl -t short /dev/ice
934
935 Display results of test:
936 # smartctl -l selftest /dev/ice
937
938 Query device information:
939 # smartctl -i /dev/ice
940 -- 
941 Mount a BSD / Solaris partition:
942
943 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
944
945 Use ufstype 44bsd  for FreeBSD, NetBSD, OpenBSD (read-write).
946 Use ufstype ufs2   for >= FreeBSD 5.x (read-only).
947 Use ufstype sun    for SunOS (Solaris) (read-write).
948 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
949
950 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
951 for more details.
952 -- 
953 Read BIOS (and or BIOS) password:
954
955 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
956 -- 
957 Clone one of the kernel trees via git:
958
959  git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
960                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
961 This path defines the tree. See http://kernel.org/git/ for an overview.
962 -- 
963 Mount filesystems over ssh protocol:
964
965 % sshfs user@host:/remote_dir /mnt/test
966
967 Unmount via:
968
969 % fusermount -u /mnt/test
970
971 (Notice: requires fuse kernel module)
972 -- 
973 Install Gentoo using grml:
974
975 See http://www.gentoo.org/doc/en/altinstall.xml
976 -- 
977 Install (plain) Debian (sarge release) via grml:
978
979 Assuming you want to install Debian to sda1:
980
981 mkfs.ext3 /dev/sda1           # make an ext3 filesystem on /dev/sda1
982 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
983 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
984 chroot /mnt/test /bin/bash    # let's chroot into the new system
985 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
986 mount -t proc   none /proc    # make sure we also have a mounted /proc
987 base-config                   # now configure some main settings
988 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
989 cd /dev ; ./MAKEDEV generic                                # make sure we have all necessary devices for lilo
990 apt-get install lilo linux-image-2.6.12-1-386              # install lilo and a kernel which fits your needs
991 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
992 vi /etc/lilo.conf && lilo                                  # adjust the file for your needs and run lilo afterwards
993 umount /proc ; umount /dev/pts                             # we do not need them any more
994 exit                                                       # now leave chroot
995 cp /etc/hosts /etc/fstab /mnt/test/etc/           # you might want to take the existing files...
996 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
997 umount /mnt/test && reboot    # unmount partition and reboot...
998
999 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1000 Avoid all of the above steps - use grml-debootstrap(8) instead!
1001 -- 
1002 Install (plain) Debian (etch release) via grml
1003
1004 Assuming you want to install Debian to sda1:
1005
1006 mkfs.ext3 /dev/sda1           # make an ext3 filesystem on /dev/sda1
1007 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1008 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1009 chroot /mnt/test /bin/bash    # let's chroot into the new system
1010 mount -t proc   none /proc    # make sure we have a mounted /proc
1011 apt-get install locales console-data  # install locales
1012 dpkg-reconfigure locales console-data # adjust locales to your needs
1013 apt-get install vim most zsh screen less initrd-tools file grub     \
1014         usbutils pciutils bzip2 sysfsutils dhcp3-client resolvconf  \
1015         strace lsof w3m # install useful software
1016 apt-get install linux-headers-2.6-686 linux-image-686  # install current kernel
1017
1018 echo "127.0.0.1       localhost" > /etc/hosts   # adjust /etc/hosts and network:
1019 cat >> /etc/network/interfaces << EOF
1020 iface lo inet loopback
1021 iface eth0 inet dhcp
1022 auto lo
1023 auto eth0
1024 EOF
1025
1026 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1027 cat >> /etc/fstab << EOF
1028 sysfs          /sys         sysfs   auto                       0   0
1029 proc           /proc        proc    defaults                   0   0
1030 /dev/sda1      /            ext3    defaults,errors=remount-ro 0   1
1031 /dev/sda2      none         swap    sw                         0   0
1032 /dev/cdrom     /mnt/cdrom0  iso9660 ro,user,noauto             0   0
1033 EOF
1034 passwd             # set password of user root
1035
1036 mkdir /boot/grub   # setup grub
1037 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1038 cat >> /boot/grub/menu.lst << EOF
1039 title           Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1040 root            (hd0,0)
1041 kernel          /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1042 initrd          /boot/initrd.img-2.6.18-3-686
1043 EOF
1044 vim /boot/grub/menu.lst               # adjust grub configuration to your needs
1045 cd /dev && MAKEDEV generic            # create default devices
1046 cp -i /usr/lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1047 grub install  # now install grub, run in grub-cmdline following commands:
1048 > root (hd0,0)
1049 > setup (hd0)
1050 > quit
1051 umount -a # unmount all filesystems in chroot and finally:
1052 exit      # exit the chroot and:
1053 reboot
1054
1055 If you want to use lilo instead of grub take a look at
1056 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1057
1058 cat > /etc/lilo.conf << EOF
1059 # This allows booting from any partition on disks with more than 1024 cylinders.
1060 lba32
1061
1062 # Specifies the boot device
1063 boot=/dev/sda1
1064
1065 # Specifies the device that should be mounted as root.
1066 root=/dev/sda1
1067
1068 # use Debian on software raid:
1069 # raid-extra-boot=mbr-only
1070
1071 install=text
1072 # prompt
1073 timeout=1
1074 map=/boot/map
1075 vga=normal
1076
1077 image=/boot/vmlinuz-2.6.18-grml
1078         label="2.6.18-grml"
1079         #append="...."
1080         read-only
1081         initrd=/boot/initrd.img-2.6.18-grml
1082 EOF
1083
1084 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1085 Avoid all of the above steps - use grml-debootstrap(8) instead!
1086 -- 
1087 Convert files from Unicode / UTF to ISO:
1088
1089 % iconv -f utf8 -t iso-8859-15 < utffile > isofile
1090
1091 and vice versa:
1092
1093 % iconv -f iso-8859-15 -t utf8 < isofile > utffile
1094 -- 
1095 Assign static setup for network cards (eth0 and eth1) via udev:
1096
1097 First method - manual:
1098 ~~~~~~~~~~~~~~~~~~~~~~
1099 Get information for SYSFS address:
1100 # udevinfo -a -p /sys/class/net/eth0/ | grep address
1101
1102 Then create udev rules:
1103 # cat /etc/udev/network.rules
1104 # match eth* stuff:
1105 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:01", NAME="wlan0"
1106 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:02", NAME="lan0"
1107 # do not match eth* drivers but also e.g. firewire stuff:
1108 ACTION=="add", SUBSYSTEM=="net", SYSFS{address}=="00:00:00:00:00:03", NAME="1394"
1109
1110 Now activate the rules:
1111 # cd /etc/udev/rules.d/ && ln -s ../network.rules z35_network.rules
1112
1113 Unload the drivers, restart udev and load the drivers again to activate
1114 the settings.
1115
1116 Second method - automatic:
1117 ~~~~~~~~~~~~~~~~~~~~~~~~~~
1118 Run /lib/udev/write_net_rules shipped with recent udev versions:
1119
1120 # INTERFACE=wlan1 /lib/udev/write_net_rules 00:00:00:00:00:04
1121
1122 This command will create /etc/udev/rules.d/z25_persistent-net.rules containing:
1123
1124 SUBSYSTEM=="net", DRIVER=="?*", SYSFS{address}=="00:00:00:00:00:04", NAME=wlan1
1125
1126 See /usr/share/doc/udev/writing_udev_rules/index.html for more information.
1127 -- 
1128 Change the suffix from *.sh to *.pl using zsh:
1129
1130 % autoload zmv
1131 % zmv -W '*.sh' '*.pl'
1132 -- 
1133 Generate SSL certificate:
1134
1135 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1136 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1137
1138 Check certfile:
1139 # openssl x509 -in certfile -text
1140
1141 Verify against CA certificate:
1142 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1143
1144 Generate 2048bit RSA-key:
1145 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1146
1147 As before but add request to existing key pub-sec-key.pem:
1148 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1149
1150 Show request request.pem:
1151 # openssl req -text -noout -in request.pem
1152
1153 Verify signature of request request.pem:
1154 # openssl req -verify -noout -in request.pem
1155
1156 Generate SHA1 fingerprint (modulo key) of request.pem:
1157 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1158
1159 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1160 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1161
1162 As before but create self signed certificate based on existing key pub-sec-key.pem:
1163 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1164
1165 Generate new request out of existing self signed certificate:
1166 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1167
1168 Display certificate self-signed-certificate.pem in plaintext:
1169 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1170
1171 Check self signed certificate:
1172 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1173
1174 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1175 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1176
1177 Generate ssl-certificate for use with apache2:
1178
1179 export RANDFILE=/dev/random
1180 mkdir /etc/apache2/ssl/
1181 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
1182 chmod 600 /etc/apache2/ssl/apache.pem
1183
1184 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1185
1186 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1187
1188 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1189 -- 
1190 Change Windows NT password(s):
1191
1192 # mount -o rw /mnt/hda1
1193 # cd /mnt/hda1/WINDOWS/system32/config/
1194 # chntpw SAM SECURITY system
1195
1196 Notice: if mounting the partition read-write did not work (check syslog!)
1197 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1198
1199 (Be careful with deactivating syskey!)
1200 -- 
1201 glark - replacement for grep written in Ruby:
1202
1203 A replacement for (or supplement to) the grep family, glark offers:
1204 Perl compatible regular expressions, highlighting of matches,
1205 context around matches, complex expressions and automatic exclusion
1206 of non-text files.
1207
1208 Usage examples:
1209
1210 % glark -y keyword file      # display only the region that matched, not the entire line
1211 % glark -o format print *.h  # search for either "printf" or "format"
1212
1213 More information: man glark
1214 -- 
1215 Find CD burning device(s):
1216
1217 General information on CD-ROM:
1218 % cat /proc/sys/dev/cdrom/info
1219
1220 Scan using ATA Packet specific SCSI transport:
1221 # cdrecord -dev=ATA -scanbus
1222 # cdrecord-prodvd -s -scanbus dev=ATA
1223
1224 Get specific information for /dev/ice:
1225 # cdrecord dev=/dev/ice -scanbus
1226 -- 
1227 Create devices in /dev on udev:
1228
1229 For example create md devices (/dev/md0, /dev/md1,...):
1230 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1231 -- 
1232 Identify network device (NIC):
1233
1234 # ethtool -i $DEVICE
1235
1236 Show NIC statistics:
1237
1238 # ethtool -S $DEVICE
1239
1240 If your NIC shows some aging signs, you may want to be sure:
1241
1242 # ethtool -t $DEVICE
1243
1244 Disable TCP/UDP checksums:
1245
1246 # ethtool -K $DEVICE tx off
1247 -- 
1248 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1249
1250 Switch to tty12 and take a look at the syslog. If you see something like:
1251
1252   SQUASHFS error: zlib_fs returned unexpected result 0x........
1253   SQUASHFS error: Unable to read cache block [.....]
1254   SQUASHFS error: Unable to read inode [.....]
1255
1256 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1257 Check your CD low-level via running:
1258
1259 # readcd -c2scan dev=/dev/cdrom
1260
1261 If the medium really is ok and it still fails try to boot with deactivated DMA
1262 via using grml nodma at the bootprompt.
1263 -- 
1264 Write a Microsoft compatible boot record (MBR) using ms-sys
1265
1266 Write a Windows 2000/XP/2003 MBR to device:
1267
1268 # ms-sys -m /dev/ice
1269 -- 
1270 Use a Vodafone 3G Datacard (UMTS) with Linux:
1271
1272 Plug in your vodafone card and check in syslog whether the appropriate
1273 (probably /dev/ttyUSB0 or /dev/noz0 when using newer vodafone cards) has
1274 been created. If so run:
1275
1276 # gcom -d $DEVICE
1277 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1278
1279 Usage examples:
1280 # gcom -d /dev/ttyUSB0
1281 # wvdial --config /etc/wvdial.conf.umts a1usb
1282
1283 # gcom -d /dev/noz0
1284 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1285
1286 # gcom -d /dev/noz0
1287 # wvdial --config /etc/wvdial.conf.umts dreiusb
1288
1289 Notice: newer vodafone cards require the nozomi driver. Run 'modprobe nozomi' on
1290 your grml system.
1291 -- 
1292 hdparm - get/set hard disk parameters
1293
1294 Display the identification info that was obtained from the drive at boot time,
1295 if available:
1296 # hpdarm -i /dev/ice
1297
1298 Request identification info directly from the drive:
1299 # hpdarm -I /dev/ice
1300
1301 Perform timings of device + cache reads for benchmark and comparison purposes:
1302 # hdparm -tT /dev/ice
1303 -- 
1304 bonnie++ - program to test hard drive performance.
1305
1306 # mkdir /mnt/benchmark
1307 # mount /dev/ice /mnt/benchmark
1308 # chmod go+w /mnt/benchmark
1309 # bonnie -u grml -d /mnt/benchmark -s 2000M
1310 -- 
1311 Use gizmo with a bluetooth headset:
1312
1313 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1314 % gizmo --mic $DEVICE --speaker $DEVICE
1315 -- 
1316 Scan a v4l device for TV stations:
1317
1318 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1319
1320 Then running xawtv should work:
1321
1322 % xawtv
1323 -- 
1324 Run apt-get with timeout of 3 seconds:
1325
1326 # apt-get -o acquire::http::timeout=3  update
1327 -- 
1328 Debian GNU/Linux device driver check page
1329
1330 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1331 -- 
1332 Use dd with status line:
1333
1334 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1335 -- 
1336 Generate a 512k file of random data with status bar:
1337
1338 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1339 -- 
1340 Install Grub instead of lilo on grml installation (grml2hd):
1341
1342 install grml:
1343 # grml2hd ....
1344
1345 adjust grub's configuration file menu.lst:
1346 # $EDITOR /boot/grub/menu.lst
1347
1348 now install grub (usage example for /dev/sda1):
1349 # grub install
1350 root (hd0,0)
1351 setup (hd0)
1352 -- 
1353 Install Ubuntu using grml:
1354
1355 See https://wiki.ubuntu.com/Installation/FromKnoppix
1356 -- 
1357 Resize ext2 / ext3 partition:
1358
1359 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1360 # fsck.ext2 -v -y -f /dev/iceX        # check the filesystem
1361 # resize2fs -p /dev/iceX  $SIZE       # resize it (adjust $SIZE)
1362 # fdisk /dev/ice                      # adjust partition in partition table
1363 # fsck.ext2 -v -y -f /dev/iceX        # check filesystem again
1364 # resize2fs -p /dev/iceX              # resize it to maximum
1365 # tune2fs -j /dev/iceX                # re-enable journal
1366 -- 
1367 Tune ext2 / ext3 filesystem:
1368
1369 Check partition first:
1370
1371 # tune2fs -l /dev/iceX
1372
1373 If you don't see dir_index in the list, then enable it:
1374
1375 # tune2fs -O dir_index /dev/iceX
1376
1377 Now run e2fsck with the -D option to have the directories optimized:
1378
1379 # e2fsck -D /dev/iceX
1380
1381 Notice: since e2fsprogs (1.39-1) filesystems are created with
1382 directory indexing and on-line resizing enabled by default.
1383 -- 
1384 Search for printers via network:
1385
1386 # pconf_detect -m NETWORK -i 192.168.0.1/24
1387 -- 
1388 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1389
1390 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1391 -- 
1392 System-Profiling using oprofile:
1393
1394 Prepare setup:
1395
1396 # opcontrol --reset
1397 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1398
1399 Start logging:
1400 # opcontrol --start
1401
1402 Now $DO_SOME_TASKS...
1403
1404 Stop logging:
1405 # opcontrol --shutdown
1406
1407 Then take a look at the reports using something like e.g.:
1408 # opreport -t 0.5 --exclude-dependent
1409 # opreport -t 0.5 /path/to/executable_to_check
1410 # opannotate -t 0.5 --source --assembly
1411 -- 
1412 Install ATI's fglrx driver for Xorg / X.org:
1413
1414 Usually there already exist drivers for the grml-system:
1415 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1416
1417 After installing adjust xorg.conf via running:
1418 # aticonfig --initial --input=/etc/X11/xorg.conf
1419
1420 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1421 -- 
1422 Install nvidia driver for Xorg / X.org:
1423
1424 Usually there already exist drivers for the grml-system:
1425 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
1426
1427 Then switch from module nv to nvidia:
1428
1429 # sed -i 's/Driver.*nv.*/Driver      "nvidia"/' /etc/X11/xorg.conf
1430 -- 
1431 glxgears - a GLX demo that draws three rotating gears
1432
1433 To print frames per second (fps) use:
1434 % glxgears -printfps
1435 -- 
1436 You forgot to boot with 'grml noeject noprompt' to avoid
1437 ejecting and prompting for CD removal when rebooting/halting
1438 the system?
1439
1440 Either run:
1441
1442 # noeject reboot
1443
1444 or:
1445
1446 # noeject halt
1447
1448 If you want to avoid only the prompting part, run:
1449
1450 # noprompt reboot
1451
1452 or:
1453
1454 # noprompt halt
1455 -- 
1456 Mount wikipedia local via fuse:
1457
1458 Adjust configuration:
1459 % cat ~/.wikipediafs/config.xml
1460 <wfs-config>
1461     <general>
1462        <article-cache-time>300</article-cache-time>
1463     </general>
1464     <sites>
1465       <site>
1466         <dirname>wikipedia-de</dirname>
1467         <host>de.wikipedia.org</host>
1468         <basename>/w/index.php</basename>
1469       </site>
1470       <site>
1471         <dirname>wikipedia-en</dirname>
1472         <host>en.wikipedia.org</host>
1473         <basename>/w/index.php</basename>
1474       </site>
1475     </sites>
1476 </wfs-config>
1477
1478 Mount it (/wiki must exist of course):
1479 % mount.wikipediafs /wiki
1480 % cat /wiki/wikipedia-en/Cat
1481
1482 Unmount via:
1483 % fusermount -u /wiki
1484 -- 
1485 Remote notification on X via osd (on screen display):
1486
1487 Start osd_server.py at your local host (listens on port 1234 by default):
1488 % osd_server.py
1489
1490 Then login to a $REMOTEHOST
1491 % ssh -R 1234:localhost:1234 $REMOTEHOST
1492
1493 Now send the text to your local display via running something like:
1494 % echo "text to send" | nc localhost 1234
1495
1496 Very useful when you are waiting for a long running job
1497 but want to do something else in the meanwhile:
1498
1499 % ./configure && make && echo "finished compiling" | netcat localhost 1234
1500
1501 You can use this in external programs as well of course. Examples:
1502
1503 Use osd in centericq:
1504
1505 % cat ~/.centericq/external
1506 [...]
1507 %action osd notify
1508 event msg
1509 proto all
1510 status all
1511 options nowait
1512 %exec
1513 #!/bin/bash
1514 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
1515   CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
1516   osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
1517   if echo | socat - TCP4:localhost:1234 &>/dev/null ; then
1518     echo "${osd_msg}" | netcat localhost 1234
1519   fi
1520 fi
1521
1522 Use it in the IRC console client irssi via running:
1523
1524 /script load osd.pl
1525
1526 You can even activate the port forwarding by default globally:
1527
1528 % cat ~/.ssh/config
1529 [...]
1530 Host *
1531 RemoteForward 1234 127.0.0.1:1234
1532 ForwardAgent yes
1533
1534 Notice: if you get 'ABORT: Requested font not found' make sure the
1535 requested font is available, running 'LANG=C LC_ALL=C osd_server.py...'
1536 might help as well.
1537 -- 
1538 Avoid automatical startup of init scripts via invoke-rc.d:
1539
1540 First of all make sure the package policyrcd-script-zg2 (which
1541 provides the /usr/sbin/policy-rc.d interface) is installed.
1542
1543 In policyrcd-script-zg2's configuration file named
1544 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
1545 defined as the interface for handling invoke-rc.d's startup policy.
1546
1547 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf.  By
1548 default you won't notice any differences to Debian's default
1549 behaviour, except that invoke-rc.d won't be executed if a chroot has
1550 been detected (detection: /proc is missing).
1551
1552 If you want to disable automatical startup of newly installed packages
1553 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
1554 /etc/policy-rc.d.conf.
1555
1556 To restore the default behaviour set EXITSTATUS back to '0' in
1557 /etc/policy-rc.d.conf.
1558 -- 
1559 Install VMware-Tools for grml:
1560
1561 First of all make sure a CD-ROM device in VMware is available.
1562
1563 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
1564 the tools running:
1565
1566 cd /tmp
1567 unp /mnt/cdrom/vmware-linux-tools.tar.gz
1568 cd vmware-tools-distrib
1569 ./vmware-install.pl
1570
1571 /etc/init.d/networking stop
1572 rmmod pcnet32
1573 rmmod vmxnet
1574 depmod -a
1575 modprobe vmxnet
1576 /etc/init.d/networking start
1577
1578 In an X terminal, launch the VMware Tools running:
1579
1580 vmware-toolbox
1581 -- 
1582 Some important Postfix stuff
1583
1584 List mail queue:
1585
1586 # mailq
1587 or
1588 # postqueue -p
1589
1590 Send all messages in the queue:
1591
1592 # postqueue -f
1593
1594 Send all messages in the queue for a specific site:
1595
1596 # postqueue -s site
1597
1598 Delete a specific message
1599 # postsuper -d 12345678942
1600
1601 Deletes all messages held in the queue for later delivery
1602 # postsuper -d ALL deferred
1603
1604 Mail queues in postfix:
1605
1606     incoming -> mail who just entered the system
1607     active   -> mail to be delivered
1608     deferred -> mail to be delivered later because there were problems
1609     hold     -> mail that should not be delivered until released from hold
1610
1611 For configuration of postfix take a look at
1612 /etc/postfix/master.cf  - man 5 master
1613 /etc/postfix/main.cf    - man 5 postconf
1614 and http://www.postfix.org/documentation.html.
1615 -- 
1616 File permissions
1617
1618 mode 4000 - set user ID (suid):
1619
1620 - for executable files: run as the user who owns the file, instead of the
1621   user who runs the file
1622 - for directories: not used
1623
1624 mode 2000 - set group ID (guid):
1625
1626 - for executable files: run as the group who owns the file, instead of the
1627   group of the user who runs the file
1628 - for directories: when a file is created inside the directory, it belongs
1629   to the group of the directory instead of the default group of the user who
1630   created the file
1631
1632 mode 1000 - sticky bit:
1633
1634 - for files: not used
1635 - for directories: only the owner of a file can delete or rename the file
1636 -- 
1637 Create MySQL database
1638
1639 # apt-get install mysql-client mysql-server
1640
1641 Run 'mysql' as root - create a database with:
1642
1643 create database grml
1644
1645 Give a user access to the database (without password):
1646
1647 grant all on grml.* to mika;
1648
1649 Give a user access to the database (with password):
1650
1651 grant all on grml.* to enrico identified by "PASSWORD";
1652 -- 
1653 Setup an HTTPS website:
1654
1655 Create a certificate:
1656
1657 # mkdir /etc/apache2/ssl
1658 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
1659
1660 Create a virtual host on port 443:
1661
1662 <VirtualHost www.foo.invalid:443>
1663 [...]
1664 </VirtualHost>
1665
1666 Enable SSL in the VirtualHost:
1667
1668 SSLEngine On
1669 SSLCertificateFile /etc/apache2/ssl/apache.pem
1670
1671 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
1672
1673 Listen 443
1674
1675 and make sure the SSL module is used:
1676
1677 # a2enmod ssl
1678 -- 
1679 Useful Apache / Apache2 stuff
1680
1681 Check configuration file via running:
1682
1683 # apache2ctl configtest
1684
1685 Enable a site:
1686
1687 # a2ensite sitename
1688
1689 Enable a module
1690
1691 # a2enmod modulename
1692 -- 
1693 Create tar archive and store it on remote machine:
1694
1695 % tar zcf - /sourcedir | ssh user@targethost "cat >file.tgz"
1696 -- 
1697 Pick out and displays images from network traffic:
1698
1699 # driftnet
1700 -- 
1701 Install Flash plugin:
1702
1703 # dpkg-reconfigure flashplugin-nonfree
1704 -- 
1705 To test a proxy, low level way:
1706
1707 % telnet proxy 8080
1708 [...]
1709 GET http://www.google.com HTTP/1.0 [press enter twice]
1710 -- 
1711 Adjust system for use of qemu with kqemu:
1712
1713 Make sure you have all you need:
1714 # apt-get update ; apt-get install qemu grml-kerneladdons-$KERNELVERSION
1715
1716 Then set up kqemu:
1717
1718 modprobe kqemu
1719 mknod /dev/kqemu c 250 0
1720 chmod 666 /dev/kqemu
1721 chmod 666 /dev/net/tun
1722
1723 Check kqemu support via starting qemu, press
1724 Ctrl-Alt-2 and entering 'info kqemu'.
1725 -- 
1726 (High-Load) Debugging related tools:
1727
1728 mpstat  # report processors related statistics
1729 iostat  # report CPU statistics and input/output statistics for devices and partitions
1730 vmstat  # report virtual memory statistics
1731 slabtop # display kernel slab cache information in real time
1732 atsar   # system activity report
1733 dstat   # versatile tool for generating system resource statistics
1734
1735 Usage examples:
1736
1737 # mpstat -P ALL
1738 # iostat -x 1
1739 # iostat -xtc 5 3
1740 # vmstat 1
1741 # atsar -t 60 10
1742 # dstat -af
1743 -- 
1744 Using WPA for network setup manually:
1745
1746 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
1747
1748 Adjust the options and configuration file to your needs.
1749 Also take a look at 'grml-network'.
1750 -- 
1751 Start X and lock console via exiting:
1752
1753 % startx 2>~/.xsession-errors &| exit
1754 -- 
1755 Which process is writing to disk?
1756
1757 # echo 1 > /proc/sys/vm/block_dump
1758
1759 Warning: you must disable syslogd before you do this, or you must
1760 make sure that kernel output is not logged.
1761
1762 When you're done, disable block dump using:
1763 # echo 0 > /proc/sys/vm/block_dump
1764
1765 Alternative:
1766 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
1767 which handles block_dump on its own.
1768 -- 
1769 Install initrd via initramfs-tools for currently running kernel:
1770
1771 # update-initramfs -c -t -k $(uname -r)
1772 -- 
1773 Install initrd via yaird for currently running kernel:
1774
1775 # yaird -o /boot/initrd.img-$(uname -r)
1776
1777 Install initrd via yaird for specific kernel:
1778
1779 # mount /proc
1780 # mount /sys
1781 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
1782 -- 
1783 Reinstall package with its original configuration files:
1784
1785 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o \
1786   DPkg::Options::=--force-confnew package
1787 -- 
1788 grml 0.8 funkenzutzler - rt2x00 drivers:
1789
1790 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
1791 includes beta-version drivers) is not installed by default. If you want to
1792 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
1793 rt73usb please install the package manually running:
1794
1795 # dpkg -i /usr/src/rt2x00-modules-*.deb
1796 -- 
1797 Use Java with jikes and jamvm on grml:
1798
1799 Simple demo:
1800
1801 % cp /usr/share/doc/grml-templates/template.java .
1802 % jikes template.java
1803 % jamvm HelloWorld
1804
1805 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
1806 so you do not have to manually run
1807 jikes --bootclasspath /usr/share/classpath/glibj.zip
1808 -- 
1809 Online resizing of (Software-)RAID5:
1810
1811 # Initiate a RAID5 setup for testing purposes:
1812 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
1813
1814 # Create filesystem, mount md0, create a testfile and save md5sum for
1815 # later check:
1816 mkfs.ext3 /dev/md0
1817 mount /dev/md0 /mnt/test
1818 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
1819 md5sum /mnt/test/dd > md5sum
1820
1821 # Make sure the RAID is synched via checking:
1822 cat /proc/mdstat
1823
1824 # Now remove one partition:
1825 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
1826
1827 # Delete partition, create a new + bigger one and set partition type to fd
1828 # (Linux raid autodetect):
1829 cfdisk /dev/hdd
1830
1831 # And re-add the partition:
1832 mdadm -a /dev/md0 /dev/hdd1
1833
1834 # Make sure the RAID is synched via checking:
1835 cat /proc/mdstat
1836
1837 # Repeat the steps for all other disks/partitions as well:
1838 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
1839 cfdisk /dev/hdb
1840 mdadm -a /dev/md0 /dev/hdb1
1841 cat /proc/mdstat
1842 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
1843 cfdisk /dev/hda
1844 mdadm -a /dev/md0 /dev/hda1
1845 cat /proc/mdstat
1846
1847 # Now resize the RAID5 system online [see 'man mdadm' for details]:
1848 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
1849 mdadm --grow /dev/md0 -z max
1850 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
1851
1852 # Last step - resize the filesystem (online again):
1853 resize2fs /dev/md0
1854 -- 
1855 ext3 online resizing:
1856
1857 Starting with Linux kernel 2.6.10 you can resize ext3 online.  With
1858 e2fsprogs >=1.39-1 new filesystems are created with directory indexing and
1859 on-line resizing enabled by default (see /etc/mke2fs.conf).
1860
1861 Demo:
1862
1863 cfdisk /dev/hda                           # create a partition with type 8e (lvm)
1864 pvcreate /dev/hda2                        # create a physical volume
1865 vgcreate resize_me /dev/hda2              # create volume group
1866 lvcreate -n resize_me -L100 resize_me     # create a logical volume
1867 mkfs.ext3 /dev/resize_me/resize_me        # now create a new filesystem
1868 mount /dev/resize_me/resize_me /mnt/test  # mount the new fs for demonstrating online resizing
1869 df -h                                     # check the size of the partition
1870 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
1871 resize2fs /dev/resize_me/resize_me        # and finally resize the filesystem
1872 df -h                                     # recheck the size of the partition
1873
1874 This also works for Software-RAID. Demo:
1875
1876 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
1877 mkfs.ext3 /dev/md0
1878 mount /dev/md0 /mnt/test
1879 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
1880 cfdisk /dev/hda                                  # adjust partition size for hda2
1881 mdadm /dev/md0 --add /dev/hda2
1882 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
1883 cfdisk /dev/hdb                                  # adjust partition size for hdb1
1884 mdadm /dev/md0 --add /dev/hdb1
1885 mdadm --grow /dev/md0 --size=max
1886 resize2fs /dev/md0
1887
1888 Notice: online resizing works as soon as the kernel can re-read the
1889 partition table. So it works for example with LVM and SW-RAID but not with
1890 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
1891 table if the device is already mounted.
1892 -- 
1893 Use vim as an outline editor:
1894
1895 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
1896 % vim ~/foo.otl
1897 :he vo
1898 -- 
1899 Monitor directories/files for changes using iwatch
1900
1901 Monitor /tmp for changes:
1902 % iwatch /tmp/
1903
1904 Monitor files/directories specified in /etc/iwatch.xml
1905 and send mail on changes:
1906 % iwatch
1907 -- 
1908 Some often used mdadm commands:
1909
1910 Set up RAID1:
1911 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
1912
1913 Display details of specific RAID:
1914 # mdadm --detail /dev/md0
1915 # cat /proc/mdstat
1916
1917 Simulating a drive failure by software:
1918 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
1919
1920 Remove disk from RAID:
1921 # mdadm /dev/md0 -r /dev/hda1
1922
1923 Set disk as faulty and remove from RAID:
1924 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
1925
1926 Stop a RAID-device:
1927 # mdadm -S /dev/md0
1928
1929 Restart a RAID-device:
1930 # mdadm -R /dev/md0
1931
1932 Add another disk to existing RAID setup (hotadd):
1933 # mdadm /dev/md0 -a /dev/hde1
1934 # mdadm --grow /dev/md0 --raid-devices=4
1935
1936 Assemble and start all arrays:
1937 # mdadm --assemble --scan
1938
1939 Assemble a specific array:
1940 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
1941
1942 Resync:
1943 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
1944
1945 Stop and rebuild:
1946 # mdadm --stop --scan
1947
1948 Scan for and setup arrays automatically:
1949 # mdadm --assemble --scan --auto=yes --verbose
1950
1951 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
1952 DEVICE partitions
1953 CREATE owner=root group=disk mode=0660 auto=yes
1954 HOMEHOST <system>
1955 MAILADDR root
1956
1957 Running
1958 # /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
1959 might help as well.
1960
1961 Monitoring the sw raid
1962 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
1963
1964 Producing /etc/mdadm/mdadm.conf:
1965 # mdadm --detail --scan > /etc/mdadm/mdadm.conf
1966
1967 See also: man mdadm | less -p "^EXAMPLES"
1968           http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
1969 -- 
1970 A quick summary of the most commonly used RAID levels:
1971
1972 RAID 0: Striped Set
1973  => 2 disks each 160 GB: 320 GB data
1974 RAID 1: Mirrored Set
1975  => 2 disks each 160 GB: 160 GB data
1976 RAID 5: Striped Set with Parity
1977  => 3 disks each 160 GB: 320 GB data; 160 GB redundancy
1978
1979 Common nested RAID levels:
1980 RAID 01: A mirror of stripes
1981 RAID 10: A stripe of mirrors
1982 RAID 30: A stripe across dedicated parity RAID systems
1983 RAID 100: A stripe of a stripe of mirrors
1984
1985   -- http://en.wikipedia.org/wiki/RAID
1986 -- 
1987 Logical Volume Management (LVM) with Linux
1988
1989 LVM setup layout:
1990 ~~~~~~~~~~~~~~~~~
1991
1992 |    hda1   hdc1      (PV:s on partitions or whole disks)
1993 |       \   /
1994 |        \ /
1995 |       diskvg        (VG)
1996 |       /  |  \
1997 |      /   |   \
1998 |  usrlv rootlv varlv (LV:s)
1999 |    |      |     |
2000 | ext3    ext3  xfs   (filesystems)
2001
2002 Often used commands:
2003 ~~~~~~~~~~~~~~~~~~~~
2004
2005 Create a physical volume:
2006 # pvcreate /dev/hda2
2007
2008 Create a volume group:
2009 # vgcreate testvg /dev/hda2
2010
2011 Create a logical volume:
2012 # lvcreate -n test_lv -L100 testvg
2013
2014 Resize a logical volume:
2015 # lvextend -L+100M /dev/resize_me/resize_me
2016 # resize2fs /dev/resize_me/resize_me               # ext2/3
2017 # xfs_growfs  /dev/resize_me/resize_me             # xfs
2018 # resize_reiserfs -f /dev/resize_me/resize_me      # reiserfs online
2019 # mount -o remount,resize /dev/resize_me/resize_me # jfs
2020
2021 Create a snapshot of a logical volume:
2022 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2023
2024 Deactivate a volume group:
2025 # vgchange -a n my_volume_group
2026
2027 Actually remove a volume group:
2028 # vgremove my_volume_group
2029
2030 Display information about physical volume:
2031 # pvdisplay /dev/hda1
2032
2033 Remove physical volume:
2034 # vgreduce my_volume_group /dev/hda1
2035
2036 Remove logical volume:
2037 # umount /dev/myvg/homevol
2038 # lvremove /dev/myvg/homevol
2039
2040 See also: man lvm
2041           http://www.tldp.org/HOWTO/LVM-HOWTO/
2042 -- 
2043 How to use APT locally
2044
2045 Sometimes you have lots of packages .deb that you would like to use APT to
2046 install so that the dependencies would be automatically solved. Solution:
2047
2048 mkdir debs
2049 dpkg-scanpackages debs /dev/null | gzip > debs/Packages.gz
2050 echo "  deb file:/root debs/" >> /etc/apt/sources.list
2051 dpkg-scansources debs | gzip > debs/Sources.gz
2052 echo "  deb-src file:/root debs/" >> /etc/apt/sources.list
2053
2054 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2055 -- 
2056 Check filesystem's LABEL:
2057
2058 generic way:
2059 # vol_id -l /dev/sda1
2060
2061 ext2/3 without vol_id:
2062 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2063
2064 xfs without vol_id:
2065 # xfs_admin -l /dev/sda1
2066
2067 reiserfs without vol_id:
2068 # debugreiserfs /dev/sda1 | grep UUID
2069
2070 reiser4 without vol_id:
2071 # debugfs.reiser4 /dev/sda1 | grep uuid
2072 -- 
2073 Check filesystem's UUID:
2074
2075 generic way:
2076 # vol_id -u /dev/sda1
2077
2078 ext2/3 without vol_id:
2079 # dumpe2fs /dev/sda1 | grep UUID
2080
2081 xfs without vol_id:
2082 # xfs_admin -u /dev/sda1
2083
2084 reiserfs without vol_id:
2085 # debugreiserfs /dev/sda1 | grep LABEL
2086
2087 reiser4 without vol_id:
2088 # debugfs.reiser4 /dev/sda1 | grep label
2089 -- 
2090 Disable pdiffs feature of APT:
2091
2092 Permanent:
2093 # echo 'Acquire::PDiffs "false";' >> /etc/apt/apt.conf
2094
2095 Temporary:
2096 # apt-get update -o Acquire::Pdiffs=false
2097 -- 
2098 Backup big devices or files and create compressed splitted
2099 image chunks of it using zsplit
2100
2101 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2102 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2103 read/write buffer to 256kB:
2104 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2105
2106 Restore the backup using unzsplit:
2107 # unzsplit -D /dev/sda -d archiveofsda
2108
2109 More usage examples: man zsplit + man unzsplit
2110 -- 
2111 Measure network performance using ipserf
2112
2113 Server side:
2114 % iperf -s -V
2115
2116 Client side:
2117 % iperf -c <server_address> -V
2118
2119 or
2120
2121 Server with 128k TCP window size:
2122 % iperf -s -w128k
2123
2124 Client with running for 60 seconds and bidirectional test:
2125 % iperf -c <server_address> -r -w128k -t60
2126 -- 
2127 Framebuffer resolutions:
2128
2129                               Resolution in pixels
2130 Color depth      |   640x480      800x600      1024x768      1280x1024
2131 256        (8bit)|     769          771           773           775
2132 32000     (15bit)|     784          787           790           793
2133 65000     (16bit)|     785          788           791           794
2134 16.7 Mill.(24bit)|     786          789           792           795
2135
2136 vga=0x... modes:
2137
2138   Mode 0x0300: 640x400 (+640), 8 bits
2139   Mode 0x0301: 640x480 (+640), 8 bits
2140   Mode 0x0303: 800x600 (+800), 8 bits
2141   Mode 0x0303: 800x600 (+832), 8 bits
2142   Mode 0x0305: 1024x768 (+1024), 8 bits
2143   Mode 0x0307: 1280x1024 (+1280), 8 bits
2144   Mode 0x030e: 320x200 (+640), 16 bits
2145   Mode 0x030f: 320x200 (+1280), 24 bits
2146   Mode 0x0311: 640x480 (+1280), 16 bits
2147   Mode 0x0312: 640x480 (+2560), 24 bits
2148   Mode 0x0314: 800x600 (+1600), 16 bits
2149   Mode 0x0315: 800x600 (+3200), 24 bits
2150   Mode 0x0317: 1024x768 (+2048), 16 bits
2151   Mode 0x0318: 1024x768 (+4096), 24 bits
2152   Mode 0x031a: 1280x1024 (+2560), 16 bits
2153   Mode 0x031b: 1280x1024 (+5120), 24 bits
2154   Mode 0x0330: 320x200 (+320), 8 bits
2155   Mode 0x0331: 320x400 (+320), 8 bits
2156   Mode 0x0332: 320x400 (+640), 16 bits
2157   Mode 0x0333: 320x400 (+1280), 24 bits
2158   Mode 0x0334: 320x240 (+320), 8 bits
2159   Mode 0x0335: 320x240 (+640), 16 bits
2160   Mode 0x0336: 320x240 (+1280), 24 bits
2161   Mode 0x033c: 1400x1050 (+1408), 8 bits
2162   Mode 0x033d: 640x400 (+1280), 16 bits
2163   Mode 0x033e: 640x400 (+2560), 24 bits
2164   Mode 0x0345: 1600x1200 (+1600), 8 bits
2165   Mode 0x0346: 1600x1200 (+3200), 16 bits
2166   Mode 0x034d: 1400x1050 (+2816), 16 bits
2167   Mode 0x035c: 1400x1050 (+5632), 24 bits
2168 -- 
2169 Portscan using netcat:
2170
2171 # netcat -v -w2 <host|ip-addr.> 1-1024
2172 -- 
2173 Run apt-get but disable apt-listchanges:
2174
2175 APT_LISTCHANGES_FRONTEND=none apt-get ...
2176
2177 Upgrade system but disable apt-listbugs:
2178
2179 APT_LISTBUGS_FRONTEND=none apt-get ...
2180 -- 
2181 Set up a Transparent Debian Proxy
2182
2183 Install of apt-cacher, the default config will do:
2184 # apt-get install apt-cacher
2185
2186 Check out the ip address of debian mirror(s).
2187 Then add this to your firewall script:
2188
2189 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2190 for ip in ${DEBIAN_MIRRORS} ; do
2191   ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2192 done
2193
2194 where ${IPTABLES} is the location of your iptables binary
2195 and $subnet is your internal subnet.
2196
2197 Now everybody in your subnet who does access either
2198 ftp.de.debian.org or ftp.at.debian.org will actually
2199 access your apt-cacher instead.
2200
2201 To use apt-cacher on the router itself, add the following
2202 line to your /etc/apt/apt.conf:
2203
2204 Acquire::http::Proxy "http://localhost:3142/";
2205 -- 
2206 Version control using Mercurial
2207
2208 Setting up a Mercurial project:
2209
2210 % cd project
2211 % hg init           # creates .hg
2212 % hg add            # add all files
2213 % hg commit         # commit all changes, edit changelog entry
2214
2215 Branching and merging:
2216
2217 % hg clone linux linux-work  # create a new branch
2218 % cd linux-work
2219 <make changes>
2220 % hg commit
2221 % cd ../linux
2222 % hg pull ../linux-work     # pull changesets from linux-work
2223 % hg merge                  # merge the new tip from linux-work into
2224                             # (old versions used "hg update -m" instead)
2225                             # our working directory
2226 % hg commit                 # commit the result of the merge
2227
2228 Importing patches:
2229
2230 % cat ../p/patchlist | xargs hg import -p1 -b ../p
2231
2232 Exporting a patch:
2233
2234 (make changes)
2235 % hg commit
2236 % hg tip
2237 1234:af3b5cd57dd5
2238 % hg export 1234 > foo.patch    # export changeset 1234
2239
2240 Export your current repo via HTTP with browsable interface:
2241
2242 % hg serve -n "My repo" -p 80
2243
2244 Pushing changes to a remote repo with SSH:
2245
2246 % hg push ssh://user@example.com/~/hg/
2247
2248 Merge changes from a remote machine:
2249
2250 host1% hg pull http://foo/
2251 host2% hg merge # merge changes into your working directory
2252
2253 Set up a CGI server on your webserver:
2254 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
2255 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
2256
2257 Mercurial repositories of grml can be found at http://hg.grml.org/
2258 -- 
2259 Download binary codecs for mplayer:
2260
2261 # /usr/share/mplayer/scripts/win32codecs.sh
2262
2263 To play encrypted DVDs and if you are living in a country where using
2264 libdvdcss code is not illegal can install Debian package libdvdread3
2265 and use the script /usr/share/doc/libdvdread3/install-css.sh.
2266 -- 
2267 Read manpages of uninstalled packages with debman:
2268
2269 % debman -p git-core git
2270 -- 
2271 Test network performance using netperf:
2272
2273 Server:
2274 # netserver
2275
2276 Client:
2277 # netperf -t TCP_STREAM -H 192.168.0.41
2278 -- 
2279 Setup Xen within 20 minutes on Debian/grml
2280
2281 Install relevant software und update grub's menu.lst (Xen does not work with
2282 usual lilo so install grub instead if not done already):
2283
2284 apt-get install linux-image-2.6.18-1-xen-686 xen-hypervisor-3.0.3-1-i386 \
2285                  xen-utils-3.0.3-1 xen-tools bridge-utils
2286 update-grub
2287
2288 Example for installation of Debian etch as DomU:
2289
2290 mkdir /mnt/md1/xen
2291 xen-create-image --debootstrap --dir=/mnt/md1/xen --size=2Gb --memory=512Mb --fs=ext3 \
2292    --cache=yes --dist=etch --hostname=xengrml1 --ip 192.168.1.2 --netmask 255.255.255.0 \
2293   --gateway 192.168.1.1 --initrd=/boot/initrd.img-2.6.18-1-xen-686 \
2294   --kernel=/boot/vmlinuz-2.6.18-1-xen-686 --mirror=http://ftp.at.debian.org/debian/
2295
2296 Start services:
2297
2298 /etc/init.d/xend start
2299 /etc/init.d/xendomains start
2300
2301 Setup a bridge for network, either manually:
2302
2303 brctl addbr xenintbr
2304 brctl stp xenintbr off
2305 brctl sethello xenintbr 0
2306 brctl setfd xenintbr 0
2307 ifconfig xenintbr 192.168.1.1 netmask 255.255.255.0 up
2308
2309 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
2310 without rebooting):
2311
2312 auto xenintbr
2313 iface xenintbr inet static
2314   pre-up brctl addbr xenintbr
2315   post-down brctl delbr xenintbr
2316   address 192.168.1.1
2317   netmask 255.255.255.0
2318   bridge_fd 0
2319   bridge_hello 0
2320   bridge_stp off
2321
2322 Setup forwarding (adjust $PUBLIC_IP; for permanet setup use /etc/sysctl.conf and
2323 add the iptables commands to a startup script like /etc/init.d/rc.local):
2324
2325 echo 1 > /proc/sys/net/ipv4/ip_forward
2326 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to $PUBLIC_IP
2327 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $PUBLIC_IP
2328
2329 Adjust network configuration of Xend:
2330
2331 cat >> /etc/xen/xend-config.sxp << EOF
2332 (network-script    network-route)
2333 (vif-bridge        xenintbr)
2334 (vif-script        vif-bridge)
2335 EOF
2336
2337 List domains, start up a DomU, shutdown later again:
2338
2339 xm create -c /etc/xen/xengrml1.cfg
2340 xm list
2341 xm shutdown 1
2342
2343 This HowTo is also available online at http://grml.org/xen/
2344 -- 
2345 Play tetris with zsh:
2346
2347 autoload -U tetris
2348 zle -N tetris
2349 bindkey "^Xt" tetris
2350
2351 Now press 'ctrl-x t'.
2352 -- 
2353 Set up a router with grml
2354
2355 Run grml-router script:
2356 # grml-router
2357
2358 Install dnsmasq if not already present:
2359 # apt-get update ; apt-get install dnsmasq
2360
2361 Adjust /etc/dnsmasq.conf according to your needs:
2362 # cat >> /etc/dnsmasq.conf << EOF
2363 domain-needed
2364 bogus-priv
2365 dhcp-range=19.168.0.124,192.168.0.254,1m # dhcp range
2366 dhcp-option=3,192.168.0.1   # dns server
2367 dhcp-option=1,255.255.255.0 # netmask
2368 EOF
2369
2370 Start dnsmasq finally:
2371 # Restart dnsmasq
2372 -- 
2373 Find out which process(es) cause the disk to spin up:
2374
2375 # echo 1 > /proc/sys/vm/block_dump
2376
2377 The command sets a sysctl to cause the kernel to log all disk
2378 writes. Please notice that there is a lot of data.
2379
2380 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2381
2382 Also take a look at event-viewer(8).
2383 -- 
2384 Display stats about memory allocations performed by a program:
2385
2386 Usage example for 'ls':
2387
2388 % LD_PRELOAD=/lib/libmemusage.so ls > /dev/null
2389 -- 
2390 Use KVM (Kernel-based Virtual Machine for Linux):
2391
2392 Make sure to install the relevant tools:
2393 # apt-get update ; apt-get install kvm
2394 # modprobe kvm
2395
2396 Test it with a minimal system like ttylinux:
2397 # wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz
2398 # gzip -d bootcd-i386-5.3.iso.gz
2399 # kvm -cdrom bootcd-i386-5.3.iso
2400 --