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