1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3 <title>grml.org - grml Tips</title>
4 <meta name="Title" content="grml.org - grml Tips" />
5 <meta name="Author" content="the grml team [www.grml.org/team/]" />
6 <meta name="Keywords" content="grml.org, grml" />
7 <meta name="Description" content="grml Tips" />
8 <meta name="Abstract" content="grml, just another linux-distribution" />
9 <meta name="fdse-index-as" content="http://www.grml.org/tips/" />
10 <meta name="Robots" content="index,follow" />
11 <meta name="Language" content="english" />
12 <meta name="identifier-url" content="http://www.grml.org/" />
13 <meta name="MSSmartTagsPreventParsing" content="true" />
14 <meta http-equiv="imagetoolbar" content="no" />
15 <link rel="home" href="/" title="grml.org" />
16 <link rel="help" href="/features/" title="About" />
17 <link rel="author" href="/team/" title="Team" />
18 <link rel="icon" href="/favicon.png" type="image/png" />
19 <link rel="stylesheet" href="/style.css" type="text/css" />
25 Install grml to harddisk:
29 Notice: You can pre-select the partition for the partition selector
30 and mbr dialogs inside grml2hd using:
31 # grml2hd /dev/hda1 -mbr /dev/hda
33 See: man grml2hd + http://grml.org/grml2hd/
35 Tags: grml2hd, installation
37 <a name="1"></a><hr />
39 Install grml on software RAID level 1:
41 Create /dev/md0 (and some more /dev/md* devices) first of all:
42 # cd /dev && MAKEDEV dev
45 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdc1
47 Finally install grml on it:
48 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
50 See: man grml2hd + http://grml.org/grml2hd/
52 Tags: grml2hd, installation, mdadm, raid
54 <a name="2"></a><hr />
56 Install grml in non interactive mode with grml2hd:
58 Adjust configuration as needed:
59 # vim /etc/grml2hd/config
63 # GRML2HD_NONINTERACTIVE=yes grml2hd
69 Use with care and only if you really know what you are doing!
71 See: man grml2hd + http://grml.org/grml2hd/
73 Tags: grml2hd, installation
75 <a name="3"></a><hr />
81 Tags: configuration, network
83 <a name="4"></a><hr />
85 Deactivate error correction of zsh:
89 Run zsh-help for more information regarding zsh.
91 Tags: zsh, configuration
93 <a name="5"></a><hr />
95 Disable automatic setting of title in GNU screen:
99 Set it manually e.g. via:
101 % screen -X title foobar
103 Run zsh-help for more information regarding zsh.
105 Tags: zsh, configuration
107 <a name="6"></a><hr />
109 Do not use menu completion in zsh:
113 Run zsh-help for more information regarding zsh.
115 Tags: zsh, configuration
117 <a name="7"></a><hr />
119 Run GNU screen with grml-configuration:
125 % screen -c /etc/grml/screenrc
127 Tags: screen, configuration
129 <a name="8"></a><hr />
131 Print out grml-version:
137 <a name="9"></a><hr />
145 <a name="10"></a><hr />
147 Configure mutt-ng / muttng:
153 <a name="11"></a><hr />
155 Set up Inode-PPTP connection:
159 # grml-pptp-xdsl-students
161 Tags: pptp, inode, xdsl
163 <a name="12"></a><hr />
165 Set up VPN / WLAN connection at TUG (TU Graz):
167 Set ESSID and request for ip-address via DHCP:
168 # iwconfig $DEVICE essid tug
171 Now run the main script:
174 After running the script an init script is available:
176 # /etc/init.d/vpnctug [start|stop]
180 <a name="13"></a><hr />
182 Set up PPTP connection at VCG (Virtual Campus Graz):
188 <a name="14"></a><hr />
192 # grml-vpn <options>
196 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
200 Tags: grml, vpn, network
202 <a name="15"></a><hr />
204 Use encrypted files / partitions:
206 # grml-crypt <options>
212 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
213 # cp big_file /mnt/test
214 # grml-crypt stop /mnt/test
218 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
219 # grml-crypt stop /mnt/test
223 Tags: crypto, grml-crypt, dmcrypt, luks
225 <a name="16"></a><hr />
227 Change resolution of X:
229 % xrandr -s '1024x768'
231 Tags: x11, xorg, resolution
233 <a name="17"></a><hr />
235 Change resolution of framebuffer:
241 <a name="18"></a><hr />
243 Configure newsreader slrn:
249 <a name="19"></a><hr />
251 Configure grml system:
255 Or directly run scripts:
260 Tags: grml, configuration
262 <a name="20"></a><hr />
264 Lock screen (X / console):
268 Press ctrl-alt-x to lock a GNU screen session.
270 Tags: grml, lock, grml-lock, screen
272 <a name="21"></a><hr />
274 Change wallpaper in X:
276 % grml-wallpaper <press-tab>
278 Tags: grml, wallpaper
280 <a name="22"></a><hr />
282 Start X window system (XFree86 / Xorg / X.org):
284 % grml-x $WINDOWMANAGER
289 % grml-x -mode '1024x768' wmii
290 % grml-x -nosync wm-ng
292 Tags: grml-x, x11, xorg, graphic
294 <a name="23"></a><hr />
296 Collect hardware information:
300 or run as root to collect some more information:
304 will generate a file named info.tar.bz2.
306 Tags: grml, hardware, hwinfo, collect
308 <a name="24"></a><hr />
310 Configure hardware detection features of harddisk installation:
314 or manually edit /etc/grml/autoconfig[.small]
316 See: man grml-autoconfig
318 Tags: grml, installation, configuration
320 <a name="25"></a><hr />
322 Bootoptions / cheatcodes / bootparams for booting grml:
324 On the grml-ISO if not running grml:
325 % less /cdrom/GRML/grml-cheatcodes.txt
328 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
330 Tags: grml, cheatcodes, boot, bootoptions, bootparam
332 <a name="26"></a><hr />
334 Report bugs to Debian's Bug Tracking System (BTS):
336 % reportbug --bts debian
338 or adjust /etc/reportbug.conf to your needs.
342 http://grml.org/bugs/
343 http://www.debian.org/Bugs/
345 Tags: bug, reportbug, bts, debian
347 <a name="27"></a><hr />
349 Offline documentation:
353 Online documentation:
356 http://grml.org/docs/
357 http://wiki.grml.org/doku.php
359 Tags: info, grml, grml-info, documentation
361 <a name="28"></a><hr />
363 Mount NTFS partition (read-write):
365 # mount.ntfs-3g /dev/sda1 /mnt/sda1
369 <a name="29"></a><hr />
371 Overwrite specific file on an NTFS partition:
373 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
375 <a name="30"></a><hr />
377 Resize an NTFS partition:
383 ntfsresize -n -s 10G /dev/hda1 # testcase
384 ntfsresize -s 10G /dev/hda1 # testing was successfull, now really resize partition
385 cfdisk /dev/hda # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
387 Tags: ntfs, resize, ntfsresize
389 <a name="31"></a><hr />
391 Modify resolution for intel graphic chipsets:
397 # 915resolution 4d 1400 1050
399 <a name="32"></a><hr />
401 Connect bluetooth mouse:
405 ... and press 'connect' button on your bluetooth device.
407 <a name="33"></a><hr />
409 Connect bluetooth headset:
413 ... and press 'connect' button on your bluetooth device.
415 <a name="34"></a><hr />
417 Secure delete file / directory / partition:
423 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
425 Tags: delete, secure, wipe, shred
427 <a name="35"></a><hr />
429 Use grml on Samsung X20 laptop:
431 # apt-get install grml-samsung-x20
433 See: http://www.michael-prokop.at/computer/samsung_x20.html
435 <a name="36"></a><hr />
437 Development information regarding grml:
439 http://blog.grml.org/
441 Tags: blog, grml, developmnet
443 <a name="37"></a><hr />
447 #grml on irc.freenode.org - http://grml.org/irc/
448 http://grml.org/contact/
450 Tags: contact, irc, freenode, email
452 <a name="38"></a><hr />
454 Join the grml mailinglist:
456 http://grml.org/mailinglist/
458 Tags: grml, mailinglist
460 <a name="39"></a><hr />
464 http://grml.org/donations/
468 <a name="40"></a><hr />
470 Commercial support / system administration / adjusted live-cds:
472 grml-solutions: http://grml.org/solutions/
474 Tags: grml, commercial, customize
476 <a name="41"></a><hr />
478 Information regarding the kernel provided by grml:
480 http://grml.org/kernel/
482 Tags: documentation, grml, kernel
484 <a name="42"></a><hr />
486 SMTP command-line test tool:
488 % swaks <options>
492 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
496 Tags: swak, smtp, test
498 <a name="43"></a><hr />
500 NTFS related packages:
508 <a name="44"></a><hr />
510 Modify service through init script:
517 # /etc/init.d/lvm start
519 Tags: init, script, start, stop
521 <a name="45"></a><hr />
525 # jstest /dev/input/js0
527 <a name="46"></a><hr />
531 % mplayer /path/to/movie
535 <a name="47"></a><hr />
537 Use webcam with mplayer:
539 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
541 Tags: webcam, mplayer
543 <a name="48"></a><hr />
545 Powerful network discovery tool:
549 Tags: network, python, tool
551 <a name="49"></a><hr />
553 Grab an entire CD and compress it to Ogg/Vorbis,
554 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
558 Tags: rip, abcde, mp3, transcode, audio
560 <a name="50"></a><hr />
562 Show a console session in several terminals:
566 <a name="51"></a><hr />
568 Switch behaviour of caps lock key:
572 <a name="52"></a><hr />
574 grep with Perl-compatible regular expressions:
578 <a name="53"></a><hr />
580 ncp: a fast file copy tool for LANs
585 Remote (receive file):
588 Tags: copy, file, network
590 <a name="54"></a><hr />
592 utility for sorting records in complex ways:
596 <a name="55"></a><hr />
598 a smaller, cheaper, faster SED implementation:
602 <a name="56"></a><hr />
608 See: http://grml.org/zsh/
610 <a name="57"></a><hr />
612 zsh reference card for grml system:
615 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
617 <a name="58"></a><hr />
621 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
623 % prename 's/foo/bar/' foo*
625 % zmv 'foo(*)' 'bar$1'
627 <a name="59"></a><hr />
629 Test TFT / LCD display:
633 <a name="60"></a><hr />
639 <a name="61"></a><hr />
641 Improved grep version:
645 <a name="62"></a><hr />
647 Grep with highlighting:
649 % grep --color=auto ...
652 Tags: grep, color, highlight
654 <a name="63"></a><hr />
656 Extract matches when grepping:
659 % ifconfig | grepc 'inet addr:(.*?)s'
660 % ifconfig | glark --extract-matches 'inet addr:(.*?)s'
662 <a name="64"></a><hr />
664 Output text as sound:
667 % xsay # when running X and text selected via mouse
669 <a name="65"></a><hr />
671 Adjust a grml harddisk (grml2hd) installation:
675 Tags: grml2hd, configuration, installation
677 <a name="66"></a><hr />
679 Get information on movie files:
681 % tcprobe -i file.avi
683 <a name="67"></a><hr />
685 Get an overview of your image files:
687 % convert 'vid:*.jpg' thumbnails.jpg
689 <a name="68"></a><hr />
691 List all standard defines:
693 % gcc -dM -E - < /dev/null
695 <a name="69"></a><hr />
697 Send a mail as reminder:
699 echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
701 <a name="70"></a><hr />
703 ncurses-based presentation tool:
707 See: man tpp and /usr/share/doc/tpp/examples/
709 <a name="71"></a><hr />
711 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
715 <a name="72"></a><hr />
717 Use IRC on command line:
721 <a name="73"></a><hr />
725 % vimdiff file1 file2
731 Moving between diffs:
741 <a name="74"></a><hr />
743 Hardware monitoring without kernel dependencies:
747 <a name="75"></a><hr />
749 Install grml-iso to usb-stick:
751 % grml2usb grml.iso /mount/point
753 Tags: usbpen, usbstick, installation, grml2usb
755 <a name="76"></a><hr />
757 Use mplayer on framebuffer console:
759 % mplayer -vo fbdev ...
761 <a name="77"></a><hr />
763 Use links2 on framebuffer console:
765 % links2 -driver fb ...
767 <a name="78"></a><hr />
769 Switch language / keyboard:
771 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
772 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
773 Usage example: 'grml lang=us keyboard=de xkeyboard=de'
775 Or run one of the following commands:
779 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
782 Tags: language, keyboard, configuration
784 <a name="79"></a><hr />
786 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
790 <a name="80"></a><hr />
792 Mount usb device / usb stick:
794 % mount /mnt/external1 # corresponds to /dev/sda1
796 % mount /mnt/external # corresponds to /dev/sda
798 <a name="81"></a><hr />
800 Install Sun Java packages:
802 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
804 # apt-get install java-package
805 # fakeroot make-jpkg j2re-*.bin
806 # dpkg -i sun-j2re*.deb
807 # update-alternatives --config java
809 <a name="82"></a><hr />
813 ddrescue is an improved version of dd which tries to read and
814 if it fails it will go on with the next sectors, where tools
821 <a name="83"></a><hr />
823 How to make an audio file (e.g. Musepack format) out of a DVD track:
825 % mkfifo /tmp/fifo.wav
826 % mppenc /tmp/fifo.wav track06.mpc &
827 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
829 Adjust the mppenc line with the encoder you would like to use,
830 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
834 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
835 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
837 Usage example for getting a PCM/wave file from audio channel 128:
838 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
840 <a name="84"></a><hr />
842 Create simple chroot:
844 # make_chroot_jail $USERNAME
846 <a name="85"></a><hr />
848 Convert DOS formated file to unix format:
850 sed 's/.$//' dosfile > unixfile # assumes that all lines end with CR/LF
851 sed 's/^M$//' dosfile > unixfile # in bash/tcsh, press Ctrl-V then Ctrl-M
852 sed 's/x0D$//' dosfile > unixfile # gsed 3.02.80, but top script is easier
853 awk '{sub(/r$/,"");print}' # assumes EACH line ends with Ctrl-M
854 gawk -v BINMODE="w" '1' infile >outfile # in DOS environment; cannot be done with
855 # DOS versions of awk, other than gawk
856 tr -d r < dosfile > unixfile # GNU tr version 1.22 or higher
857 tr -d '015' < dosfile > unixfile # use octal value for "r" (see man ascii)
858 tr -d '[015032]' < dosfile > unixfile # sometimes ^Z is appended to DOS-files
859 vim -c ":set ff=unix" -c ":wq" file # convert using vim
860 vim -c "se ff=dos|x" file # ... and even shorter ;)
861 recode ibmpc..lat1 file # convert using recode
862 echo -e "s/r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
864 Tags: windows, line, convert, recode, tr, line end,
866 <a name="86"></a><hr />
868 Save live audio stream to file:
870 % mplayer -ao pcm:file=$FILE $URL
872 <a name="87"></a><hr />
874 Save live stream to file:
876 % mplayer -dumpfile $FILE -dumpstream $STREAM
880 % mencoder mms://$URL -o $FILE -ovc copy -oac copy
884 % mimms mms://file.wmv
886 <a name="88"></a><hr />
892 % avimerge -i *.avi -o blub.avi
896 % cat *.mpg > blub.mpg
900 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
901 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
902 % avimerge -i file1.avi file2.avi -o blub.avi
904 <a name="89"></a><hr />
906 Display MS-Word file:
908 % strings file.doc | fmt | less
914 <a name="90"></a><hr />
916 Convert MS-Word file to postscript:
918 % antiword -p a4 file.doc > file.ps
920 <a name="91"></a><hr />
922 Convert manual to postscript:
924 % zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
926 % man -t zsh > zsh.ps
928 <a name="92"></a><hr />
932 % dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
934 <a name="93"></a><hr />
936 Read HTTP via netcat:
938 echo -e "GET / HTTP/1.1rnHost: $DOMAINrnrn" | netcat $DOMAIN 80
940 <a name="94"></a><hr />
942 Get X ressources for specific program:
944 % xrdb -q |grep -i xterm
946 <a name="95"></a><hr />
948 Get windowid of specific X-window:
950 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
952 <a name="96"></a><hr />
954 Get titel of specific X-window:
958 <a name="97"></a><hr />
960 check locale - LC_MESSAGES:
962 % locale -ck LC_MESSAGES
964 <a name="98"></a><hr />
966 Create random password:
970 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
972 <a name="99"></a><hr />
974 Get tarballs of various Linux Kernel trees:
977 to get the current stable 2.6 release
980 to get a list of all supported trees
982 <a name="100"></a><hr />
984 Transfer your SSH public key to another host:
986 % ssh-keygen # ssh-keygen / ssh-key-gen: if you don't have a key yet
988 % ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
990 % cat $HOME/.ssh/id_rsa.pub | ssh user@remote-system 'cat >> .ssh/authorized_keys'
992 Tags: ssh, ssh key, public key, ssh-copy-id, ssh-keygen
994 <a name="101"></a><hr />
996 Update /etc/fstab entries:
1000 See "man grml-rebuildfstab" for more details about
1001 generation of /etc/fstab (including stuff like
1002 fs LABELs / UUIDs,...).
1004 <a name="102"></a><hr />
1006 Fetch and potentially change SCSI device parameters:
1012 <a name="103"></a><hr />
1014 reclaim disk space by linking identical files together:
1018 <a name="104"></a><hr />
1020 Find and remove duplicate files:
1024 <a name="105"></a><hr />
1026 Perform layer 2 attacks:
1030 Tags: network, attack, security
1032 <a name="106"></a><hr />
1036 <a name="107"></a><hr />
1038 Guess PC-type hard disk partitions / partition table:
1040 # gpart <options>
1042 Perform a standard scan:
1045 Write back the guessed table:
1046 # gpart -W /dev/ice /dev/ice
1048 Tags: partition, recovery, disk
1050 <a name="108"></a><hr />
1052 Develop, test and use exploit code with the Metasploit Framework:
1055 wget http://spool.metasploit.com/releases/framework-3.2.tar.gz
1056 unp framework-3.2.tar.gz
1060 <a name="109"></a><hr />
1062 Useful documentation:
1064 % w3m /usr/share/doc/Debian/reference/reference.en.html
1066 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
1068 http://grml.org/docs/ grml Documentation
1069 http://wiki.grml.org/ grml Wiki
1070 http://www.debian.org/doc/ Debian Documentation
1071 http://wiki.debian.org/ Debian Wiki
1072 http://www.gentoo.org/doc/en/ Gentoo Documentation
1073 http://gentoo-wiki.com/ Gentoo Wiki
1074 http://www.tldp.org/ The Linux Documentation Project
1078 % fortune debian-hints
1082 <a name="110"></a><hr />
1086 % fortune debian-hints
1087 % dpkg -L funny-manpages
1089 <a name="111"></a><hr />
1091 Backup master boot record (MBR):
1093 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
1097 <a name="112"></a><hr />
1099 Backup partition table:
1101 # sfdisk -d /dev/hda > hda.out
1103 Restore partition table:
1105 # sfdisk /dev/hda < hda.out
1107 Tags: backup, partition, sfdisk, recovery
1109 <a name="113"></a><hr />
1111 Clone disk via network using netcat:
1114 # nc -vlp 30000 > hda1.img
1116 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
1118 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
1121 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
1123 Tags: network, backup, dd, netcat
1125 <a name="114"></a><hr />
1127 Backup specific directories via cpio and ssh:
1129 # for f in directory_list; do find $f >> backup.list done
1130 # cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
1134 <a name="115"></a><hr />
1138 This one uses CPU cycles on the remote server to compare the files:
1139 # ssh target_address cat remotefile | diff - localfile
1140 # cat localfile | ssh target_address diff - remotefile
1142 This one uses CPU cycles on the local server to compare the files:
1143 # ssh target_address cat <localfile "|" diff - remotefile
1145 Tags: network, backup, ssh
1147 <a name="116"></a><hr />
1149 Useful tools for cloning / backups:
1151 * dd: convert and copy a file
1152 * dd_rescue: copies data from one file (or block device) to another
1153 * pcopy: a replacement for dd
1154 * partimage: back up and restore disk partitions
1155 * dirvish: Disk based virtual image network backup system
1156 * devclone: in-place filesystem conversion -- device cloning
1157 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
1158 * dump: ext2/3 filesystem backup
1159 * udpcast: multicast file transfer tool
1160 * cpio: copy files to and from archives
1161 * pax: read and write file archives and copy directory hierarchies
1162 * netcat / ssh / tar / gzip / bzip2: additional helper tools
1164 Tags: network, backup, ssh, udp, rescue, recovery
1166 <a name="117"></a><hr />
1168 Use grml as a rescue system:
1172 * dd: convert and copy a file
1173 * ddrescue: copies data from one file or block device to another
1174 * partimage: Linux/UNIX utility to save partitions in a compressed image file
1175 * cfdisk: Partition a hard drive
1176 * nparted: Newt and GNU Parted based disk partition table manipulator
1177 * parted-bf: The GNU Parted disk partition resizing program, small version
1178 * testdisk: Partition scanner and disk recovery tool
1179 * gpart: Guess PC disk partition table, find lost partitions
1183 * e2fsprogs: ext2 file system utilities and libraries
1184 * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
1185 * e2undel: Undelete utility for the ext2 file system
1186 * ext2resize: an ext2 filesystem resizer
1187 * recover: Undelete files on ext2 partitions
1191 * reiser4progs: administration utilities for the Reiser4 filesystem
1192 * reiserfsprogs: User-level tools for ReiserFS filesystems
1196 * xfsdump: Administrative utilities for the XFS filesystem
1197 * xfsprogs: Utilities for managing the XFS filesystem
1201 * jfsutils: utilities for managing the JFS filesystem
1205 * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
1206 * salvage-ntfs: free NTFS data recovery tools
1207 * scrounge-ntfs: data recovery program for NTFS file systems
1208 * ntfsresize: resize ntfs partitions
1210 Tags: ntfs, jfs, xfs, ext3, rescue, recovery, backup, filesystem, tools
1212 <a name="118"></a><hr />
1214 Get ASCII value of a character with zsh:
1216 % char=N ; print $((#char))
1218 <a name="119"></a><hr />
1220 Convert a collection of mp3 files to wave or cdr using zsh:
1222 % for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
1224 <a name="120"></a><hr />
1226 Convert images (foo.gif to foo.png) using zsh:
1228 % for i in **/*.gif; convert $i $i:r.png
1230 <a name="121"></a><hr />
1232 Remove all "non txt" files using zsh:
1236 <a name="122"></a><hr />
1238 Remote Shell Using SSH:
1241 % ssh -NR 3333:localhost:22 user@yourhost
1244 % ssh user@localhost -p 3333
1246 Tags: port forwarding, ssh, remote port, network
1248 <a name="123"></a><hr />
1250 Reverse Shell with Netcat:
1253 % netcat -v -l -p 3333 -e /bin/sh
1256 % netcat 192.168.0.1 3333
1258 TagS: port forwarding, ssh, remote, network
1260 <a name="124"></a><hr />
1262 Reverse Shell via SSH:
1264 local host (inside the network):
1265 % ssh -NR 1234:localhost:22 remote_host
1267 remote host (outside the network):
1268 % ssh localhost -p 1234
1270 Tags: port forwarding, ssh, remote port, network
1272 <a name="125"></a><hr />
1274 Remove empty directories with zsh:
1276 % rmdir ./**/*(/od) 2> /dev/null
1278 <a name="126"></a><hr />
1280 Find all the empty directories in a tree with zsh:
1284 <a name="127"></a><hr />
1286 Find all files without a valid owner and change ownership with zsh:
1288 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
1290 <a name="128"></a><hr />
1292 Display the 5-10 last modified files with zsh:
1294 % print -rl -- /path/to/dir/**/*(D.om[5,10])
1296 <a name="129"></a><hr />
1298 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
1300 % print -rl -- **/*(Dom[1,10])
1302 <a name="130"></a><hr />
1304 Find most recent file in a directory with zsh:
1306 % setopt dotglob ; print directory/**/*(om[1])
1308 <a name="131"></a><hr />
1310 Tunnel all traffic through an external server:
1312 % ssh -ND 3333 username@external.machine
1314 Then set the SOCKS4/5 proxy to localhost:3333.
1315 Check whether it's working by surfing e.g. to checkip.dyndns.org
1317 Tags: ssh, network, proxy, socks, tunnel
1319 <a name="132"></a><hr />
1321 Tunnel everything through SSH via tsocks:
1323 set up the SSH proxy on the client side:
1325 % ssh -ND 3333 user@remote.host.example.com
1327 Adjust /etc/tsocks.conf afterwards (delete all other lines):
1332 For programs who natively support proxying connections (e.g. Mozilla
1333 Firefox) you can now set the proxy address to localhost port 3333.
1335 All other programs which's connections you want to tunnel through your
1336 external host are prefixed with tsocks, e.g.:
1338 % tsocks netcat example.com 80
1339 % tsocks irssi -c irc.quakenet.eu.org -p 6667
1341 If you call tsocks without parameters it executes a shell witht the
1342 LD_PRELOAD environment variable already set and exported.
1344 Tags: ssh, network, proxy, socks, tunnel, tsocks
1346 <a name="133"></a><hr />
1348 smartctl - control and monitor utility for harddisks using Self-Monitoring,
1349 Analysis and Reporting Technology (SMART):
1351 # smartctl --all /dev/ice
1353 If you want to use smartctl on S-ATA (sata) disks use:
1355 # smartctl -d ata --all /dev/sda
1358 # smartctl -t offline /dev/ice
1361 # smartctl -t short /dev/ice
1363 Display results of test:
1364 # smartctl -l selftest /dev/ice
1366 Query device information:
1367 # smartctl -i /dev/ice
1369 Tags: smart, s.m.a.r.t, info, test, hardware
1371 <a name="134"></a><hr />
1373 Mount a BSD / Solaris partition:
1375 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
1377 Use ufstype 44bsd for FreeBSD, NetBSD, OpenBSD (read-write).
1378 Use ufstype ufs2 for >= FreeBSD 5.x (read-only).
1379 Use ufstype sun for SunOS (Solaris) (read-write).
1380 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
1382 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
1385 Tags: ufs, bsd, mount, solaris
1387 <a name="135"></a><hr />
1389 Read BIOS (and or BIOS) password:
1391 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
1393 <a name="136"></a><hr />
1395 Clone one of the kernel trees via git:
1397 git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
1398 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1399 This path defines the tree. See http://kernel.org/git/ for an overview.
1401 <a name="137"></a><hr />
1403 Mount filesystems over ssh protocol:
1405 % sshfs user@host:/remote_dir /mnt/test
1409 % fusermount -u /mnt/test
1411 (Notice: requires fuse kernel module)
1413 Tags: ssh, sshfs, network, mount, directory, remote, fuse
1415 <a name="138"></a><hr />
1417 Install Gentoo using grml:
1419 See http://www.gentoo.org/doc/en/altinstall.xml
1421 <a name="139"></a><hr />
1423 Install (plain) Debian (sarge release) via grml:
1425 Assuming you want to install Debian to sda1:
1427 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1428 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1429 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1430 chroot /mnt/test /bin/bash # let's chroot into the new system
1431 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
1432 mount -t proc none /proc # make sure we also have a mounted /proc
1433 base-config # now configure some main settings
1434 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
1435 cd /dev ; ./MAKEDEV generic # make sure we have all necessary devices for lilo
1436 apt-get install lilo linux-image-2.6.12-1-386 # install lilo and a kernel which fits your needs
1437 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
1438 vi /etc/lilo.conf && lilo # adjust the file for your needs and run lilo afterwards
1439 umount /proc ; umount /dev/pts # we do not need them any more
1440 exit # now leave chroot
1441 cp /etc/hosts /etc/fstab /mnt/test/etc/ # you might want to take the existing files...
1442 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
1443 umount /mnt/test && reboot # unmount partition and reboot...
1445 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1446 Avoid all of the above steps - use grml-debootstrap(8) instead!
1448 Tags: manual, installation, debian, debootstrap
1450 <a name="140"></a><hr />
1452 Install (plain) Debian (etch release) via grml
1454 Assuming you want to install Debian to sda1:
1456 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
1457 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
1458 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
1459 chroot /mnt/test /bin/bash # let's chroot into the new system
1460 mount -t proc none /proc # make sure we have a mounted /proc
1461 apt-get install locales console-data # install locales
1462 dpkg-reconfigure locales console-data # adjust locales to your needs
1463 apt-get install vim most zsh screen less initrd-tools file grub usbutils pciutils bzip2 sysfsutils dhcp3-client resolvconf strace lsof w3m # install useful software
1464 apt-get install linux-headers-2.6-686 linux-image-686 # install current kernel
1466 echo "127.0.0.1 localhost" > /etc/hosts # adjust /etc/hosts and network:
1467 cat >> /etc/network/interfaces << EOF
1468 iface lo inet loopback
1469 iface eth0 inet dhcp
1474 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1475 cat >> /etc/fstab << EOF
1476 sysfs /sys sysfs auto 0 0
1477 proc /proc proc defaults 0 0
1478 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1
1479 /dev/sda2 none swap sw 0 0
1480 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
1482 passwd # set password of user root
1484 mkdir /boot/grub # setup grub
1485 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1486 cat >> /boot/grub/menu.lst << EOF
1487 title Debian Etch, kernel 2.6.18-3-686 (on /dev/sda1)
1489 kernel /boot/vmlinuz-2.6.18-3-686 root=/dev/sda1 ro
1490 initrd /boot/initrd.img-2.6.18-3-686
1492 vim /boot/grub/menu.lst # adjust grub configuration to your needs
1493 cd /dev && MAKEDEV generic # create default devices
1494 cp -i /usr/lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1495 grub install # now install grub, run in grub-cmdline following commands:
1499 umount -a # unmount all filesystems in chroot and finally:
1500 exit # exit the chroot and:
1503 If you want to use lilo instead of grub take a look at
1504 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1506 cat > /etc/lilo.conf << EOF
1507 # This allows booting from any partition on disks with more than 1024 cylinders.
1510 # Specifies the boot device
1513 # Specifies the device that should be mounted as root.
1516 # use Debian on software raid:
1517 # raid-extra-boot=mbr-only
1525 image=/boot/vmlinuz-2.6.18-grml
1529 initrd=/boot/initrd.img-2.6.18-grml
1532 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1533 Avoid all of the above steps - use grml-debootstrap(8) instead!
1535 Tags: manual, installation, debian, debootstrap, howto
1537 <a name="141"></a><hr />
1539 Convert files from Unicode / UTF-8 to ISO:
1541 % iconv -c -f utf8 -t iso-8859-15 < utffile > isofile
1545 % iconv -f iso-8859-15 -t utf8 < isofile > utffile
1547 Tags: utf-8, iso, unicode, utf8
1549 <a name="142"></a><hr />
1551 Assign static setup for network cards (NICs) via udev:
1553 Retrieve information for address (corresponding to MAC address):
1555 # udevadm info -a -p /sys/class/net/eth0/ | grep -i 'ATTR{address}'
1557 Execute /lib/udev/write_net_rules with according values (INTERFACE
1558 is old NIC name, INTERFACE_NAME is new NIC name and MATCHADDR
1559 is the MAC address retrieved with udevadm info command):
1561 # INTERFACE=eth0 INTERFACE_NAME=lan0 MATCHADDR=00:00:00:00:00:01 /lib/udev/write_net_rules
1563 This will generate file /etc/udev/rules.d/70-persistent-net.rules with content:
1565 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:00:00:00:01", KERNEL=="eth*", NAME="lan0"
1567 Finally take down the interface (ifdown/ifconfig) and execute:
1569 # udevadm trigger --action=add --subsystem-match=net
1571 so the interface will be renamed. (Rebooting or
1572 unloading drivers/restart udev/loading drivers again
1573 works as well of course.)
1575 Tags: udev, configuration, name, eth0, howto
1577 <a name="143"></a><hr />
1579 Change the suffix from *.sh to *.pl using zsh:
1582 % zmv -W '*.sh' '*.pl'
1584 <a name="144"></a><hr />
1586 Generate SSL certificate:
1588 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1589 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1592 # openssl x509 -in certfile -text
1594 Verify against CA certificate:
1595 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1597 Generate 2048bit RSA-key:
1598 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1600 As before but add request to existing key pub-sec-key.pem:
1601 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1603 Show request request.pem:
1604 # openssl req -text -noout -in request.pem
1606 Verify signature of request request.pem:
1607 # openssl req -verify -noout -in request.pem
1609 Generate SHA1 fingerprint (modulo key) of request.pem:
1610 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1612 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1613 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1615 As before but create self signed certificate based on existing key pub-sec-key.pem:
1616 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1618 Generate new request out of existing self signed certificate:
1619 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1621 Display certificate self-signed-certificate.pem in plaintext:
1622 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1624 Check self signed certificate:
1625 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1627 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1628 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1630 Generate ssl-certificate for use with apache2:
1632 export RANDFILE=/dev/random
1633 mkdir /etc/apache2/ssl/
1634 openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem
1635 chmod 600 /etc/apache2/ssl/apache.pem
1637 Also take a look at make-ssl-cert (debconf wrapper for openssl):
1639 # /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/apache.pem
1641 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1643 Tags: openssl, howto
1645 <a name="145"></a><hr />
1647 Change Windows NT password(s):
1649 # mount -o rw /mnt/hda1
1650 # cd /mnt/hda1/WINDOWS/system32/config/
1651 # chntpw SAM SECURITY system
1653 Notice: if mounting the partition read-write did not work (check syslog!)
1654 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1656 (Be careful with deactivating syskey!)
1658 Tags: password, windows, recovery, chntpw, howto
1660 <a name="146"></a><hr />
1662 glark - replacement for grep written in Ruby:
1664 A replacement for (or supplement to) the grep family, glark offers:
1665 Perl compatible regular expressions, highlighting of matches,
1666 context around matches, complex expressions and automatic exclusion
1671 % glark -y keyword file # display only the region that matched, not the entire line
1672 % glark -o format print *.h # search for either "printf" or "format"
1674 More information: man glark
1676 <a name="147"></a><hr />
1678 Find CD burning device(s):
1680 General information on CD-ROM:
1681 % cat /proc/sys/dev/cdrom/info
1683 Scan using ATA Packet specific SCSI transport:
1684 # cdrecord -dev=ATA -scanbus
1685 # cdrecord-prodvd -s -scanbus dev=ATA
1687 Get specific information for /dev/ice:
1688 # cdrecord dev=/dev/ice -scanbus
1690 Tags: hardware, info, cd burn
1692 <a name="148"></a><hr />
1694 Create devices in /dev on udev:
1696 For example create md devices (/dev/md0, /dev/md1,...):
1697 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1701 <a name="149"></a><hr />
1703 Identify network device (NIC):
1705 # ethtool -i $DEVICE
1707 Show NIC statistics:
1709 # ethtool -S $DEVICE
1711 If your NIC shows some aging signs, you may want to be sure:
1713 # ethtool -t $DEVICE
1715 Disable TCP/UDP checksums:
1717 # ethtool -K $DEVICE tx off
1719 Tags: configuration, network, device
1721 <a name="150"></a><hr />
1723 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1725 Switch to tty12 and take a look at the syslog. If you see something like:
1727 SQUASHFS error: zlib_fs returned unexpected result 0x........
1728 SQUASHFS error: Unable to read cache block [.....]
1729 SQUASHFS error: Unable to read inode [.....]
1731 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1732 Check your CD low-level via running:
1734 # readcd -c2scan dev=/dev/cdrom
1736 If the medium really is ok and it still fails try to boot with deactivated DMA
1737 via using grml nodma at the bootprompt.
1739 Tags: grml2hd, installation, verify, squashfs, error
1741 <a name="151"></a><hr />
1743 Write a Microsoft compatible boot record (MBR) using ms-sys
1745 Write a Windows 2000/XP/2003 MBR to a device:
1747 # ms-sys -m /dev/ice
1749 Notice: grab ms-sys from http://ms-sys.sourceforge.net/ - demo:
1751 wget http://surfnet.dl.sourceforge.net/sourceforge/ms-sys/ms-sys-2.1.3.tgz
1752 unp ms-sys-2.1.3.tgz
1757 Tags: mbr, windows, ms-sys, recovery
1759 <a name="152"></a><hr />
1761 Use a Vodafone 3G Datacard (UMTS) with Linux:
1763 Plug in your vodafone card and check in syslog whether the appropriate
1764 (probably /dev/ttyUSB0 or /dev/noz0) has been created. If so run:
1767 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1770 # comgt -d /dev/ttyUSB0
1771 # wvdial --config /etc/wvdial.conf.umts a1usb
1773 # comgt -d /dev/noz0
1774 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1776 # comgt -d /dev/noz0
1777 # wvdial --config /etc/wvdial.conf.umts dreiusb
1779 # comgt -d /dev/ttyACM0
1780 # wvdial --config /etc/wvdial.conf.umts yesss
1782 If you receive invalid DNS nameservers when connecting, like:
1785 --> primary DNS address 10.11.12.13
1786 --> secondary DNS address 10.11.12.14
1788 just provide a working nameserver to resolvconf via:
1790 # echo "nameserver 80.120.17.70" | resolvconf -a ppp0
1792 Notice: some vodafone cards require the nozomi driver (run 'modprobe nozomi' on
1793 your grml system), some other ones require the sierra driver (run
1796 If your device isn't supported by usbserial yet, manually provide vendor and
1797 product ID when loading the usbserial module. Usage example:
1801 Bus 004 Device 008: ID 1199:6813 Sierra Wireless, Inc.
1803 # modprobe usbserial vendor=0x1199 product=0x6813
1805 To get a list of available providers execute:
1807 # comgt -s -d /dev/ttyUSB0 /etc/comgt/operator
1809 Tags: umts, 3g, vodafone, sierra, wvdial, ppp, howto
1811 <a name="153"></a><hr />
1813 hdparm - get/set hard disk parameters
1815 Display the identification info that was obtained from the drive at boot time,
1817 # hpdarm -i /dev/ice
1819 Request identification info directly from the drive:
1820 # hpdarm -I /dev/ice
1822 Perform timings of device + cache reads for benchmark and comparison purposes:
1823 # hdparm -tT /dev/ice
1825 Tags: hardware, performance, configuration, harddisk
1827 <a name="154"></a><hr />
1829 bonnie++ - program to test hard drive performance.
1831 # mkdir /mnt/benchmark
1832 # mount /dev/ice /mnt/benchmark
1833 # chmod go+w /mnt/benchmark
1834 # bonnie -u grml -d /mnt/benchmark -s 2000M
1836 Tags: benchmark, harddisk
1838 <a name="155"></a><hr />
1840 Use gizmo with a bluetooth headset:
1842 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1843 % gizmo --mic $DEVICE --speaker $DEVICE
1845 <a name="156"></a><hr />
1847 Scan a v4l device for TV stations:
1849 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1851 Then running xawtv should work:
1855 <a name="157"></a><hr />
1857 Run apt-get with timeout of 3 seconds:
1859 # apt-get -o acquire::http::timeout=3 update
1863 <a name="158"></a><hr />
1865 Debian GNU/Linux device driver check page
1867 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1869 <a name="159"></a><hr />
1871 Use dd with status line:
1873 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1875 <a name="160"></a><hr />
1877 Generate a 512k file of random data with status bar:
1879 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1881 <a name="161"></a><hr />
1883 Install Grub instead of lilo on grml installation (grml2hd):
1888 adjust grub's configuration file menu.lst:
1889 # $EDITOR /boot/grub/menu.lst
1891 now install grub (usage example for /dev/sda1):
1898 <a name="162"></a><hr />
1900 Install Ubuntu using grml:
1902 See https://wiki.ubuntu.com/Installation/FromKnoppix
1904 Tags: ubuntu, installation
1906 <a name="163"></a><hr />
1908 Resize ext2 / ext3 partition:
1910 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1911 # fsck.ext2 -v -y -f /dev/iceX # check the filesystem
1912 # resize2fs -p /dev/iceX $SIZE # resize it (adjust $SIZE)
1913 # fdisk /dev/ice # adjust partition in partition table
1914 # fsck.ext2 -v -y -f /dev/iceX # check filesystem again
1915 # resize2fs -p /dev/iceX # resize it to maximum
1916 # tune2fs -j /dev/iceX # re-enable journal
1918 Tags: resize, ext2, ext3, ext4, partition, howto
1920 <a name="164"></a><hr />
1922 Tune ext2 / ext3 filesystem:
1924 Check partition first:
1926 # tune2fs -l /dev/iceX
1928 If you don't see dir_index in the list, then enable it:
1930 # tune2fs -O dir_index /dev/iceX
1932 Now run e2fsck with the -D option to have the directories optimized:
1934 # e2fsck -D /dev/iceX
1936 Notice: since e2fsprogs (1.39-1) filesystems are created with
1937 directory indexing and on-line resizing enabled by default.
1939 Tags: configuration, ext2, ext3, ext4, partition
1941 <a name="165"></a><hr />
1943 Search for printers via network:
1945 # pconf_detect -m NETWORK -i 192.168.0.1/24
1947 Tags: printer, network, scan
1949 <a name="166"></a><hr />
1951 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1953 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1955 Tags: webdav, mount, mediacenter, gmx
1957 <a name="167"></a><hr />
1959 System-Profiling using oprofile:
1964 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1969 Now $DO_SOME_TASKS...
1972 # opcontrol --shutdown
1974 Then take a look at the reports using something like e.g.:
1975 # opreport -t 0.5 --exclude-dependent
1976 # opreport -t 0.5 /path/to/executable_to_check
1977 # opannotate -t 0.5 --source --assembly
1979 Tags: profile, profiling, opcontrol, howto
1981 <a name="168"></a><hr />
1983 Install ATI's fglrx driver for Xorg / X.org:
1985 Usually there already exist drivers for the grml-system:
1986 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1988 After installing adjust xorg.conf via running:
1989 # aticonfig --initial --input=/etc/X11/xorg.conf
1991 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1993 Tags: xorg, x11, driver, ati
1995 <a name="169"></a><hr />
1997 Install nvidia driver for Xorg / X.org:
1999 Usually there already exist drivers for the grml-system:
2000 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
2002 Then switch from module nv to nvidia:
2004 # sed -i 's/Driver.*nv.*/Driver "nvidia"/' /etc/X11/xorg.conf
2006 Tags: xorg, x11, driver, nvidia
2008 <a name="170"></a><hr />
2010 glxgears - a GLX demo that draws three rotating gears
2012 To print frames per second (fps) use:
2013 % glxgears -printfps
2015 Tags: xorg, x11, glx,
2017 <a name="171"></a><hr />
2019 You forgot to boot with 'grml noeject noprompt' to avoid
2020 ejecting and prompting for CD removal when rebooting/halting
2031 If you want to avoid only the prompting part, run:
2039 Tags: bootparam, fix, grml
2041 <a name="172"></a><hr />
2043 Mount wikipedia local via fuse:
2045 Adjust configuration:
2046 % cat ~/.wikipediafs/config.xml
2049 <article-cache-time>300</article-cache-time>
2053 <dirname>wikipedia-de</dirname>
2054 <host>de.wikipedia.org</host>
2055 <basename>/w/index.php</basename>
2058 <dirname>wikipedia-en</dirname>
2059 <host>en.wikipedia.org</host>
2060 <basename>/w/index.php</basename>
2065 Mount it (/wiki must exist of course):
2066 % mount.wikipediafs /wiki
2067 % cat /wiki/wikipedia-en/Cat
2070 % fusermount -u /wiki
2072 Tags: fuse, wikipedia, mount
2074 <a name="173"></a><hr />
2076 Remote notification on X via osd (on screen display):
2078 Start osd_server.py at your local host (listens on port 1234 by default):
2081 Then login to a $REMOTEHOST
2082 % ssh -R 1234:localhost:1234 $REMOTEHOST
2084 Now send the text to your local display via running something like:
2085 % echo "text to send" | nc localhost 1234
2087 Very useful when you are waiting for a long running job
2088 but want to do something else in the meanwhile:
2090 % ./configure && make && echo "finished compiling" | netcat localhost 1234
2092 You can use this in external programs as well of course. Examples:
2094 Use osd in centericq:
2096 % cat ~/.centericq/external
2105 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
2106 CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
2107 osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
2108 if echo | socat - TCP4:localhost:1234 &>/dev/null ; then
2109 echo "${osd_msg}" | netcat localhost 1234
2113 Use it in the IRC console client irssi via running:
2117 You can even activate the port forwarding by default globally:
2122 RemoteForward 1234 127.0.0.1:1234
2125 Notice: if you get 'ABORT: Requested font not found' make sure the
2126 requested font is available, running 'LANG=C LC_ALL=C osd_server.py...'
2129 Tags: osd, notification, ssh, network, port-forwarding
2131 <a name="174"></a><hr />
2133 Avoid automatical startup of init scripts via invoke-rc.d:
2135 First of all make sure the package policyrcd-script-zg2 (which
2136 provides the /usr/sbin/policy-rc.d interface) is installed.
2138 In policyrcd-script-zg2's configuration file named
2139 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
2140 defined as the interface for handling invoke-rc.d's startup policy.
2142 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf. By
2143 default you won't notice any differences to Debian's default
2144 behaviour, except that invoke-rc.d won't be executed if a chroot has
2145 been detected (detection: /proc is missing).
2147 If you want to disable automatical startup of newly installed packages
2148 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
2149 /etc/policy-rc.d.conf.
2151 To restore the default behaviour set EXITSTATUS back to '0' in
2152 /etc/policy-rc.d.conf.
2154 Tags: policy, init, script, invode-rc.d
2156 <a name="175"></a><hr />
2158 Install VMware-Tools for grml:
2160 First of all make sure a CD-ROM device in VMware is available.
2162 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
2166 unp /mnt/cdrom/vmware-linux-tools.tar.gz
2167 cd vmware-tools-distrib
2170 /etc/init.d/networking stop
2175 /etc/init.d/networking start
2177 In an X terminal, launch the VMware Tools running:
2181 Tags: vmware, tool, vmware-toolbox, howto
2183 <a name="176"></a><hr />
2185 Some important Postfix stuff
2193 Send all messages in the queue:
2197 Send all messages in the queue for a specific site:
2201 Delete a specific message
2202 # postsuper -d 12345678942
2204 Deletes all messages held in the queue for later delivery
2205 # postsuper -d ALL deferred
2207 Mail queues in postfix:
2209 incoming -> mail who just entered the system
2210 active -> mail to be delivered
2211 deferred -> mail to be delivered later because there were problems
2212 hold -> mail that should not be delivered until released from hold
2214 For configuration of postfix take a look at
2215 /etc/postfix/master.cf - man 5 master
2216 /etc/postfix/main.cf - man 5 postconf
2217 and http://www.postfix.org/documentation.html.
2219 <a name="177"></a><hr />
2223 mode 4000 - set user ID (suid):
2225 - for executable files: run as the user who owns the file, instead of the
2226 user who runs the file
2227 - for directories: not used
2229 mode 2000 - set group ID (guid):
2231 - for executable files: run as the group who owns the file, instead of the
2232 group of the user who runs the file
2233 - for directories: when a file is created inside the directory, it belongs
2234 to the group of the directory instead of the default group of the user who
2237 mode 1000 - sticky bit:
2239 - for files: not used
2240 - for directories: only the owner of a file can delete or rename the file
2242 Tags: postix, mailq, postsuper, queue, delete, smtp
2244 <a name="178"></a><hr />
2246 Create MySQL database
2248 # apt-get install mysql-client mysql-server
2250 Run 'mysql' as root - create a database with:
2252 create database grml
2254 Give a user access to the database (without password):
2256 grant all on grml.* to mika;
2258 Give a user access to the database (with password):
2260 grant all on grml.* to enrico identified by "PASSWORD";
2262 Tags: mysql, database
2264 <a name="179"></a><hr />
2266 Setup an HTTPS website:
2268 Create a certificate:
2270 # mkdir /etc/apache2/ssl
2271 # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
2273 Create a virtual host on port 443:
2275 <VirtualHost www.foo.invalid:443>
2277 </VirtualHost>
2279 Enable SSL in the VirtualHost:
2282 SSLCertificateFile /etc/apache2/ssl/apache.pem
2284 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
2288 and make sure the SSL module is used:
2292 Tags: ssl, https, configuration, apache
2294 <a name="180"></a><hr />
2296 Useful Apache / Apache2 stuff
2298 Check configuration file via running:
2300 # apache2ctl configtest
2308 # a2enmod modulename
2310 Tags: apache, configuration
2312 <a name="181"></a><hr />
2314 Create tar archive and store it on remote machine:
2316 % tar zcf - /sourcedir | ssh user@targethost "cat >file.tgz"
2318 Tags: tar, backup, remote, network, ssh
2320 <a name="182"></a><hr />
2322 Pick out and displays images from network traffic:
2326 Tags: remote, network, sniff, image
2328 <a name="183"></a><hr />
2330 Install Flash plugin:
2332 # dpkg-reconfigure flashplugin-nonfree
2336 <a name="184"></a><hr />
2338 To test a proxy, low level way:
2342 GET http://www.google.com HTTP/1.0 [press enter twice]
2346 <a name="185"></a><hr />
2348 Adjust system for use of qemu with kqemu:
2350 Make sure you have all you need:
2351 # aptitude update ; aptitude install qemu kqemu-modules-$(uname -r)
2356 mknod /dev/kqemu c 250 0
2357 chmod 666 /dev/kqemu
2358 chmod 666 /dev/net/tun
2360 Check kqemu support via starting qemu, press
2361 Ctrl-Alt-2 and entering 'info kqemu'.
2363 <a name="186"></a><hr />
2365 (High-Load) Debugging related tools:
2367 mpstat # report processors related statistics
2368 iostat # report CPU statistics and input/output statistics for devices and partitions
2369 vmstat # report virtual memory statistics
2370 slabtop # display kernel slab cache information in real time
2371 atsar # system activity report
2372 dstat # versatile tool for generating system resource statistics
2383 Tags: test, debug, information, hardware, statistic
2385 <a name="187"></a><hr />
2387 Using WPA for network setup manually:
2389 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
2391 Adjust the options and configuration file to your needs.
2392 Also take a look at 'grml-network'.
2394 Tags: wireless, wpa, network, configuration
2396 <a name="188"></a><hr />
2398 Start X and lock console via exiting:
2400 % startx 2>~/.xsession-errors &| exit
2402 Tags: xorg, x11, startx, graphical
2404 <a name="189"></a><hr />
2406 Which process is writing to disk and/or causes the disk to spin up?
2408 First of all use lsof to check what's going on. Does not help? ->
2410 # echo 1 > /proc/sys/vm/block_dump
2412 The command sets a sysctl to cause the kernel to log all disk
2413 writes. Please notice that there is a lot of data. So please
2414 disable syslogd/syslog-ng before you do this, or you must make
2415 sure that kernel output is not logged.
2417 When you're done, disable block dump using:
2418 # echo 0 > /proc/sys/vm/block_dump
2421 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
2422 which handles block_dump on its own.
2424 See: $KERNEL-SOURCE/Documentation/laptop-mode.txt
2426 Also take a look at event-viewer(8) which is part of grml-debugtools.
2428 Tags: debug, device, block, partition
2430 <a name="190"></a><hr />
2432 Install initrd via initramfs-tools for currently running kernel:
2434 # update-initramfs -c -t -k $(uname -r)
2438 <a name="191"></a><hr />
2440 Install initrd via yaird for currently running kernel:
2442 # yaird -o /boot/initrd.img-$(uname -r)
2444 Install initrd via yaird for specific kernel:
2448 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
2450 <a name="192"></a><hr />
2452 Reinstall package with its original configuration files:
2454 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o DPkg::Options::=--force-confnew package
2456 <a name="193"></a><hr />
2458 grml 0.8 funkenzutzler - rt2x00 drivers:
2460 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
2461 includes beta-version drivers) is not installed by default. If you want to
2462 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
2463 rt73usb please install the package manually running:
2465 # dpkg -i /usr/src/rt2x00-modules-*.deb
2467 <a name="194"></a><hr />
2469 Use Java with jikes and jamvm on grml:
2473 % cp /usr/share/doc/grml-templates/template.java .
2474 % jikes template.java
2477 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
2478 so you do not have to manually run
2479 jikes --bootclasspath /usr/share/classpath/glibj.zip
2481 <a name="195"></a><hr />
2483 Online resizing of (Software-)RAID5:
2485 # Initiate a RAID5 setup for testing purposes:
2486 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
2488 # Create filesystem, mount md0, create a testfile and save md5sum for
2491 mount /dev/md0 /mnt/test
2492 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
2493 md5sum /mnt/test/dd > md5sum
2495 # Make sure the RAID is synched via checking:
2498 # Now remove one partition:
2499 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
2501 # Delete partition, create a new + bigger one and set partition type to fd
2502 # (Linux raid autodetect):
2505 # And re-add the partition:
2506 mdadm -a /dev/md0 /dev/hdd1
2508 # Make sure the RAID is synched via checking:
2511 # Repeat the steps for all other disks/partitions as well:
2512 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2514 mdadm -a /dev/md0 /dev/hdb1
2516 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2518 mdadm -a /dev/md0 /dev/hda1
2521 # Now resize the RAID5 system online [see 'man mdadm' for details]:
2522 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
2523 mdadm --grow /dev/md0 -z max
2524 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
2526 # Last step - resize the filesystem (online again):
2529 Tags: raid, resize, raid5, mdadm
2531 <a name="196"></a><hr />
2533 ext3 online resizing:
2535 Starting with Linux kernel 2.6.10 you can resize ext3 online. With
2536 e2fsprogs >=1.39-1 new filesystems are created with directory indexing and
2537 on-line resizing enabled by default (see /etc/mke2fs.conf).
2541 cfdisk /dev/hda # create a partition with type 8e (lvm)
2542 pvcreate /dev/hda2 # create a physical volume
2543 vgcreate resize_me /dev/hda2 # create volume group
2544 lvcreate -n resize_me -L100 resize_me # create a logical volume
2545 mkfs.ext3 /dev/resize_me/resize_me # now create a new filesystem
2546 mount /dev/resize_me/resize_me /mnt/test # mount the new fs for demonstrating online resizing
2547 df -h # check the size of the partition
2548 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
2549 resize2fs /dev/resize_me/resize_me # and finally resize the filesystem
2550 df -h # recheck the size of the partition
2552 This also works for Software-RAID. Demo:
2554 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
2556 mount /dev/md0 /mnt/test
2557 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
2558 cfdisk /dev/hda # adjust partition size for hda2
2559 mdadm /dev/md0 --add /dev/hda2
2560 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
2561 cfdisk /dev/hdb # adjust partition size for hdb1
2562 mdadm /dev/md0 --add /dev/hdb1
2563 mdadm --grow /dev/md0 --size=max
2566 Notice: online resizing works as soon as the kernel can re-read the
2567 partition table. So it works for example with LVM and SW-RAID but not with
2568 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
2569 table if the device is already mounted.
2571 Tags: resize, raid, lvm, ext2, ext3, ext4, raid1
2573 <a name="197"></a><hr />
2575 Use vim as an outline editor:
2577 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
2581 <a name="198"></a><hr />
2583 Monitor directories/files for changes using iwatch
2585 Monitor /tmp for changes:
2588 Monitor files/directories specified in /etc/iwatch.xml
2589 and send mail on changes:
2592 Tags: inotify, watch, file, directory
2594 <a name="199"></a><hr />
2596 Some often used mdadm commands:
2599 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
2601 Display details of specific RAID:
2602 # mdadm --detail /dev/md0
2605 Simulating a drive failure by software:
2606 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
2608 Remove disk from RAID:
2609 # mdadm /dev/md0 -r /dev/hda1
2611 Set disk as faulty and remove from RAID:
2612 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
2617 Restart a RAID-device:
2620 Add another disk to existing RAID setup (hotadd):
2621 # mdadm /dev/md0 -a /dev/hde1
2622 # mdadm --grow /dev/md0 --raid-devices=4
2624 Assemble and start all arrays:
2625 # mdadm --assemble --scan
2627 Assemble a specific array:
2628 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
2631 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
2634 # mdadm --stop --scan
2636 Scan for and setup arrays automatically:
2637 # mdadm --assemble --scan --auto=yes --verbose
2639 Notice: If the above does not work make sure /etc/mdadm/mdadm.conf contains:
2641 CREATE owner=root group=disk mode=0660 auto=yes
2642 HOMEHOST <system>
2646 # /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
2649 Monitoring the sw raid
2650 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
2652 Producing /etc/mdadm/mdadm.conf:
2653 # mdadm --detail --scan > /etc/mdadm/mdadm.conf
2655 See also: man mdadm | less -p "^EXAMPLES"
2656 http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
2658 Tags: raid, raid1, raid5, configuration, mdadm, howto
2660 <a name="200"></a><hr />
2662 A quick summary of the most commonly used RAID levels:
2665 => 2 disks each 160 GB: 320 GB data
2666 RAID 1: Mirrored Set
2667 => 2 disks each 160 GB: 160 GB data
2668 RAID 5: Striped Set with Parity
2669 => 3 disks each 160 GB: 320 GB data; 160 GB redundancy
2671 Common nested RAID levels:
2672 RAID 01: A mirror of stripes
2673 RAID 10: A stripe of mirrors
2674 RAID 30: A stripe across dedicated parity RAID systems
2675 RAID 100: A stripe of a stripe of mirrors
2677 -- http://en.wikipedia.org/wiki/RAID
2679 Tags: raid, raid1, raid5, raid01, raid10, raid100
2681 <a name="201"></a><hr />
2683 Logical Volume Management (LVM) with Linux
2688 | hda1 hdc1 (PV:s on partitions or whole disks)
2692 | / | | / | | usrlv rootlv varlv (LV:s)
2694 | ext3 ext3 xfs (filesystems)
2696 Often used commands:
2697 ~~~~~~~~~~~~~~~~~~~~
2699 Create a physical volume:
2700 # pvcreate /dev/hda2
2702 Create a volume group:
2703 # vgcreate testvg /dev/hda2
2705 Create a logical volume:
2706 # lvcreate -n test_lv -L100 testvg
2708 Resize a logical volume:
2709 # lvextend -L+100M /dev/resize_me/resize_me
2710 # resize2fs /dev/resize_me/resize_me # ext2/3
2711 # xfs_growfs /dev/resize_me/resize_me # xfs
2712 # resize_reiserfs -f /dev/resize_me/resize_me # reiserfs online
2713 # mount -o remount,resize /dev/resize_me/resize_me # jfs
2715 Create a snapshot of a logical volume:
2716 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
2718 Deactivate a volume group:
2719 # vgchange -a n my_volume_group
2721 Actually remove a volume group:
2722 # vgremove my_volume_group
2724 Display information about physical volume:
2725 # pvdisplay /dev/hda1
2727 Remove physical volume:
2728 # vgreduce my_volume_group /dev/hda1
2730 Remove logical volume:
2731 # umount /dev/myvg/homevol
2732 # lvremove /dev/myvg/homevol
2735 http://www.tldp.org/HOWTO/LVM-HOWTO/
2737 Tags: lvm, howto, pvcreate, lvcreate
2739 <a name="202"></a><hr />
2741 How to use APT locally
2743 Sometimes you have lots of packages .deb that you would like to use APT to
2744 install so that the dependencies would be automatically solved. Solution:
2747 dpkg-scanpackages debs /dev/null | gzip > debs/Packages.gz
2748 echo " deb file:/root debs/" >> /etc/apt/sources.list
2749 dpkg-scansources debs | gzip > debs/Sources.gz
2750 echo " deb-src file:/root debs/" >> /etc/apt/sources.list
2752 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2756 <a name="203"></a><hr />
2758 Check filesystem's LABEL:
2763 ext2/3 without blkid:
2764 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2767 # xfs_admin -l /dev/sda1
2769 reiserfs without blkid:
2770 # debugreiserfs /dev/sda1 | grep -i label
2773 # jfs_tune -l /dev/sda1 | grep -i label
2775 reiser4 without blkid:
2776 # debugfs.reiser4 /dev/sda1 | grep -i label
2778 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, label
2780 <a name="204"></a><hr />
2782 Check filesystem's UUID:
2787 ext2/3 without blkid:
2788 # dumpe2fs /dev/sda1 | grep -i UUID
2791 # xfs_admin -u /dev/sda1
2793 reiserfs without blkid:
2794 # debugreiserfs /dev/sda1 | grep -i UUID
2796 reiser4 without blkid:
2797 # debugfs.reiser4 /dev/sda1 | grep -i UUID
2799 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs, uuid
2801 <a name="205"></a><hr />
2803 Change a filesystem's LABEL:
2806 # mkswap -L $LABEL /dev/sda1
2809 # e2label /dev/sda1 $LABEL
2810 # tune2fs -L $LABEL /dev/sda1
2813 # reiserfstune -l $LABEL /dev/sda1
2816 # jfs_tune -L $LABEL /dev/sda1
2819 # xfs_admin -L $LABEL /dev/sda1
2822 # echo 'drive i: file="/dev/sda1"' >> ~/.mtoolsrc
2823 # mlabel -s i:$LABEL
2826 # ntfslabel $LABEL /dev/sda1
2828 Tags: filesystem, ext2, ext3, ext4, blkid, jfs, xfs
2830 <a name="206"></a><hr />
2832 Disable pdiffs feature of APT:
2835 # echo 'Acquire::PDiffs "false";' >> /etc/apt/apt.conf
2838 # apt-get update -o Acquire::Pdiffs=false
2840 <a name="207"></a><hr />
2842 Backup big devices or files and create compressed splitted
2843 image chunks of it using zsplit
2845 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2846 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2847 read/write buffer to 256kB:
2848 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2850 Restore the backup using unzsplit:
2851 # unzsplit -D /dev/sda -d archiveofsda
2853 More usage examples: man zsplit + man unzsplit
2855 Tags: backup, reocvery, spllt, limit, howto
2857 <a name="208"></a><hr />
2859 Measure network performance using iperf:
2865 % iperf -c <server_address> -V
2869 Server with 128k TCP window size:
2872 Client with running for 60 seconds and bidirectional test:
2873 % iperf -c <server_address> -r -w128k -t60
2875 Tags: network, benchmark
2877 <a name="209"></a><hr />
2879 Framebuffer resolutions:
2881 Resolution in pixels
2882 Color depth | 640x480 800x600 1024x768 1280x1024
2883 256 (8bit)| 769 771 773 775
2884 32000 (15bit)| 784 787 790 793
2885 65000 (16bit)| 785 788 791 794
2886 16.7 Mill.(24bit)| 786 789 792 795
2890 Mode 0x0300: 640x400 (+640), 8 bits
2891 Mode 0x0301: 640x480 (+640), 8 bits
2892 Mode 0x0303: 800x600 (+800), 8 bits
2893 Mode 0x0303: 800x600 (+832), 8 bits
2894 Mode 0x0305: 1024x768 (+1024), 8 bits
2895 Mode 0x0307: 1280x1024 (+1280), 8 bits
2896 Mode 0x030e: 320x200 (+640), 16 bits
2897 Mode 0x030f: 320x200 (+1280), 24 bits
2898 Mode 0x0311: 640x480 (+1280), 16 bits
2899 Mode 0x0312: 640x480 (+2560), 24 bits
2900 Mode 0x0314: 800x600 (+1600), 16 bits
2901 Mode 0x0315: 800x600 (+3200), 24 bits
2902 Mode 0x0317: 1024x768 (+2048), 16 bits
2903 Mode 0x0318: 1024x768 (+4096), 24 bits
2904 Mode 0x031a: 1280x1024 (+2560), 16 bits
2905 Mode 0x031b: 1280x1024 (+5120), 24 bits
2906 Mode 0x0330: 320x200 (+320), 8 bits
2907 Mode 0x0331: 320x400 (+320), 8 bits
2908 Mode 0x0332: 320x400 (+640), 16 bits
2909 Mode 0x0333: 320x400 (+1280), 24 bits
2910 Mode 0x0334: 320x240 (+320), 8 bits
2911 Mode 0x0335: 320x240 (+640), 16 bits
2912 Mode 0x0336: 320x240 (+1280), 24 bits
2913 Mode 0x033c: 1400x1050 (+1408), 8 bits
2914 Mode 0x033d: 640x400 (+1280), 16 bits
2915 Mode 0x033e: 640x400 (+2560), 24 bits
2916 Mode 0x0345: 1600x1200 (+1600), 8 bits
2917 Mode 0x0346: 1600x1200 (+3200), 16 bits
2918 Mode 0x034d: 1400x1050 (+2816), 16 bits
2919 Mode 0x035c: 1400x1050 (+5632), 24 bits
2921 Tags: framebuffer, resolution
2923 <a name="210"></a><hr />
2925 Portscan using netcat:
2927 # netcat -v -w2 <host|ip-addr.> 1-1024
2929 <a name="211"></a><hr />
2931 Run apt-get but disable apt-listchanges:
2933 APT_LISTCHANGES_FRONTEND=none apt-get ...
2935 Upgrade system but disable apt-listbugs:
2937 APT_LISTBUGS_FRONTEND=none apt-get ...
2939 <a name="212"></a><hr />
2941 Set up a Transparent Debian Proxy
2943 Install of apt-cacher, the default config will do:
2944 # apt-get install apt-cacher
2946 Check out the ip address of debian mirror(s).
2947 Then add this to your firewall script:
2949 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2950 for ip in ${DEBIAN_MIRRORS} ; do
2951 ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2954 where ${IPTABLES} is the location of your iptables binary
2955 and $subnet is your internal subnet.
2957 Now everybody in your subnet who does access either
2958 ftp.de.debian.org or ftp.at.debian.org will actually
2959 access your apt-cacher instead.
2961 To use apt-cacher on the router itself, add the following
2962 line to your /etc/apt/apt.conf:
2964 Acquire::http::Proxy "http://localhost:3142/";
2966 Tags: proxy, debian, apt-get, howto
2968 <a name="213"></a><hr />
2970 Version control using Mercurial
2972 Setting up a Mercurial project:
2975 % hg init # creates .hg
2976 % hg add # add all files
2977 % hg commit # commit all changes, edit changelog entry
2979 Branching and merging:
2981 % hg clone linux linux-work # create a new branch
2983 <make changes>
2986 % hg pull ../linux-work # pull changesets from linux-work
2987 % hg merge # merge the new tip from linux-work into
2988 # (old versions used "hg update -m" instead)
2989 # our working directory
2990 % hg commit # commit the result of the merge
2994 % cat ../p/patchlist | xargs hg import -p1 -b ../p
3002 % hg export 1234 > foo.patch # export changeset 1234
3004 Export your current repo via HTTP with browsable interface:
3006 % hg serve -n "My repo" -p 80
3008 Pushing changes to a remote repo with SSH:
3010 % hg push ssh://user@example.com/~/hg/
3012 Merge changes from a remote machine:
3014 host1% hg pull http://foo/
3015 host2% hg merge # merge changes into your working directory
3017 Set up a CGI server on your webserver:
3018 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
3019 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
3021 <a name="214"></a><hr />
3023 Download binary codecs for mplayer:
3025 # /usr/share/mplayer/scripts/win32codecs.sh
3029 # /usr/share/mplayer/scripts/binary_codecs.sh install
3031 (depending on the mplayer version you have).
3033 To play encrypted DVDs and if you are living in a country where using
3034 libdvdcss code is not illegal can install Debian package libdvdread3
3035 and use the script /usr/share/doc/libdvdread3/install-css.sh.
3037 <a name="215"></a><hr />
3039 Read manpages of uninstalled packages with debman:
3041 % debman -p git-core git
3043 <a name="216"></a><hr />
3045 Test network performance using netperf:
3051 # netperf -t TCP_STREAM -H 192.168.0.41
3053 Tags: benchmark, network
3055 <a name="217"></a><hr />
3057 Setup Xen within 20 minutes on Debian/grml
3059 Install relevant software und update grub's menu.lst (Xen does not work with
3060 usual lilo so install grub instead if not done already):
3062 apt-get install linux-image-2.6.18-1-xen-686 xen-hypervisor-3.0.3-1-i386 xen-utils-3.0.3-1 xen-tools bridge-utils
3065 Example for installation of Debian etch as DomU:
3068 xen-create-image --debootstrap --dir=/mnt/md1/xen --size=2Gb --memory=512Mb --fs=ext3 --cache=yes --dist=etch --hostname=xengrml1 --ip 192.168.1.2 --netmask 255.255.255.0 --gateway 192.168.1.1 --initrd=/boot/initrd.img-2.6.18-1-xen-686 --kernel=/boot/vmlinuz-2.6.18-1-xen-686 --mirror=http://ftp.at.debian.org/debian/
3072 /etc/init.d/xend start
3073 /etc/init.d/xendomains start
3075 Setup a bridge for network, either manually:
3077 brctl addbr xenintbr
3078 brctl stp xenintbr off
3079 brctl sethello xenintbr 0
3080 brctl setfd xenintbr 0
3081 ifconfig xenintbr 192.168.1.1 netmask 255.255.255.0 up
3083 or via /etc/network/interfaces (run ifup xenintbr to bring up the device then
3087 iface xenintbr inet static
3088 pre-up brctl addbr xenintbr
3089 post-down brctl delbr xenintbr
3091 netmask 255.255.255.0
3096 Setup forwarding (adjust $PUBLIC_IP; for permanet setup use /etc/sysctl.conf and
3097 add the iptables commands to a startup script like /etc/init.d/rc.local):
3099 echo 1 > /proc/sys/net/ipv4/ip_forward
3100 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j SNAT --to $PUBLIC_IP
3101 iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $PUBLIC_IP
3103 Adjust network configuration of Xend:
3105 cat >> /etc/xen/xend-config.sxp << EOF
3106 (network-script network-route)
3107 (vif-bridge xenintbr)
3108 (vif-script vif-bridge)
3111 List domains, start up a DomU, shutdown later again:
3113 xm create -c /etc/xen/xengrml1.cfg
3117 This HowTo is also available online at http://grml.org/xen/
3119 Tags: howto, xen, grml
3121 <a name="218"></a><hr />
3123 Play tetris with zsh:
3127 bindkey "^Xt" tetris
3129 Now press 'ctrl-x t'.
3131 <a name="219"></a><hr />
3133 Set up a router with grml
3135 Run grml-router script:
3138 Install dnsmasq if not already present:
3139 # apt-get update ; apt-get install dnsmasq
3141 Adjust /etc/dnsmasq.conf according to your needs:
3142 # cat >> /etc/dnsmasq.conf << EOF
3145 dhcp-range=19.168.0.124,192.168.0.254,1m # dhcp range
3146 dhcp-option=3,192.168.0.1 # dns server
3147 dhcp-option=1,255.255.255.0 # netmask
3150 Start dnsmasq finally:
3153 Tags: network, router, grml
3155 <a name="220"></a><hr />
3157 Display stats about memory allocations performed by a program:
3159 Usage example for 'ls':
3161 % LD_PRELOAD=/lib/libmemusage.so ls > /dev/null
3163 <a name="221"></a><hr />
3165 Use KVM (Kernel-based Virtual Machine for Linux):
3167 Make sure to install the relevant tools:
3168 # apt-get update ; apt-get install kvm
3171 Test it with a minimal system like ttylinux:
3172 # wget http://www.minimalinux.org/ttylinux/packages/bootcd-i386-5.3.iso.gz
3173 # gzip -d bootcd-i386-5.3.iso.gz
3174 # kvm -cdrom bootcd-i386-5.3.iso
3176 <a name="222"></a><hr />
3178 EEPROM data decoding for SDRAM DIMM modules:
3181 # /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl
3183 <a name="223"></a><hr />
3187 Make sure your device is supported by Linux and running.
3188 See http://www.linuxtv.org/ for more details.
3190 If the DVB device works on your system (see 'hwinfo --usb'
3191 when using a DVB usb device for example), then make sure you
3192 have the scan util from dvb-utils available:
3194 # aptitude install dvb-utils
3196 Then create a channels.conf configuration file:
3198 % scan /usr/share/doc/dvb-utils/examples/scan/... > ~/.mplayer/channels.conf
3200 You can find some example configuration files on
3201 your grml system in ~/.channels. Usage example:
3203 % ln -s ~/.mplayer/channels.conf-AT-graz ~/.mplayer/channels.conf
3205 Tip: w_scan (see http://free.pages.at/wirbel4vdr/w_scan/index2.html)
3206 might be useful if you do not know the initial configuration
3209 <a name="224"></a><hr />
3211 Get the lastest mercurial snapshot:
3213 Make sure you have the python-dev package available:
3214 # apt-get update ; apt-get install python-dev
3216 Get and build the source:
3217 % hg clone http://selenic.com/repo/hg mercurial
3220 % export PYTHONPATH=$(pwd)
3221 % export PATH=$PATH:$(pwd)
3223 now you should have the newest version of mercurial whenever you execute hg.
3225 To update to the lastest development snapshot, additionally use
3226 the following commands:
3227 % hg pull -u http://hg.intevation.org/mercurial/crew
3230 <a name="225"></a><hr />
3235 Available bootoptions relevant in live-cd mode:
3236 -----------------------------------------------
3238 * utc: set UTC, if your system clock is set to UTC (GMT)
3239 * gmt: set UTC, if your system clock is set to UTC (GMT) [like bootoption utc]
3240 * tz=$option: set timezone to corresponding $option, usage example:
3243 Configuration options relevant on harddisk installation:
3244 --------------------------------------------------------
3246 * Use the tzconfig utility to set the local timezone:
3250 which adjusts /etc/timezone and /etc/localtime according
3251 to the provided information. Running:
3253 # dpkg-reconfigure tzdata
3255 might be useful as well.
3257 * /etc/default/rcS: set variable UTC according to your needs,
3258 whether your system clock is set to UTC (UTC='yes') or
3261 * /etc/localtime: adjust zoneinfo according to your needs:
3263 # ln -sf /usr/share/zoneinfo/$WHATEVER_YOU_WANT /etc/localtime
3265 The zoneinfo directory contains the time zone files that were
3266 compiled by zic. The files contain information such as rules
3267 about DST. They allow the kernel to convert UTC UNIX time into
3268 appropriate local dates and times. Use the zdump utility to
3269 print current time and date (in the specified time zone).
3271 * /etc/adjtime: This file is used e.g. by the adjtimex function,
3272 which can smoothly adjust system time while the system runs
3274 * If you change the time (using 'date --set ...', ntpdate,...)
3275 it is worth setting also the hardware clock to the correct time:
3277 # hwclock --systohc [--utc]
3279 Remember to add the --utc -option if the hardware clock is set
3285 Check your current settings via:
3288 zdump /etc/localtime
3291 grep hwclock /etc/runlevel.conf
3292 grep '^UTC' /etc/default/rc
3294 Further information:
3295 --------------------
3297 hwclock(8) tzselect(1) tzconfig(8)
3298 http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html
3299 http://wiki.debian.org/TimeZoneChanges
3301 Tags: timezone, rtc, configuration
3303 <a name="226"></a><hr />
3305 Recorder shellscript session using script:
3307 % script -t 2>~/upgrade.time -a ~/upgrade.script
3308 % scriptreplay ~/upgrade.time ~/upgrade.script
3310 <a name="227"></a><hr />
3312 Test UTF-8 capabilities of terminal:
3314 wget http://www.linux-cjk.net/Console/garabik/UTF-8-demo.txt.gz
3315 zcat UTF-8-demo.txt.gz
3319 wget http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
3322 <a name="228"></a><hr />
3324 UTF-8 at grml / some general information regarding Unicde/UTF-8:
3326 http://wiki.grml.org/doku.php?id=utf8
3328 <a name="229"></a><hr />
3331 This allows one ssh connection attepmt per minute per source ip, with a initial
3332 burst of 10. The available burst is like a counter which is initialised with
3333 10. Every connection attempt decrements the counter, and every minute where the
3334 connection limit of one per minute is not overstepped the counter is
3335 incremented by one. If the burst counter is exhausted the real rate limit
3336 comes into play. This gives you 11 connectionattepmts in the first minute
3337 before blocked for 10minutes. After 10 minutes block the game restarts.
3339 Hint: you could set the burst value to 5 and the block time to only 5 minutes
3340 to achive the same average connection rate but with halve the block time.
3342 iptables -A inet_in -p tcp --syn --dport 22 -m hashlimit --hashlimit-name ssh --hashlimit 1/minute --hashlimit-burst 10 --hashlimit-mode srcip --hashlimit-htable-expire 600000 -j ACCEPT
3343 iptables -A inet_in -p tcp --dport 22 -m state --state NEW -j REJECT
3345 <a name="230"></a><hr />
3347 Tunnel a specific connection via socat:
3350 % socat TCP4-LISTEN:8003 TCP4:gateway:500
3353 # socat TCP4-LISTEN:500,fork TCP4:target:$PORT
3355 Using localhost:8003 on the client uses the tunnel now.
3357 <a name="231"></a><hr />
3361 # date --set=060916102007
3363 where the bits are month(2)/day(2)/hour(2)/minute(2)/year(4)
3365 Set date using a relative date:
3371 # date -s '+tomorrow'
3373 Display a specific relative date:
3375 # date -d '+5 days -2 hours'
3377 Don't forget to set hardware clock via:
3381 <a name="232"></a><hr />
3383 Booting grml via network / PXE:
3385 Start grml-terminalserver on a system with network access
3386 and where grml is running:
3388 # grml-terminalserver
3390 Then booting your client(s) via PXE should work without
3393 See: man grml-terminalserver + http://grml.org/terminalserver/
3395 Tags: howto, pxe, network, boot
3397 <a name="233"></a><hr />
3399 Debugging SSL communications:
3401 % openssl s_client -connect server.adress:993 > output_file
3402 % openssl x509 -noout -text -in output_file
3406 # ssldump -a -A -H -i eth0
3408 See http://prefetch.net/articles/debuggingssl.html for more details.
3410 Tags: debug, ssl, openssl
3412 <a name="234"></a><hr />
3414 Remove bootmanager from MBR:
3416 # lilo -M /dev/hda -s /dev/null
3420 <a name="235"></a><hr />
3422 Rewrite grub to MBR:
3425 # grub-install --recheck --no-floppy --root-directory=/mnt/sda1 /dev/sda
3429 <a name="236"></a><hr />
3431 Rewrite lilo to MBR:
3438 <a name="237"></a><hr />
3440 Create screenshot of plain/real console - tty1:
3442 # fbgrab -c 1 screeni.png
3444 <a name="238"></a><hr />
3446 Create screenshot when running X:
3450 Tip: use the gkrellshoot plugin when using gkrellm
3452 Tags: screenshot, xorg
3454 <a name="239"></a><hr />
3456 Redirect all connections to hostA:portA to hostB:portB, where hostA and hostB are
3459 Run the following commands on hostA:
3461 echo 1 > /proc/sys/net/ipv4/ip_forward
3462 iptables -t nat -A PREROUTING -p tcp --dport portA -j DNAT --to hostB:portB
3463 iptables -A FORWARD -i eth0 -o eth0 -d hostB -p tcp --dport portB -j ACCEPT
3464 iptables -A FORWARD -i eth0 -o eth0 -s hostB -p tcp --sport portB -j ACCEPT
3465 iptables -t nat -A POSTROUTING -p tcp -d hostB --dport portB -j SNAT --to-source hostA
3467 Tags: howto, network, redirect, port
3469 <a name="240"></a><hr />
3471 Flash BIOS without DOS/Windows:
3473 Dump flash info and set the flash chip to writable:
3476 Backup the original BIOS:
3477 # flashrom -r backup.bin
3479 Notice: the following step will overwrite your current BIOS!
3480 So make sure you really know what you are doing.
3482 Flash the BIOS image:
3483 # flashrom -wv newbios.bin
3485 Also check out LinuxBIOS: http://linuxbios.org/
3487 <a name="241"></a><hr />
3489 Enable shadow passwords:
3493 <a name="242"></a><hr />
3495 Set up an IPv6 tunnel on grml:
3499 <a name="243"></a><hr />
3501 Set up console newsreader slrn for use with Usenet:
3505 <a name="244"></a><hr />
3507 Calculate with IPv6 addresses:
3511 For usage examples refer to manpage ipv6calc(8).
3515 <a name="245"></a><hr />
3517 Common network debugging tools for use with IPv6:
3528 <a name="246"></a><hr />
3530 Set up NFS (Network File System):
3534 Make sure the relevant services are running on the server side:
3536 # /etc/init.d/portmap start
3537 # /etc/init.d/nfs-common start
3538 # /etc/init.d/nfs-kernel-server start
3540 Export shares via /etc/exports:
3542 /backups 192.168.1.100/24(rw,wdelay,no_root_squash,async,subtree_check)
3544 ... or manually export a directory running:
3546 # exportfs -o rw,wdelay,no_root_squash,async,subtree_check 192.168.1.100:/backups
3548 and unexport a share running:
3550 # exportfs -u 192.168.1.100:/backups
3552 and every time when you modify /etc/exports file run
3556 Display what NFS components are running:
3560 Display list of exported shares:
3568 Make sure the relevant services are running on the client side:
3570 # /etc/init.d/portmap start
3571 # /etc/init.d/nfs-common start
3573 Verify that the server allows you to access its RPC/NFS services:
3575 # rpcinfo -p server_name
3577 Check what directories the server exports:
3579 # showmount -e server_name
3581 On the client side you can use something like the following in /etc/fstab:
3583 192.168.1.101:/backups /mnt/nfs nfs defaults,users,wsize=8192,rsize=8192 0 0
3585 Tags: nfs, howto, network
3587 <a name="247"></a><hr />
3591 # aptitude install cloop-src
3594 # modprobe cloop file=/path/to/cloop/file
3595 # mount -r -t iso9660 /dev/cloop /mnt/test
3597 <a name="248"></a><hr />
3599 Create a PS/PDF of a plaintext file:
3601 % a2ps --medium A4dj -E -o output.ps input_file
3604 <a name="249"></a><hr />
3606 Print two pages on one in a PDF file:
3608 % pdfnup --nup 2x1 input.pdf
3610 Concatenate, extract pages/parts, encrypt/decrypt,
3611 compress PDFs using 'pdftk'.
3613 <a name="250"></a><hr />
3615 Read a PS/PDF file on console:
3619 or on plain framebuffer console in graphical mode:
3621 % pdf2ps file.pdf ; ps2png file.ps file.png ; fbi file.png
3627 <a name="251"></a><hr />
3629 Bypass the password of a PDF file:
3631 % gs -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf -c quit
3633 <a name="252"></a><hr />
3639 This will record a AIFF audio file.
3641 <a name="253"></a><hr />
3643 Change passphrase / password of an existing SSH key:
3647 <a name="254"></a><hr />
3649 Enable syntax highlighting in nano:
3651 Just uncomment the include directives for your respective
3652 language at the bottom of the file /etc/nanorc
3654 <a name="255"></a><hr />
3656 Create netboot package for grml-terminalserver:
3658 # bash /usr/share/doc/grml-terminalserver/examples/create-netboot
3660 <a name="256"></a><hr />
3662 To boot grml via network (PXE) check out grml-terminalserver:
3664 # grml-terminalserver
3666 See http://grml.org/terminalserver/ for more details.
3668 <a name="257"></a><hr />
3672 Using the 'Orientation' tag of the Exif header, rotate
3673 the image so that it is upright:
3674 % jhead -autorot *.jpg
3676 Manually rotate a picture:
3677 % convert -rotate 270 input.jpg output.jpg
3679 <a name="258"></a><hr />
3681 Rename files based on the information inside their exif header:
3683 % jhead -n%Y-%m-%d_%Hh%M_%f *.jpg
3685 This will rename a file named img_2071.jpg to something like:
3687 2007-08-17_10h38_img_2071.jpg
3689 if it was shot at 10:38 o'clock on 2007-08-17 (according to
3690 the information inside the exif header).
3692 <a name="259"></a><hr />
3694 Calculate network / netmask:
3697 % ipcalc 10.0.0.28 255.255.255.0
3698 % ipcalc 10.0.0.0/24
3700 <a name="260"></a><hr />
3702 Blacklist a kernel module:
3704 # blacklist <name_of_kernel_module>
3706 -> running 'blacklist hostap_cs' for example will generate an
3707 entry like this in /etc/modprobe.d/grml:
3712 To remove the module from the blacklist again just invoke:
3714 # unblacklist <name_of_kernel_module>
3716 or manually remove the entry from /etc/modprobe.d/grml.
3718 <a name="261"></a><hr />
3720 Create a Debian package of a perl module:
3722 % dh-make-perl --cpan Acme::Smirch --build
3724 <a name="262"></a><hr />
3726 The Magic SysRq Keys (SysReq or Sys Req, short for System Request):
3728 To reboot your system using the SysRq keys just hold down the Alt and
3729 SysRq (Print Screen) key while pressing the keys REISUB ("Raising
3730 Elephants Is So Utterly Boring").
3732 R = take the keyboard out of raw mode
3733 E = terminates all processes (except init)
3734 I = kills all processes (except init)
3735 S = synchronizes the disk(s)
3736 U = remounts all filesystems read-only
3737 B = reboot the system
3739 Notice: use O instead of B for poweroff.
3741 Or write the sequence to /proc/sysrq-trigger instead:
3743 # for i in r e i s u b ; do echo $i > /proc/sysrq-trigger ; done
3745 To enable or disable SysRq calls:
3747 # echo 0 > /proc/sys/kernel/sysrq
3748 # echo 1 > /proc/sys/kernel/sysrq
3750 See http://en.wikipedia.org/wiki/Magic_SysRq_key for more details.
3752 Tags: reboot, documentation, sysrq, magic
3754 <a name="263"></a><hr />
3758 Just boot your grml Live-CD with "memtest" to execute a memcheck/memtest
3761 <a name="264"></a><hr />
3763 Tunnel TCP-Traffic through DNS using dns2tcp:
3767 1. Create necessary DNS-Records:
3768 dnstun.example.com. 3600 IN NS host.example.com.
3769 dnstun.example.com. 3600 IN A 192.168.1.1
3770 host.example.com. 3600 IN A 192.168.1.1
3772 2. Configure dns2tcpd on host.example.com.:
3773 # cat /etc/dns2tcpd.conf
3774 listen = 192.168.1.1 #the ip dns2tcpd should listen on
3775 port = 53 #" port " " " "
3778 domain = dnstun.example.com. # the zone as specified inside dns
3779 ressources = ssh:127.0.0.1:22 # available resources
3781 3. Start the daemon:
3782 # cat > /etc/default/dns2tcp << EOF
3783 # Set ENABLED to 1 if you want the init script to start dns2tcpd.
3787 # /etc/init.d/dns2tcp start
3791 You have two possibilities:
3792 - Use the DNS inside your network (DNS must allow resolving for external domains)
3793 # grep nameserver /etc/resolv.conf
3794 nameserver 172.16.42.1
3795 # dns2tcpc -z dnstun.example.com 172.16.42.1
3796 Available connection(s) :
3798 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com 172.16.42.1 &
3799 Listening on port : 2222
3800 # ssh localhost -p 2222
3801 user@host.example.com:~#
3803 - Directly contact the endpoint (port 53 UDP must be allowed outgoing)
3804 # dns2tcpc -z dnstun.example.com dnstun.example.com
3805 Available connection(s) :
3807 # dns2tcpc -r ssh -l 2222 -z dnstun.example.com dnstun.example.com &
3808 Listenning on port : 2222
3809 # ssh localhost -p 2222
3810 user@host.example.com:~#
3812 Notice: using 'ssh -D 8080 ..' you will get a socks5-proxy listening on
3813 localhost:8080 which you can use to tunnel everything through your "dns-uplink".
3815 Tags: howto, network, tunnel
3817 <a name="265"></a><hr />
3819 Configure a MadWifi device for adhoc mode:
3821 Disable the autocreation of athX devices:
3822 # echo "options ath_pci autocreate=none" > /etc/modprobe.d/madwifi
3824 Remove the autocreated device for now:
3825 # wlanconfig ath0 destroy
3827 Configuration in /etc/network/interfaces:
3829 iface ath0 inet static
3835 - Do not use interface names without ending 0 (otherwise startup fails).
3836 - Only chooss unique names for interfaces.
3838 <a name="266"></a><hr />
3840 Find dangling symlinks using zsh:
3844 <a name="267"></a><hr />
3846 Use approx with runit supervision
3847 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3849 Install the packages:
3850 # apt-get install approx runit
3852 Add user approxlog for the logging daemon:
3853 # adduser --system --home /nonexistent --no-create-home approxlog
3855 Create config directory:
3856 # mkdir /etc/sv/approx
3858 Use /var/run/sv.approx as supervise directory:
3859 # ln -s /var/run/sv.approx /etc/sv/approx/supervise
3861 # cat > /etc/sv/approx/run << EOF
3863 echo 'approx starting'
3864 exec approx -f 2>&1
3867 You normally do not need a logging service for approx because it logs
3868 to syslog too. So just for completion:
3869 # mkdir -p /etc/sv/approx/log
3870 # ln -s /var/run/sv.approx.log /etc/sv/approx/log/supervise
3871 # cat > /etc/sv/approx/log/run << EOF
3874 LOG="/var/log/approx"
3875 test -d "$LOG" || mkdir -p -m2750 "$LOG" && chown approxlog:adm "$LOG"
3876 exec chpst -uapproxlog svlogd -tt -v "$LOG"
3879 Now activate the new approx service (will be started within 5s):
3880 # ln -s /etc/sv/approx/ /var/service/
3882 Make approx managed via runit available via init-script interface:
3883 # dpkg-divert --local --rename /etc/init.d/approx
3884 # ln -s /usr/bin/sv /etc/init.d/approx
3886 <a name="268"></a><hr />
3888 Remote-reboot a grml system using SysRQ via /proc (execute as root):
3890 eject &>/dev/null
3893 echo b > /proc/sysrq-trigger
3895 Tags: reboot, howto, grml, network
3897 <a name="269"></a><hr />
3899 Show what happens on /dev/sda0:
3901 # mount the debugfs to relay kernel info to userspace
3902 mount -t debugfs none /sys/kernel/debug
3904 # is a convenient wrapper arround blktrace and blkparse
3907 Tags: debug, block, partition, trace
3909 <a name="270"></a><hr />
3911 Convert Flash to Avi:
3913 % ffmpeg -i input.flv output.avi
3915 Extract MP3 from Flash file:
3917 % for i in *.flv; do ffmpeg -i $i -acodec copy ${i%.flv}.mp3 ; done
3919 <a name="271"></a><hr />
3921 Usage example for cryptsetup / -luks encrypted partition on LVM:
3923 volume group name: x61
3924 logical volume name: home
3926 echo "grml-crypt_home /dev/mapper/x61-home none luks" >> /etc/crypttab
3928 mount /dev/mapper/grml-crypt_home /mnt/test
3930 <a name="272"></a><hr />
3932 fdisk/parted/... complains with something like
3933 'unable to open /dev/sda - unrecognised disk label'?!
3935 See http://grml.org/faq/#fdisk =>
3937 * use /sbin/fdisk.distrib from util-linux
3938 * switch to sfdisk, cfdisk,...
3939 * use parted's mklabel command (but please read the
3940 parted manual before executing this command)
3942 <a name="273"></a><hr />
3944 dmraid - support for SW-RAID / FakeRAID controllers
3945 like Highpoint HPT and Promise FastTrack
3947 Activate all software RAID sets discovered:
3950 Deactivates all active software RAID sets:
3953 Discover all software RAID devices supported on the system:
3956 <a name="274"></a><hr />
3958 Extract winmail.dat:
3963 Extract files to current directory:
3964 % ytnef -f . winmail.dat
3966 <a name="275"></a><hr />
3968 Approx - Debian package proxy/cacher howto
3970 % apt-get install approx
3971 % echo 'debian http://ftp.de.debian.org/debian' >>/etc/approx/approx.conf
3974 Add your new approx to sources.list
3977 deb http://localhost:9999/debian unstable main contrib non-free
3979 use approx in grml-debootstrap like:
3980 % grml-debootstrap -r lenny -t /dev/sda1 -m http://127.0.0.1:9999/debian
3982 <a name="276"></a><hr />
3984 Simple webserver with python:
3986 % python -m SimpleHTTPServer
3988 <a name="277"></a><hr />
3990 Upgrade only packages from the grml-stable Debian repository:
3992 echo 'deb http://deb.grml.org/ grml-stable main' > /etc/apt/grml-stable.list
3993 apt-get -o Dir::Etc::sourcelist=/etc/apt/grml-stable.list -o Dir::Etc::sourceparts=/doesnotexist update
3996 <a name="278"></a><hr />
3998 Install Centos into a directory:
4000 % febootstrap centos-5 directory http://mirror.centos.org/centos-5/5.3/os/i386/
4002 <a name="279"></a><hr />
4004 Install Fedora into a directory:
4006 % febootstrap fedora-11 target_directory
4008 <a name="280"></a><hr />
4010 Use Nessus / OpenVAS (remote network security auditor):
4012 Install software packages:
4014 # apt-get install openvas-client openvas-server openvas-plugins-base openvas-plugins-dfsg
4019 Start openvas server (takes a while):
4020 # Start openvas-server
4022 Invoke client as user:
4025 <a name="281"></a><hr />
4027 Find packages not available from any active apt repository:
4029 % apt-show-versions | awk '/No available version in archive/{print $1}'
4031 <a name="282"></a><hr />
4033 Simple mailserver with python:
4035 % python -m smtpd -n -c DebuggingServer localhost:1025
4037 <a name="283"></a><hr />
4041 echo $USER | nc $HOST 79
4043 <a name="284"></a><hr />
4045 Install Archlinux using Grml:
4047 https://wiki.archlinux.org/index.php/Install_from_Existing_Linux
4049 wget http://tokland.googlecode.com/svn/trunk/archlinux/arch-bootstrap.sh
4051 <a name="285"></a><hr />
4053 Export blockdevices via AoE (ATA over Ethernet):
4055 % vblade -m 11:22:33:44:55:66 160 2 eth0 /dev/sdb1
4057 Allow the host with the mac address 11:22:33:44:55:66 to access /dev/sdb1
4058 via eth0, using the shelf and slot numbers 160 and 2. These numbers are
4059 arbitrary but should be unique within the network.
4061 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4062 especially arp spoofing. Do not use in hostile networks.
4064 Tags: aoe, blockdevice, export, server
4066 <a name="286"></a><hr />
4068 Access blockdevices via AoE (ATA over Ethernet):
4072 and the device should show up under /dev/etherd/. If your shelf and
4073 slot numbers re 160 and 2 the device will be /dev/etherd/e160.2
4075 A word of warning: AoE is prone to all kind of nasty ethernet attacks,
4076 especially arp spoofing. Do not use in hostile networks.
4078 Tags: aoe, blockdevice, export, client
4080 <a name="287"></a><hr />