1 Install grml to harddisk:
5 Notice: You can pre-select the partition for the partition selector
6 and mbr dialogs inside grml2hd using:
7 # grml2hd /dev/hda1 -mbr /dev/hda
9 See: man grml2hd + http://grml.org/grml2hd/
11 Install grml on software RAID level 1:
13 Create /dev/md0 (and some more /dev/md* devices) first of all:
14 # cd /dev && MAKEDEV dev
17 # mdadm --create --verbose /dev/md0 --level=raid1 \
18 --raid-devices=2 /dev/hda1 /dev/hdc1
20 Finally install grml on it:
21 # SWRAID='mbr-only' grml2hd /dev/md0 -mbr /dev/md0
23 See: man grml2hd + http://grml.org/grml2hd/
25 Install grml in non interactive mode with grml2hd:
27 Adjust configuration as needed:
28 # vim /etc/grml2hd/config
32 # GRML2HD_NONINTERACTIVE=yes grml2hd
38 Use with care and only if you really know what you are doing!
40 See: man grml2hd + http://grml.org/grml2hd/
46 Boot grml via network:
50 See: man grml-terminalserver + http://grml.org/terminalserver/
52 Deactivate error correction of zsh:
56 Run zsh-help for more information regarding zsh.
58 Disable automatic setting of title in GNU screen:
62 Set it manually e.g. via:
64 % screen -X title foobar
66 Run zsh-help for more information regarding zsh.
68 Do not use menu completion in zsh:
72 Run zsh-help for more information regarding zsh.
74 Run GNU screen with grml-configuration:
80 % screen -c /etc/grml/screenrc
82 Print out grml-version:
90 Configure mutt-ng / muttng:
94 Set up Inode-PPTP connection:
98 # grml-pptp-xdsl-students
100 Set up VPN / WLAN connection at TUG (TU Graz):
102 Set ESSID and request for ip-address via DHCP:
103 # iwconfig $DEVICE essid tug
106 Now run the main script:
109 After running the script an init script is available:
111 # /etc/init.d/vpnctug [start|stop]
113 Set up PPTP connection at VCG (Virtual Campus Graz):
123 # grml-vpn -k 2005 add 1000 192.168.20.1 192.168.20.2
127 Use encrypted files / partitions:
129 # grml-crypt <options>
135 # grml-crypt format /mnt/external1/encrypted_file /mnt/test
136 # cp big_file /mnt/test
137 # grml-crypt stop /mnt/test
141 # grml-crypt start /mnt/external1/encrypted_file /mnt/test
142 # grml-crypt stop /mnt/test
146 Change resolution of X:
148 % xrandr -s '1024x768'
150 Change resolution of framebuffer:
154 Configure newsreader slrn:
158 Configure grml system:
162 Or directly run scripts:
167 Lock screen (X / console):
171 Press ctrl-alt-x to lock a GNU screen session.
173 Change wallpaper in X:
175 % grml-wallpaper <press-tab>
177 Start X window system (XFree86 / Xorg / X.org):
179 % grml-x $WINDOWMANAGER
184 % grml-x -mode '1024x768' wmii
185 % grml-x -nosync wm-ng
187 Collect hardware information:
191 or run as root to collect some more information:
195 will generate a file named info.tar.bz2.
197 Configure hardware detection features of harddisk installation:
201 or manually edit /etc/grml/autoconfig[.small]
203 See: man grml-autoconfig
205 Bootoptions / cheatcodes / bootparams for booting grml:
207 On the grml-ISO if not running grml:
208 % less /cdrom/GRML/grml-cheatcodes.txt
211 % most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
213 Report bugs to Debian's Bug Tracking System (BTS):
215 % reportbug --bts debian
217 or adjust /etc/reportbug.conf to your needs.
221 http://grml.org/bugs/
222 http://www.debian.org/Bugs/
224 Offline documentation:
228 Online documentation:
231 http://grml.org/docs/
232 http://wiki.grml.org/doku.php
234 Mount ntfs partition (read-write):
237 # ntfsmount /dev/hda1 /mnt/hda1
239 Overwrite specific file on an NTFS partition:
241 ntfscp /dev/hda1 /tmp/file_source path/to/file_target
243 Resize an NTFS partition:
249 ntfsresize -n -s 10G /dev/hda1 # testcase
250 ntfsresize -s 10G /dev/hda1 # testing was successfull, now really resize partition
251 cfdisk /dev/hda # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
253 Modify resolution for intel graphic chipsets:
259 # 915resolution 4d 1400 1050
261 Connect bluetooth mouse:
265 ... and press 'connect' button on your bluetooth device.
267 Connect bluetooth headset:
271 ... and press 'connect' button on your bluetooth device.
273 Secure delete file / directory / partition:
279 Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
281 Use grml on Samsung X20 laptop:
283 # apt-get install grml-samsung-x20
285 See: http://www.michael-prokop.at/computer/samsung_x20.html
287 Development information regarding grml:
289 http://grml.supersized.org/
293 #grml on irc.freenode.org - http://grml.org/irc/
294 http://grml.org/contact/
296 Join the grml mailinglist:
298 http://grml.org/mailinglist/
302 http://grml.org/donations/
304 Commercial support / system administration / adjusted live-cds:
306 grml-solutions: http://grml.org/solutions/
308 Information regarding the kernel provided by grml:
310 http://grml.org/kernel/
312 SMTP command-line test tool:
318 % swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
322 NTFS related packages:
328 Modify service through init script:
335 # /etc/init.d/lvm start
339 # jstest /dev/input/js0
343 % mplayer /path/to/movie
345 Use webcam with mplayer:
347 % mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
349 Powerful network discovery tool:
353 Grab an entire CD and compress it to Ogg/Vorbis,
354 MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
358 Show a console session in several terminals:
362 Switch behaviour of caps lock key:
366 grep with Perl-compatible regular expressions:
370 ncp: a fast file copy tool for LANs
375 Remote (receive file):
378 utility for sorting records in complex ways:
382 a smaller, cheaper, faster SED implementation:
390 See: http://grml.org/zsh/
392 zsh reference card for grml system:
395 /usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
399 % for i in foo* ; do mv "$i" "bar${i/foo}" ; done
401 % prename 's/foo/bar/' foo*
403 % zmv 'foo(*)' 'bar$1'
405 Test TFT / LCD display:
413 Improved grep version:
417 glark grep extract-matches
424 Output text as sound:
427 % xsay # when running X and text selected via mouse
429 Adjust a grml harddisk (grml2hd) installation:
433 Get information on movie files:
435 % tcprobe -i file.avi
437 Get an overview of your image files:
439 % convert 'vid:*.jpg' thumbnails.jpg
441 List all standard defines:
443 % gcc -dM -E - < /dev/null
445 Send a mail as reminder:
447 echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
449 ncurses-based presentation tool:
453 See: man tpp and /usr/share/doc/tpp/examples/
455 Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
459 Use IRC on command line:
465 % vimdiff file1 file2
471 Moving between diffs:
481 Hardware monitoring without kernel dependencies:
485 Install grml-iso to usb-stick:
487 % grml2usb grml.iso /mount/point
489 Use mplayer on framebuffer console:
491 % mplayer -vo fbdev ...
493 Use links2 on framebuffer console:
495 % links2 -driver fb ...
497 Switch language / keyboard:
499 * use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
500 * use the bootparams keyboard / xkeyboard to activate specific keyboard layout
501 Usage example: 'grml lang=us keyboard=de xkeyboard=de'
503 Or run one of the following commands:
507 # loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
510 Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
514 Mount usb device / usb stick:
516 % mount /mnt/external1 # corresponds to /dev/sda1
518 % mount /mnt/external # corresponds to /dev/sda
520 Install Sun Java packages:
522 Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
524 # apt-get install java-package
525 # fakeroot make-jpkg j2re-*.bin
526 # dpkg -i sun-j2re*.deb
527 # update-alternatives --config java
531 ddrescue is an improved version of dd which tries to read and
532 if it fails it will go on with the next sectors, where tools
539 How to make an audio file (e.g. Musepack format) out of a DVD track:
541 % mkfifo /tmp/fifo.wav
542 % mppenc /tmp/fifo.wav track06.mpc &
543 % mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
545 Adjust the mppenc line with the encoder you would like to use,
546 for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
550 % mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
551 to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
553 Usage example for getting a PCM/wave file from audio channel 128:
554 % mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
556 Create simple chroot:
558 # make_chroot_jail $USERNAME
560 Convert DOS formated file to unix format:
562 sed 's/.$//' dosfile > unixfile # assumes that all lines end with CR/LF
563 sed 's/^M$//' dosfile > unixfile # in bash/tcsh, press Ctrl-V then Ctrl-M
564 sed 's/\x0D$//' dosfile > unixfile # gsed 3.02.80, but top script is easier
565 awk '{sub(/\r$/,"");print}' # assumes EACH line ends with Ctrl-M
566 gawk -v BINMODE="w" '1' infile >outfile # in DOS environment; cannot be done with
567 # DOS versions of awk, other than gawk
568 tr -d \r < dosfile > unixfile # GNU tr version 1.22 or higher
569 tr -d '\015' < dosfile > unixfile # use octal value for "\r" (see man ascii)
570 tr -d '[\015\032]' < dosfile > unixfile # sometimes ^Z is appended to DOS-files
571 vim -c ":set ff=unix" -c ":wq" file # convert using vim
572 vim -c "se ff=dos|x" file # ... and even shorter ;)
573 recode ibmpc..lat1 file # convert using recode
574 echo -e "s/\r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
576 Save live stream to file:
578 % mplayer -ao pcm -aofile $FILE
582 % mencoder mms://file.wmv -o $FILE -ovc copy -oac copy
588 % avimerge -i *.avi -o blub.avi
592 % cat *.mpg > blub.mpg
596 % mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -o file1.avi
597 % mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -o file2.avi
598 % avimerge -i file1.avi file2.avi -o blub.avi
600 Display MS-Word file:
602 % strings file.doc | fmt | less
608 Convert MS-Word file to postscript:
610 % antiword -p a4 file.doc > file.ps
612 Convert manual to postscript:
614 % zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
616 % man -t zsh > zsh.ps
620 % dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
622 Read HTTP via netcat:
624 echo "GET / HTTP/1.0\r\n\r\n" | netcat $DOMAIN 80
626 Get X ressources for specific program:
628 % xrdb -q |grep -i xterm
630 Get windowid of specific X-window:
632 % xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
634 Get titel of specific X-window:
638 check locale - LC_MESSAGES:
640 % locale -ck LC_MESSAGES
642 Create random password:
646 % dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
648 Get tarballs of various Linux Kernel trees:
651 to get the current stable 2.6 release
654 to get a list of all supported trees
656 Transfer your SSH public key to another host:
658 % ssh-copy-id -i ~/.ssh/id_dsa.pub user@remote-system
660 % cat $HOME/.ssh/id_rsa.pub | ssh user@remote-system 'cat >> .ssh/authorized_keys'
662 Update /etc/fstab entries:
666 See "man grml-rebuildfstab" for more details about
667 generation of /etc/fstab (including stuff like
668 fs LABELs / UUIDs,...).
670 Fetch and potentially change SCSI device parameters:
676 reclaim disk space by linking identical files together:
680 Find and remove duplicate files:
684 Perform layer 2 attacks:
690 Guess PC-type hard disk partitions / partition table:
694 Perform a standard scan:
697 Write back the guessed table:
698 # gpart -W /dev/ice /dev/ice
700 Develop, test and use exploit code with the Metasploit Framework:
703 unp /usr/share/grml-sectools/tools/metasploit_framework*.tar.gz
707 Useful documentation:
709 % w3m /usr/share/doc/Debian/reference/reference.en.html
711 % xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
713 http://grml.org/docs/ grml Documentation
714 http://wiki.grml.org/ grml Wiki
715 http://www.debian.org/doc/ Debian Documentation
716 http://wiki.debian.org/ Debian Wiki
717 http://www.gentoo.org/doc/en/ Gentoo Documentation
718 http://gentoo-wiki.com/ Gentoo Wiki
719 http://www.tldp.org/ The Linux Documentation Project
723 % fortune debian-hints
727 % fortune debian-hints
728 % dpkg -L funny-manpages
730 Backup master boot record (MBR):
732 # dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
734 Backup partition table:
736 # sfdisk -d /dev/hda > hda.out
738 Restore partition table:
740 # sfdisk /dev/hda < hda.out
742 Clone disk via network using netcat:
745 # nc -vlp 30000 > hda1.img
747 # dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
749 Adjust blocksize (dd's option bs=...) and include 'gzip -c'
752 # dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
754 Backup specific directories via cpio and ssh:
756 # for f in directory_list; do find $f >> backup.list done
757 # cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
761 This one uses CPU cycles on the remote server to compare the files:
762 # ssh target_address cat remotefile | diff - localfile
763 # cat localfile | ssh target_address diff - remotefile
765 This one uses CPU cycles on the local server to compare the files:
766 # ssh target_address cat <localfile "|" diff - remotefile
768 Useful tools for cloning / backups:
770 * dd: convert and copy a file
771 * dd_rescue: copies data from one file (or block device) to another
772 * pcopy: a replacement for dd
773 * partimage: back up and restore disk partitions
774 * dirvish: Disk based virtual image network backup system
775 * devclone: in-place filesystem conversion -- device cloning
776 * ntfsclone: efficiently clone, image, restore or rescue an NTFS
777 * dump: ext2/3 filesystem backup
778 * udpcast: multicast file transfer tool
779 * cpio: copy files to and from archives
780 * pax: read and write file archives and copy directory hierarchies
781 * netcat / ssh / tar / gzip / bzip2: additional helper tools
783 Use grml as a rescue system:
787 * dd: convert and copy a file
788 * ddrescue: copies data from one file or block device to another
789 * partimage: Linux/UNIX utility to save partitions in a compressed image file
790 * cfdisk: Partition a hard drive
791 * nparted: Newt and GNU Parted based disk partition table manipulator
792 * parted-bf: The GNU Parted disk partition resizing program, small version
793 * testdisk: Partition scanner and disk recovery tool
794 * gpart: Guess PC disk partition table, find lost partitions
798 * e2fsprogs: ext2 file system utilities and libraries
799 * e2tools: utilities for manipulating files in an ext2/ext3 filesystem
800 * e2undel: Undelete utility for the ext2 file system
801 * ext2resize: an ext2 filesystem resizer
802 * recover: Undelete files on ext2 partitions
806 * reiser4progs: administration utilities for the Reiser4 filesystem
807 * reiserfsprogs: User-level tools for ReiserFS filesystems
811 * xfsdump: Administrative utilities for the XFS filesystem
812 * xfsprogs: Utilities for managing the XFS filesystem
816 * jfsutils: utilities for managing the JFS filesystem
820 * ntfsprogs: tools for doing neat things in NTFS partitions from Linux
821 * salvage-ntfs: free NTFS data recovery tools
822 * scrounge-ntfs: data recovery program for NTFS file systems
823 * ntfsresize: resize ntfs partitions
825 Get ASCII value of a character with zsh:
827 % char=N ; print $((#char))
829 Convert a collection of mp3 files to wave or cdr using zsh:
831 % for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
833 Convert images (foo.gif to foo.png) using zsh:
835 % for i in **/*.gif; convert $i $i:r.png
837 Remove all "non txt" files using zsh:
841 Remote Shell Using SSH:
844 % ssh -NR 3333:localhost:22 user@yourhost
847 % ssh user@localhost -p 3333
849 Reverse Shell with Netcat:
852 % netcat -v -l -p 3333 -e /bin/sh
855 % netcat 192.168.0.1 3333
857 Remove empty directories with zsh:
859 % rmdir ./**/*(/od) 2> /dev/null
861 Find all the empty directories in a tree with zsh:
865 Find all files without a valid owner and change ownership with zsh:
867 % chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
869 Display the 5-10 last modified files with zsh:
871 % print -rl -- /path/to/dir/**/*(D.om[5,10])
873 Find and list the ten newest files in directories and subdirs (recursive) with zsh:
875 % print -rl -- **/*(Dom[1,10])
877 Find most recent file in a directory with zsh:
879 % setopt dotglob ; print directory/**/*(om[1])
881 Tunnel all traffic through an external server:
883 % ssh -ND 3333 username@external.machine
885 Then set the SOCKS4/5 proxy to localhost:3333.
886 Check whether it's working by surfing e.g. to checkip.dyndns.org
888 Tunnel everything through SSH via tsocks:
890 set up the SSH proxy on the client side:
892 % ssh -ND 3333 user@remote.host.example.com
894 Adjust /etc/tsocks.conf afterwards (delete all other lines):
899 For programs who natively support proxying connections (e.g. Mozilla
900 Firefox) you can now set the proxy address to localhost port 3333.
902 All other programs which's connections you want to tunnel through your
903 external host are prefixed with tsocks, e.g.:
905 % tsocks netcat example.com 80
906 % tsocks irssi -c irc.quakenet.eu.org -p 6667
908 If you call tsocks without parameters it executes a shell witht the
909 LD_PRELOAD environment variable already set and exported.
911 smartctl - control and monitor utility for harddisks using Self-Monitoring,
912 Analysis and Reporting Technology (SMART):
914 # smartctl --all /dev/ice
916 If you want to use smartctl on S-ATA (sata) disks use:
918 # smartctl -d ata --all /dev/sda
921 # smartctl -t offline /dev/ice
924 # smartctl -t short /dev/ice
926 Display results of test:
927 # smartctl -l selftest /dev/ice
929 Query device information:
930 # smartctl -i /dev/ice
932 Mount a BSD / Solaris partition:
934 # mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
936 Use ufstype 44bsd for FreeBSD, NetBSD, OpenBSD (read-write).
937 Use ufstype ufs2 for >= FreeBSD 5.x (read-only).
938 Use ufstype sun for SunOS (Solaris) (read-write).
939 Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
941 See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
944 Read BIOS (and or BIOS) password:
946 # dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
948 Clone one of the kernel trees via git:
950 git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
951 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
952 This path defines the tree. See http://kernel.org/git/ for an overview.
954 Mount filesystems over ssh protocol:
956 % sshfs user@host:/remote_dir /mnt/test
960 % fusermount -u /mnt/test
962 (Notice: requires fuse kernel module)
964 Install Gentoo using grml:
966 See http://www.gentoo.org/doc/en/altinstall.xml
968 Install (plain) Debian (sarge release) via grml:
970 Assuming you want to install Debian to sda1:
972 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
973 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
974 debootstrap sarge /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
975 chroot /mnt/test /bin/bash # let's chroot into the new system
976 mount -t devpts none /dev/pts # ...otherwise running base-config might fail ("Terminated" or "openpty failed")
977 mount -t proc none /proc # make sure we also have a mounted /proc
978 base-config # now configure some main settings
979 vi /etc/mkinitrd/mkinitrd.conf # adjust $ROOT (to /dev/sda1) for your new partition, autodetection will fail in chroot
980 cd /dev ; ./MAKEDEV generic # make sure we have all necessary devices for lilo
981 apt-get install lilo linux-image-2.6.12-1-386 # install lilo and a kernel which fits your needs
982 cp /usr/share/doc/lilo/examples/conf.sample /etc/lilo.conf # let's use a template
983 vi /etc/lilo.conf && lilo # adjust the file for your needs and run lilo afterwards
984 umount /proc ; umount /dev/pts # we do not need them any more
985 exit # now leave chroot
986 cp /etc/hosts /etc/fstab /mnt/test/etc/ # you might want to take the existing files...
987 cp /etc/network/interfaces /mnt/test/etc/network/ # ...from the running grml system for your new system
988 umount /mnt/test && reboot # unmount partition and reboot...
990 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
992 Install (plain) Debian (etch release) via grml
994 Assuming you want to install Debian to sda1:
996 mkfs.ext3 /dev/sda1 # make an ext3 filesystem on /dev/sda1
997 mount -o rw,suid,dev /dev/sda1 /mnt/test # now mount the new partition
998 debootstrap etch /mnt/test ftp://ftp.tugraz.at/mirror/debian # get main packages from a debian-mirror
999 chroot /mnt/test /bin/bash # let's chroot into the new system
1000 mount -t proc none /proc # make sure we have a mounted /proc
1001 apt-get install locales console-data # install locales
1002 dpkg-reconfigure locales console-data # adjust locales to your needs
1003 apt-get install vim most zsh screen less initrd-tools file grub \
1004 usbutils pciutils bzip2 sysfsutils dhcp3-client resolvconf \
1005 strace lsof w3m # install useful software
1006 apt-get install linux-headers-2.6-686 linux-image-2.6.15-1-686 # install current kernel
1008 echo "127.0.0.1 localhost" > /etc/hosts # adjust /etc/hosts and network:
1009 cat >> /etc/network/interfaces << EOF
1010 iface lo inet loopback
1011 iface eth0 inet dhcp
1016 ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime # adjust timezone and /etc/fstab:
1017 cat >> /etc/fstab << EOF
1018 sysfs /sys sysfs auto 0 0
1019 proc /proc proc defaults 0 0
1020 /dev/sda1 / ext3 defaults,errors=remount-ro 0 1
1021 /dev/sda2 none swap sw 0 0
1022 /dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
1024 passwd # set password of user root
1026 mkdir /boot/grub # setup grub
1027 cp /usr/share/doc/grub/examples/menu.lst /boot/grub
1028 cat >> /boot/grub/menu.lst << EOF
1029 title Debian Etch, kernel 2.6.15-1-686 (on /dev/sda1)
1031 kernel /boot/vmlinuz-2.6.15-1-686 root=/dev/sda1 ro
1032 initrd /boot/initrd.img-2.6.15-1-686
1034 vim /boot/grub/menu.lst # adjust grub configuration to your needs
1035 cd /dev && MAKEDEV generic # create default devices
1036 cp -i /lib/grub/i386-pc/* /boot/grub/ # copy stage-files to /boot/grub/
1037 grub install # now install grub, run in grub-cmdline following commands:
1041 umount -a # unmount all filesystems in chroot and finally:
1042 exit # exit the chroot and:
1045 If you want to use lilo instead of grub take a look at
1046 /usr/share/doc/lilo/examples/conf.sample or use the following template:
1048 cat > /etc/lilo.conf << EOF
1049 # This allows booting from any partition on disks with more than 1024 cylinders.
1052 # Specifies the boot device
1055 # Specifies the device that should be mounted as root.
1058 # use Debian on software raid:
1059 # raid-extra-boot=mbr-only
1067 image=/boot/vmlinuz-2.6.17-grml
1071 initrd=/boot/initrd.img-2.6.17-grml
1074 See also: http://www.debian.org/releases/stable/i386/apcs04.html.en
1076 Convert files from Unicode / UTF to ISO:
1078 % iconv -f utf8 -t iso-8859-15 < utffile > isofile
1082 % iconv -f iso-8859-15 -t utf8 < isofile > utffile
1084 Assign static setup for network cards (eth0 and eth1) via udev:
1086 First method - manual:
1087 ~~~~~~~~~~~~~~~~~~~~~~
1088 Get information for SYSFS address:
1089 # udevinfo -a -p /sys/class/net/eth0/ | grep address
1091 Then create udev rules:
1092 # cat /etc/udev/network.rules
1094 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:01", NAME="wlan0"
1095 KERNEL=="eth*", SYSFS{address}=="00:00:00:00:00:02", NAME="lan0"
1096 # do not match eth* drivers but also e.g. firewire stuff:
1097 ACTION=="add", SUBSYSTEM=="net", SYSFS{address}=="00:00:00:00:00:03", NAME="1394"
1099 Now activate the rules:
1100 # cd /etc/udev/rules.d/ && ln -s ../network.rules z35_network.rules
1102 Unload the drivers, restart udev and load the drivers again to activate
1105 Second method - automatic:
1106 ~~~~~~~~~~~~~~~~~~~~~~~~~~
1107 Run /lib/udev/write_net_rules shipped with recent udev versions:
1109 # INTERFACE=wlan1 /lib/udev/write_net_rules 00:00:00:00:00:04
1111 This command will create /etc/udev/rules.d/z25_persistent-net.rules containing:
1113 SUBSYSTEM=="net", DRIVER=="?*", SYSFS{address}=="00:00:00:00:00:04", NAME=wlan1
1115 See /usr/share/doc/udev/writing_udev_rules/index.html for more information.
1117 Change the suffix from *.sh to *.pl using zsh:
1120 % zmv -W '*.sh' '*.pl'
1122 Generate SSL certificate:
1124 Create self signed certificate (adjust /etc/ssl/openssl.cnf if necessary):
1125 # openssl req -x509 -newkey rsa:1024 -keyout keyfile -out certfile -days 9999 -nodes
1128 # openssl x509 -in certfile -text
1130 Verify against CA certificate:
1131 # openssl verify -CAfile cacert.crt -verbose -purpose sslserver
1133 Generate 2048bit RSA-key:
1134 # openssl req -new -x509 -keyout pub-sec-key.pem -out pub-sec-key.pem -days 365 -nodes
1136 As before but add request to existing key pub-sec-key.pem:
1137 # openssl req -new -out request.pem -keyin pub-sec-key.pem
1139 Show request request.pem:
1140 # openssl req -text -noout -in request.pem
1142 Verify signature of request request.pem:
1143 # openssl req -verify -noout -in request.pem
1145 Generate SHA1 fingerprint (modulo key) of request.pem:
1146 # openssl req -noout -modulus -in request.pem | openssl sha1 -c
1148 Generate 2048bit RSA-key and put it to pub-sec-key.pem. Save self signed certificate in self-signed-certificate.pem:
1149 # openssl req -x509 -days 365 -newkey rsa:2048 -out self-signed-certificate.pem -keyout pub-sec-key.pem
1151 As before but create self signed certificate based on existing key pub-sec-key.pem:
1152 # openssl req -x509 -days 365 -new -out self-signed-certificate.pem -key pub-sec-key.pem
1154 Generate new request out of existing self signed certificate:
1155 # openssl x509 -x509toreq -in self-signed-certificate.pem -signkey pub-sec-key.pem -out request.pem
1157 Display certificate self-signed-certificate.pem in plaintext:
1158 # openssl x509 -text -noout -md5 -in self-signed-certificate.pem
1160 Check self signed certificate:
1161 # openssl verify -issuer_checks -CAfile self-signed-certificate.pem self-signed-certificate.pem
1163 Estable OpenSSL-connection using self-signed-certificate.pem and display certificate:
1164 # openssl s_client -showcerts -CAfile self-signed-certificate.pem -connect www.example.com:443
1166 Also take a look at make-ssl-cert (debconf wrapper for openssl)
1167 and mod-ssl-makecert (utility to create SSL certificates in /etc/apache/ssl.*/).
1169 Change Windows NT password(s):
1171 # mount -o rw /mnt/hda1
1172 # cd /mnt/hda1/WINDOWS/system32/config/
1173 # chntpw SAM SECURITY system
1175 Notice: if mounting the partition read-write did not work (check syslog!)
1176 try using mount.ntfs-3g instead: mount.ntfs-3g /dev/hda1 /mnt/hda1
1178 (Be careful with deactivating syskey!)
1180 glark - replacement for grep written in Ruby:
1182 A replacement for (or supplement to) the grep family, glark offers:
1183 Perl compatible regular expressions, highlighting of matches,
1184 context around matches, complex expressions and automatic exclusion
1189 % glark -y keyword file # display only the region that matched, not the entire line
1190 % glark -o format print *.h # search for either "printf" or "format"
1192 More information: man glark
1194 Find CD burning device(s):
1196 General information on CD-ROM:
1197 % cat /proc/sys/dev/cdrom/info
1199 Scan using ATA Packet specific SCSI transport:
1200 # cdrecord -dev=ATA -scanbus
1201 # cdrecord-prodvd -s -scanbus dev=ATA
1203 Get specific information for /dev/ice:
1204 # cdrecord dev=/dev/ice -scanbus
1206 Create devices in /dev on udev:
1208 For example create md devices (/dev/md0, /dev/md1,...):
1209 # cd /dev ; WRITE_ON_UDEV=1 ./MAKEDEV md
1211 Identify network device (NIC):
1213 # ethtool -i $DEVICE
1215 Show NIC statistics:
1217 # ethtool -S $DEVICE
1219 If your NIC shows some aging signs, you may want to be sure:
1221 # ethtool -t $DEVICE
1223 Disable TCP/UDP checksums:
1225 # ethtool -K $DEVICE tx off
1227 grml2hd seems to hang? Getting Squashfs errors? Problems while booting?
1229 Switch to tty12 and take a look at the syslog. If you see something like:
1231 SQUASHFS error: zlib_fs returned unexpected result 0x........
1232 SQUASHFS error: Unable to read cache block [.....]
1233 SQUASHFS error: Unable to read inode [.....]
1235 your ISO/CD-ROM very probably is not ok. Verify it via booting with grml testcd.
1236 Check your CD low-level via running:
1238 # readcd -c2scan dev=/dev/cdrom
1240 If the medium really is ok and it still fails try to boot with deactivated DMA
1241 via using grml nodma at the bootprompt.
1243 Write a Microsoft compatible boot record (MBR) using ms-sys
1245 Write a Windows 2000/XP/2003 MBR to device:
1247 # ms-sys -m /dev/ice
1249 Use a Vodafone 3G Datacard (UMTS) with Linux:
1251 Plug in your vodafone card and check in syslog whether the appropriate
1252 (probably /dev/ttyUSB0 or /dev/noz0 when using newer vodafone cards) has
1253 been created. If so run:
1256 # wvdial --config /etc/wvdial.conf.umts $PROFILE
1259 # gcom -d /dev/ttyUSB0
1260 # wvdial --config /etc/wvdial.conf.umts a1usb
1263 # wvdial --config /etc/wvdial.conf.umts tmnozomi
1266 # wvdial --config /etc/wvdial.conf.umts dreiusb
1268 Notice: newer vodafone cards require the nozomi driver. Run 'modprobe nozomi' on
1271 hdparm - get/set hard disk parameters
1273 Display the identification info that was obtained from the drive at boot time,
1275 # hpdarm -i /dev/ice
1277 Request identification info directly from the drive:
1278 # hpdarm -I /dev/ice
1280 Perform timings of device + cache reads for benchmark and comparison purposes:
1281 # hdparm -tT /dev/ice
1283 bonnie++ - program to test hard drive performance.
1285 # mkdir /mnt/benchmark
1286 # mount /dev/ice /mnt/benchmark
1287 # chmod go+w /mnt/benchmark
1288 # bonnie -u grml -d /mnt/benchmark -s 2000M
1290 Use gizmo with a bluetooth headset:
1292 % DEVICE="/dev/dsp$(awk '/- BT Headset/ {print $1}' /proc/asound/cards)"
1293 % gizmo --mic $DEVICE --speaker $DEVICE
1295 Scan a v4l device for TV stations:
1297 % scantv -c /dev/video0 -C /dev/vbi0 -o ~/.xawtv
1299 Then running xawtv should work:
1303 Run apt-get with timeout of 3 seconds:
1305 # apt-get -o acquire::http::timeout=3 update
1307 Debian GNU/Linux device driver check page
1309 % $BROWSER http://kmuto.jp/debian/hcl/index.cgi
1311 Use dd with status line:
1313 # dd if=/dev/ice conv=noerror,notrunc,sync | buffer -S 100k | dd of=/tmp/file
1315 Generate a 512k file of random data with status bar:
1317 % dd if=/dev/random bs=1024 count=512 | bar -s 512k -of ./random
1319 Install Grub instead of lilo on grml installation (grml2hd):
1324 adjust grub's configuration file menu.lst:
1325 # $EDITOR /boot/grub/menu.lst
1327 now install grub (usage example for /dev/sda1):
1332 Install Ubuntu using grml:
1334 See https://wiki.ubuntu.com/Installation/FromKnoppix
1336 Resize ext2 / ext3 partition:
1338 # tune2fs -O '^has_journal' /dev/iceX # disable journaling
1339 # fsck.ext2 -v -y -f /dev/iceX # check the filesystem
1340 # resize2fs -p /dev/iceX $SIZE # resize it (adjust $SIZE)
1341 # fdisk /dev/ice # adjust partition in partition table
1342 # fsck.ext2 -v -y -f /dev/iceX # check filesystem again
1343 # resize2fs -p /dev/iceX # resize it to maximum
1344 # tune2fs -j /dev/iceX # re-enable journal
1346 Tune ext2 / ext3 filesystem:
1348 Check partition first:
1350 # tune2fs -l /dev/iceX
1352 If you don't see dir_index in the list, then enable it:
1354 # tune2fs -O dir_index /dev/iceX
1356 Now run e2fsck with the -D option to have the directories optimized:
1358 # e2fsck -D /dev/iceX
1360 Notice: since e2fsprogs (1.39-1) filesystems are created with
1361 directory indexing and on-line resizing enabled by default.
1363 Search for printers via network:
1365 # pconf_detect -m NETWORK -i 192.168.0.1/24
1367 Mount a remote directory via webdav (e.g. Mediacenter of GMX):
1369 # mount -t davfs https://mediacenter.gmx.net/ /mnt/test
1371 System-Profiling using oprofile:
1376 # opcontrol --setup --no-vmlinux --event=CPU_CLK_UNHALTED:500000:0:1:1 --separate=library
1381 Now $DO_SOME_TASKS...
1384 # opcontrol --shutdown
1386 Then take a look at the reports using something like e.g.:
1387 # opreport -t 0.5 --exclude-dependent
1388 # opreport -t 0.5 /path/to/executable_to_check
1389 # opannotate -t 0.5 --source --assembly
1391 Install ATI's fglrx driver for Xorg / X.org:
1393 Usually there already exist drivers for the grml-system:
1394 # apt-get update ; apt-get install fglrx-driver fglrx-kernel-`uname -r`
1396 After installing adjust xorg.conf via running:
1397 # aticonfig --initial --input=/etc/X11/xorg.conf
1399 For more information take a look at http://wiki.grml.org/doku.php?id=ati
1401 Install nvidia driver for Xorg / X.org:
1403 Usually there already exist drivers for the grml-system:
1404 # apt-get update ; apt-get install nvidia-glx nvidia-kernel-`uname -r`
1406 Then switch from module nv to nvidia:
1408 # sed -i 's/Driver.*nv.*/Driver "nvidia"/' /etc/X11/xorg.conf
1410 glxgears - a GLX demo that draws three rotating gears
1412 To print frames per second (fps) use:
1413 % glxgears -printfps
1415 You forgot to boot with 'grml noeject noprompt' to avoid
1416 ejecting and prompting for CD removal when rebooting/halting
1427 If you want to avoid only the prompting part, run:
1435 Mount wikipedia local via fuse:
1437 Adjust configuration:
1438 % cat ~/.wikipediafs/config.xml
1441 <article-cache-time>300</article-cache-time>
1445 <dirname>wikipedia-de</dirname>
1446 <host>de.wikipedia.org</host>
1447 <basename>/w/index.php</basename>
1450 <dirname>wikipedia-en</dirname>
1451 <host>en.wikipedia.org</host>
1452 <basename>/w/index.php</basename>
1457 Mount it (/wiki must exist of course):
1458 % mount.wikipediafs /wiki
1459 % cat /wiki/wikipedia-en/Cat
1462 % fusermount -u /wiki
1464 Remote notification on X via osd (on screen display):
1466 Start osd_server.py at your local host (listens on port 1234 by default):
1469 Then login to a $REMOTEHOST
1470 % ssh -R 1234:localhost:1234 $REMOTEHOST
1472 Now send the text to your local display via running something like:
1473 % echo "text to send" | nc localhost 1234
1475 Very useful when you are waiting for a long running job
1476 but want to do something else in the meanwhile:
1478 % ./configure && make && echo "finished compiling" | netcat localhost 1234
1480 You can use this in external programs as well of course. Examples:
1482 Use osd in centericq:
1484 % cat ~/.centericq/external
1493 if [ -x /usr/bin/socat -a -x /bin/netcat ] ; then
1494 CONTACT_CUSTOM_NICK=$(cat ${CONTACT_INFODIR}/info | head -n 46 | tail -n 1)
1495 osd_msg="*** CenterICQ: new ${EVENT_NETWORK} ${EVENT_TYPE} from ${CONTACT_CUSTOM_NICK} ***"
1496 if echo | socat - TCP4:localhost:1234 &>/dev/null ; then
1497 echo "${osd_msg}" | netcat localhost 1234
1501 Use it in the IRC console client irssi via running:
1505 You can even activate the port forwarding by default globally:
1510 RemoteForward 1234 127.0.0.1:1234
1513 Avoid automatical startup of init scripts via invoke-rc.d:
1515 First of all make sure the package policyrcd-script-zg2 (which
1516 provides the /usr/sbin/policy-rc.d interface) is installed.
1518 In policyrcd-script-zg2's configuration file named
1519 /etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
1520 defined as the interface for handling invoke-rc.d's startup policy.
1522 grml-policy-rc.d can be configure via /etc/policy-rc.d.conf. By
1523 default you won't notice any differences to Debian's default
1524 behaviour, except that invoke-rc.d won't be executed if a chroot has
1525 been detected (detection: /proc is missing).
1527 If you want to disable automatical startup of newly installed packages
1528 (done via the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
1529 /etc/policy-rc.d.conf.
1531 To restore the default behaviour set EXITSTATUS back to '0' in
1532 /etc/policy-rc.d.conf.
1534 Install VMware-Tools for grml:
1536 First of all make sure a CD-ROM device in VMware is available.
1538 Mount the CD-ROM device to /mnt/cdrom, then unpack and install
1542 unp /mnt/cdrom/vmware-linux-tools.tar.gz
1543 cd vmware-tools-distrib
1546 /etc/init.d/networking stop
1551 /etc/init.d/networking start
1553 In an X terminal, launch the VMware Tools running:
1557 Some important Postfix stuff
1565 Send all messages in the queue:
1569 Send all messages in the queue for a specific site:
1573 Delete a specific message
1574 # postsuper -d 12345678942
1576 Deletes all messages held in the queue for later delivery
1577 # postsuper -d ALL deferred
1579 Mail queues in postfix:
1581 incoming -> mail who just entered the system
1582 active -> mail to be delivered
1583 deferred -> mail to be delivered later because there were problems
1584 hold -> mail that should not be delivered until released from hold
1586 For configuration of postfix take a look at
1587 /etc/postfix/master.cf - man 5 master
1588 /etc/postfix/main.cf - man 5 postconf
1589 and http://www.postfix.org/documentation.html.
1593 mode 4000 - set user ID (suid):
1595 - for executable files: run as the user who owns the file, instead of the
1596 user who runs the file
1597 - for directories: not used
1599 mode 2000 - set group ID (guid):
1601 - for executable files: run as the group who owns the file, instead of the
1602 group of the user who runs the file
1603 - for directories: when a file is created inside the directory, it belongs
1604 to the group of the directory instead of the default group of the user who
1607 mode 1000 - sticky bit:
1609 - for files: not used
1610 - for directories: only the owner of a file can delete or rename the file
1612 Create MySQL database
1614 # apt-get install mysql-client mysql-server
1616 Run 'mysql' as root - create a database with:
1618 create database grml
1620 Give a user access to the database (without password):
1622 grant all on grml.* to mika;
1624 Give a user access to the database (with password):
1626 grant all on grml.* to enrico identified by "PASSWORD";
1628 Setup an HTTPS website:
1630 create a certificate:
1632 /usr/sbin/apache2-ssl-certificate -days 365
1634 Create a virtual host on port 443:
1636 <VirtualHost www.foo.invalid:443>
1640 Enable SSL in the VirtualHost:
1643 SSLCertificateFile /etc/apache2/ssl/apache.pem
1645 Enable listening on the HTTPS port (/etc/apache2/ports.conf):
1649 Useful Apache / Apache2 stuff
1651 Check configuration file via running:
1653 # apache2ctl configtest
1661 # a2enmod modulename
1663 Create tar archive and store it on remote machine:
1665 % tar zcf - /sourcedir | ssh user@targethost "cat >file.tgz"
1667 Pick out and displays images from network traffic:
1671 Install Flash plugin:
1673 # dpkg-reconfigure flashplugin-nonfree
1675 To test a proxy, low level way:
1679 GET http://www.google.com HTTP/1.0 [press enter twice]
1681 Adjust system for use of qemu with kqemu:
1683 Make sure you have all you need:
1684 # apt-get update ; apt-get install qemu grml-kerneladdons
1689 mknod /dev/kqemu c 250 0
1690 chmod 666 /dev/kqemu
1691 chmod 666 /dev/net/tun
1693 Check kqemu support via starting qemu, press
1694 Ctrl-Alt-2 and entering 'info kqemu'.
1696 (High-Load) Debugging related tools:
1698 mpstat # report processors related statistics
1699 iostat # report CPU statistics and input/output statistics for devices and partitions
1700 vmstat # report virtual memory statistics
1701 slabtop # display kernel slab cache information in real time
1702 atsar # system activity report
1703 dstat # versatile tool for generating system resource statistics
1714 Using WPA for network setup manually:
1716 # wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
1718 Adjust the options and configuration file to your needs.
1719 Also take a look at 'grml-network'.
1721 Start X and lock console via exiting:
1723 % startx 2>~/.xsession-errors &| exit
1725 Which process is writing to disk?
1727 # echo 1 > /proc/sys/vm/block_dump
1729 Warning: you must disable syslogd before you do this, or you must
1730 make sure that kernel output is not logged.
1732 When you're done, disable block dump using:
1733 # echo 0 > /proc/sys/vm/block_dump
1736 laptop-mode-tools provides a tool named lm-profiler (laptop mode profiler)
1737 which handles block_dump on its own.
1739 Install initrd via initramfs-tools for currently running kernel:
1741 # update-initramfs -u -t -k $(uname -r)
1743 Install initrd via yaird for currently running kernel:
1745 # yaird -o /boot/initrd.img-$(uname -r)
1747 Install initrd via yaird for specific kernel:
1751 # yaird -o /boot/initrd.img-2.6.15-1-686 2.6.15-1-686
1753 Reinstall package with its original configuration files:
1755 # apt-get install --reinstall -o DPkg::Options::=--force-confmiss -o \
1756 DPkg::Options::=--force-confnew package
1758 grml 0.8 funkenzutzler - rt2x00 drivers:
1760 To avoid conflicts with the other rt2x00-drivers the package rt2x00 (which
1761 includes beta-version drivers) is not installed by default. If you want to
1762 use the kernel modules rt2400pci, rt2500pci, rt2500usb, rt61pci and/or
1763 rt73usb please install the package manually running:
1765 # dpkg -i /usr/src/rt2x00-modules-*.deb
1767 Use Java with jikes and jamvm on grml:
1771 % cp /usr/share/doc/grml-templates/template.java .
1772 % jikes template.java
1775 Notice that grml exports $JIKESPATH (/usr/share/classpath/glibj.zip),
1776 so you do not have to manually run
1777 jikes --bootclasspath /usr/share/classpath/glibj.zip
1779 Online resizing of (Software-)RAID5:
1781 # Initiate a RAID5 setup for testing purposes:
1782 mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/hda1 /dev/hdb1 /dev/hdd1
1784 # Create filesystem, mount md0, create a testfile and save md5sum for
1787 mount /dev/md0 /mnt/test
1788 dd if=/dev/urandom of=/mnt/test/dd bs=512 count=10000
1789 md5sum /mnt/test/dd > md5sum
1791 # Make sure the RAID is synched via checking:
1794 # Now remove one partition:
1795 mdadm /dev/md0 --fail /dev/hdd1 --remove /dev/hdd1
1797 # Delete partition, create a new + bigger one and set partition type to fd
1798 # (Linux raid autodetect):
1801 # And re-add the partition:
1802 mdadm -a /dev/md0 /dev/hdd1
1804 # Make sure the RAID is synched via checking:
1807 # Repeat the steps for all other disks/partitions as well:
1808 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
1810 mdadm -a /dev/md0 /dev/hdb1
1812 mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
1814 mdadm -a /dev/md0 /dev/hda1
1817 # Now resize the RAID5 system online [see 'man mdadm' for details]:
1818 mdadm --detail /dev/md0 | grep -e 'Array Size' -e 'Device Size'
1819 mdadm --grow /dev/md0 -z max
1820 mdadm --detail /dev/md0 | grep -e "Array Size" -e 'Device Size'
1822 # Last step - resize the filesystem (online again):
1825 ext3 online resizing:
1827 Starting with Linux kernel 2.6.10 you can resize ext3 online. With
1828 e2fsprogs >=1.39-1 new filesystems are created with directory indexing and
1829 on-line resizing enabled by default (see /etc/mke2fs.conf).
1833 cfdisk /dev/hda # create a partition with type 8e (lvm)
1834 pvcreate /dev/hda2 # create a physical volume
1835 vgcreate resize_me /dev/hda2 # create volume group
1836 lvcreate -n resize_me -L100 resize_me # create a logical volume
1837 mkfs.ext3 /dev/resize_me/resize_me # now create a new filesystem
1838 mount /dev/resize_me/resize_me /mnt/test # mount the new fs for demonstrating online resizing
1839 df -h # check the size of the partition
1840 lvextend -L+100M /dev/resize_me/resize_me # let's extend the logical volume
1841 resize2fs /dev/resize_me/resize_me # and finally resize the filesystem
1842 df -h # recheck the size of the partition
1844 This also works for Software-RAID. Demo:
1846 mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda2 /dev/hdb1
1848 mount /dev/md0 /mnt/test
1849 mdadm /dev/md0 --fail /dev/hda2 --remove /dev/hda2
1850 cfdisk /dev/hda # adjust partition size for hda2
1851 mdadm /dev/md0 --add /dev/hda2
1852 mdadm /dev/md0 --fail /dev/hdb1 --remove /dev/hdb1
1853 cfdisk /dev/hdb # adjust partition size for hdb1
1854 mdadm /dev/md0 --add /dev/hdb1
1855 mdadm --grow /dev/md0 --size=max
1858 Notice: online resizing works as soon as the kernel can re-read the
1859 partition table. So it works for example with LVM and SW-RAID but not with
1860 a plain device (/dev/[sh]d*). The kernel does not re-read the partition
1861 table if the device is already mounted.
1863 Use vim as an outline editor:
1865 % $PAGER /usr/share/doc/vim-vimoutliner/README.Debian
1869 Monitor directories/files for changes using iwatch
1871 Monitor /tmp for changes:
1874 Monitor files/directories specified in /etc/iwatch.xml
1875 and send mail on changes:
1878 Some often used mdadm commands:
1881 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1
1883 Display details of specific RAID:
1884 # mdadm --detail /dev/md0
1887 Simulating a drive failure by software:
1888 # mdadm --manage --set-faulty /dev/md0 /dev/hda1
1890 Remove disk from RAID:
1891 # mdadm /dev/md0 -r /dev/hda1
1893 Set disk as faulty and remove from RAID:
1894 # mdadm /dev/md0 --fail /dev/hda1 --remove /dev/hda1
1899 Restart a RAID-device:
1902 Add another disk to existing RAID setup (hotadd):
1903 # mdadm /dev/md0 -a /dev/hde1
1904 # mdadm --grow /dev/md0 --raid-devices=4
1906 Assemble and start all arrays:
1907 # mdadm --assemble --scan
1909 Assemble a specific array:
1910 # mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1
1913 # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda1 /dev/sda2
1916 # mdadm --stop --scan
1917 # mdadm --assemble /dev/md0 --auto --scan --update=summaries --verbose
1919 Monitoring the sw raid
1920 # nohup mdadm --monitor --mail=root@localhost --delay=300 /dev/md0
1922 See also: man mdadm | less -p "^EXAMPLES"
1923 http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html
1925 A quick summary of the most commonly used RAID levels:
1928 => 2 disks each 160 GB: 320 GB data
1929 RAID 1: Mirrored Set
1930 => 2 disks each 160 GB: 160 GB data
1931 RAID 5: Striped Set with Parity
1932 => 3 disks each 160 GB: 320 GB data; 160 GB redundancy
1934 Common nested RAID levels:
1935 RAID 01: A mirror of stripes
1936 RAID 10: A stripe of mirrors
1937 RAID 30: A stripe across dedicated parity RAID systems
1938 RAID 100: A stripe of a stripe of mirrors
1940 -- http://en.wikipedia.org/wiki/RAID
1942 Logical Volume Management (LVM) with Linux
1947 | hda1 hdc1 (PV:s on partitions or whole disks)
1953 | usrlv rootlv varlv (LV:s)
1955 | ext3 ext3 xfs (filesystems)
1957 Often used commands:
1958 ~~~~~~~~~~~~~~~~~~~~
1960 Create a physical volume:
1961 # pvcreate /dev/hda2
1963 Create a volume group:
1964 # vgcreate testvg /dev/hda2
1966 Create a logical volume:
1967 # lvcreate -n test_lv -L100 testvg
1969 Resize a logical volume:
1970 # lvextend -L+100M /dev/resize_me/resize_me
1971 # resize2fs /dev/resize_me/resize_me # ext2/3
1972 # xfs_growfs /dev/resize_me/resize_me # xfs
1973 # resize_reiserfs -f /dev/resize_me/resize_me # reiserfs online
1974 # mount -o remount,resize /dev/resize_me/resize_me # jfs
1976 Create a snapshot of a logical volume:
1977 # lvcreate -L 500M --snapshot -n mysnap /dev/testvg/test_lv
1979 Deactivate a volume group:
1980 # vgchange -a n my_volume_group
1982 Actually remove a volume group:
1983 # vgremove my_volume_group
1985 Display information about physical volume:
1986 # pvdisplay /dev/hda1
1988 Remove physical volume:
1989 # vgreduce my_volume_group /dev/hda1
1991 Remove logical volume:
1992 # umount /dev/myvg/homevol
1993 # lvremove /dev/myvg/homevol
1996 http://www.tldp.org/HOWTO/LVM-HOWTO/
1998 How to use APT locally
2000 Sometimes you have lots of packages .deb that you would like to use APT to
2001 install so that the dependencies would be automatically solved. Solution:
2004 dpkg-scanpackages debs /dev/null | gzip > debs/Packages.gz
2005 echo " deb file:/root debs/" >> /etc/apt/sources.list
2006 dpkg-scansources debs | gzip > debs/Sources.gz
2007 echo " deb-src file:/root debs/" >> /etc/apt/sources.list
2009 See also: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html
2011 Check filesystem's LABEL:
2014 # vol_id -l /dev/sda1
2016 ext2/3 without vol_id:
2017 # dumpe2fs /dev/sda1 | grep "Filesystem volume name"
2020 # xfs_admin -l /dev/sda1
2022 reiserfs without vol_id:
2023 # debugreiserfs /dev/sda1 | grep UUID
2025 reiser4 without vol_id:
2026 # debugfs.reiser4 /dev/sda1 | grep uuid
2028 Check filesystem's UUID:
2031 # vol_id -u /dev/sda1
2033 ext2/3 without vol_id:
2034 # dumpe2fs /dev/sda1 | grep UUID
2037 # xfs_admin -u /dev/sda1
2039 reiserfs without vol_id:
2040 # debugreiserfs /dev/sda1 | grep LABEL
2042 reiser4 without vol_id:
2043 # debugfs.reiser4 /dev/sda1 | grep label
2045 Disable pdiffs feature of APT:
2048 # echo 'Acquire::PDiffs "false";' >> /etc/apt/apt.conf
2051 # apt-get update -o Acquire::Pdiffs=false
2053 Backup big devices or files and create compressed splitted
2054 image chunks of it using zsplit
2056 Create backup of /dev/sda named archiveofsda_#.spl.zp in directory
2057 /mnt/sda1/backup, split the files up into chunks of 1GB each and set
2058 read/write buffer to 256kB:
2059 # zsplit -b 256 -N archiveofsda -o /mnt/sda1/backup/ -s 1G /dev/sda
2061 Restore the backup using unzsplit:
2062 # unzsplit -D /dev/sda -d archiveofsda
2064 More usage examples: man zsplit + man unzsplit
2066 Measure network performance using ipserf
2072 % iperf -c <server_address> -V
2076 Server with 128k TCP window size:
2079 Client with running for 60 seconds and bidirectional test:
2080 % iperf -c <server_address> -r -w128k -t60
2082 Framebuffer resolutions:
2084 Resolution in pixels
2085 Color depth | 640x480 800x600 1024x768 1280x1024
2086 256 (8bit)| 769 771 773 775
2087 32000 (15bit)| 784 787 790 793
2088 65000 (16bit)| 785 788 791 794
2089 16.7 Mill.(24bit)| 786 789 792 795
2093 Mode 0x0300: 640x400 (+640), 8 bits
2094 Mode 0x0301: 640x480 (+640), 8 bits
2095 Mode 0x0303: 800x600 (+800), 8 bits
2096 Mode 0x0303: 800x600 (+832), 8 bits
2097 Mode 0x0305: 1024x768 (+1024), 8 bits
2098 Mode 0x0307: 1280x1024 (+1280), 8 bits
2099 Mode 0x030e: 320x200 (+640), 16 bits
2100 Mode 0x030f: 320x200 (+1280), 24 bits
2101 Mode 0x0311: 640x480 (+1280), 16 bits
2102 Mode 0x0312: 640x480 (+2560), 24 bits
2103 Mode 0x0314: 800x600 (+1600), 16 bits
2104 Mode 0x0315: 800x600 (+3200), 24 bits
2105 Mode 0x0317: 1024x768 (+2048), 16 bits
2106 Mode 0x0318: 1024x768 (+4096), 24 bits
2107 Mode 0x031a: 1280x1024 (+2560), 16 bits
2108 Mode 0x031b: 1280x1024 (+5120), 24 bits
2109 Mode 0x0330: 320x200 (+320), 8 bits
2110 Mode 0x0331: 320x400 (+320), 8 bits
2111 Mode 0x0332: 320x400 (+640), 16 bits
2112 Mode 0x0333: 320x400 (+1280), 24 bits
2113 Mode 0x0334: 320x240 (+320), 8 bits
2114 Mode 0x0335: 320x240 (+640), 16 bits
2115 Mode 0x0336: 320x240 (+1280), 24 bits
2116 Mode 0x033c: 1400x1050 (+1408), 8 bits
2117 Mode 0x033d: 640x400 (+1280), 16 bits
2118 Mode 0x033e: 640x400 (+2560), 24 bits
2119 Mode 0x0345: 1600x1200 (+1600), 8 bits
2120 Mode 0x0346: 1600x1200 (+3200), 16 bits
2121 Mode 0x034d: 1400x1050 (+2816), 16 bits
2122 Mode 0x035c: 1400x1050 (+5632), 24 bits
2124 Portscan using netcat:
2126 # netcat -v -w2 <host|ip-addr.> 1-1024
2128 Run apt-get but disable apt-listchanges:
2130 APT_LISTCHANGES_FRONTEND=none apt-get ...
2132 Upgrade system but disable apt-listbugs:
2134 APT_LISTBUGS_FRONTEND=none apt-get ...
2136 Set up a Transparent Debian Proxy
2138 Install of apt-cacher, the default config will do:
2139 # apt-get install apt-cacher
2141 Check out the ip address of debian mirror(s).
2142 Then add this to your firewall script:
2144 DEBIAN_MIRRORS="141.76.2.4 213.129.232.18"
2145 for ip in ${DEBIAN_MIRRORS} ; do
2146 ${IPTABLES} -t nat -A PREROUTING -s $subnet -d $ip -p tcp --dport 80 -j REDIRECT --to-port 3142
2149 where ${IPTABLES} is the location of your iptables binary
2150 and $subnet is your internal subnet.
2152 Now everybody in your subnet who does access either
2153 ftp.de.debian.org or ftp.at.debian.org will actually
2154 access your apt-cacher instead.
2156 To use apt-cacher on the router itself, add the following
2157 line to your /etc/apt/apt.conf:
2159 Acquire::http::Proxy "http://localhost:3142/";
2161 Version control using Mercurial
2163 Setting up a Mercurial project:
2166 % hg init # creates .hg
2167 % hg add # add all files
2168 % hg commit # commit all changes, edit changelog entry
2170 Branching and merging:
2172 % hg clone linux linux-work # create a new branch
2177 % hg pull ../linux-work # pull changesets from linux-work
2178 % hg merge # merge the new tip from linux-work into
2179 # (old versions used "hg update -m" instead)
2180 # our working directory
2181 % hg commit # commit the result of the merge
2185 % cat ../p/patchlist | xargs hg import -p1 -b ../p
2193 % hg export 1234 > foo.patch # export changeset 1234
2195 Export your current repo via HTTP with browsable interface:
2197 % hg serve -n "My repo" -p 80
2199 Pushing changes to a remote repo with SSH:
2201 % hg push ssh://user@example.com/~/hg/
2203 Merge changes from a remote machine:
2205 host1% hg pull http://foo/
2206 host2% hg merge # merge changes into your working directory
2208 Set up a CGI server on your webserver:
2209 % cp hgwebdir.cgi ~/public_html/hg/index.cgi
2210 % $EDITOR ~/public_html/hg/index.cgi # adjust the defaults
2212 Mercurial repositories of grml can be found at http://hg.grml.org/