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