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