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