____              _ _ _                            _        _         __
  _   / / /_ _ _ __   __| (_) | ___ _ __  _ __   ___ _ __| |_   __| | ___   / /
 (_) / / / _` | '_ \ / _` | | |/ _ \ '_ \| '_ \ / _ \ '__| __| / _` |/ _ \ / /
  _ / / / (_| | | | | (_| | | |  __/ |_) | |_) |  __/ |  | |_ | (_| |  __// /
 (_)_/_/ \__,_|_| |_|\__,_|_|_|\___| .__/| .__/ \___|_|   \__(_)__,_|\___/_/
                                   |_|   |_|
Alsa | Apache | Bash | Burn | Centericq | Firefox | Gentoo | Gimp | hdparm | ImageMagick | Irssi | Latex | Linux | Mail Setup | mail | Midnight Commander | Mplayer | Muttprint | Nameserver | NFS | Nmap | Open Office | Perl | PHP | Psutils | Root-Tail | Samba | Screen | smart | SPIM | SSH | Syslog-ng | Uni | Vim | Webalizer | Xmonad | Xorg | Zip


Alsa

Correct setting for sound with Thinkpads (1st Oct'07)

Don't know why, but there is something special in alsamixer with all Txx laptops. To hear music you have to mute "headphone jack" and "line jack sense".


Command line interface for alsa driver (4th Oct'07)

There are several commands on the CLI to control the alsa driver:
amixer -c 0 set PCM unmute 5dB-
amixer -c 0 set PCM unmute 5dB+
amixer -c 0 set PCM mute

Apache

Protection using .htaccess and .htpasswd (long time ago ...)

Create an .htaccess file in the directory you want to protect and write this into it:
AuthUserFile /server/path/.htpasswd
AuthName "password protected section"
AuthType Basic
require valid-user
Run htpasswd2 -c /server/path/.htpasswd user for the first user and remove -c for more users.

Bash

short liners (18th Oct'07)

For each pdf-file in the directory, make a new one with eight pages on one side to get more slided on one page.
for i in *.pdf; do acroread -toPostScript -level3 -size letter -landscape $i; psnup -l -h29.7cm -w21cm -m0.5cm -pletter -d -8 `basename $i pdf`ps output.ps; ps2pdf14 output.ps $i; done

Instead of acroread you can also use the free pdftops utility:
for i in *.pdf; do pdftops $i; psnup -l -h29.7cm -w21cm -m0.5cm -pletter -d -8 `basename $i pdf`ps output.ps; ps2pdf14 output.ps $i; done


Convert pictures to new ones with a fix resolution:
for i in *.JPG; do convert -resize 800x600 $i `basename $i JPG`jpg; done;


Rename all files in the current directory whereby all upper letters are transformed into lower ones:
for i in *; do mv "$i" "`echo $i | tr [:upper:] [:lower:]`"; done;


Set empty id3-tags for mp3-files using audiotag (there is a better solution for this with id3ed):
audiotag -T 1 -A " " -a " " -c " " -g 0 -t " " -y 2005


Encode wav-files into mp3-files:
for i in *.wav; do lame -h $i `basename $i wav`mp3; done;


Introduction to the built-in find command (self-explanatory):
find . -user andi

find . -group andi

find . -type x (whereby x is one of d,l,f,s (directory, links, files, sockets))

find ~/Movies -size +1024M

normally, every combination is AND'ed:
you can use -or / ! to OR / negate search criteria

find all files in /etc owned by root that have been modified within the last day:
find /etc -user root -mtime -1 

same with -atime, -ctime, -mtime
-amin, -cmin, -mmin

-nouser shows output that's not associated with an existing userid
-nogroup: same for groups

-links n: file has n links

-newer file: file was modified more recently than file

-perm mode: file has mode permissions

find / -nouser -print0 | xargs -0 rm

verify whether a file is referenced
find / -type l -print | perl -nle '-e || print'


You can search with grep for several alternatives:
grep -E "Text1|Text2" * sucht nach den beiden Alternativen


Show incoming / outgoing network traffic:
/sbin/ifconfig $INTERFACE | sed -n 's/.*RX bytes:[^(]*(\([^)]*\)).*/\1/p'
/sbin/ifconfig $INTERFACE | sed -n 's/.*TX bytes:[^(]*(\([^)]*\)).*/\1/p'


Show current associated IP addresses:
/sbin/ifconfig $DEVICE | awk '/inet/ { print $2 } ' | sed -e s/addr://


Find out the MAC address:
nmap -sP 193.170.227.0/21 && arp -a > textfile


Find out the date of installation of your system:
ls - -sort=t /dev -l | tail -n1 | awk '{print $8 " " $7 " " $9}'


Checkout a svn - repository:
svn checkout http://svn.ipd.uni-karlsruhe.de/repos/swt/swt/material07/


Printing in the ATIS:
lpr -Pi08pr_sw1 -o sides=two-sided-long-edge foobar.txt


Printing on a windows printer using Samba
device URI: smb://BLABLA/HL1430 or
smb://wudmx:osirus@BLABLA/HL1430

In /etc/hosts there should be something like:
192.168.0.99 BLABLA


Converting dos files into unix ones:
dos2unix -p */*.txt



Colors in Bash (20th Oct'07)

Colors can be print in bash using special ASCII-sequences. It has to begin with an ASCII-ESC (octal value is \033).
echo -e "\033[1;34mHello foobar!"
The structure is: at first, the ESC character as mentioned above

Then follows a text decoration encoding (here the 1): 0=none, 1=bold, 4=underlined, 5=blinking, 7=inversed

The semicolon is a delimiter. After that one can express colors: 30=black, 31=red, 32=green, 33=yellow, 34=blue, 35=violett, 36=cyan, 37=white. The m after the color is always there after a color name.

Example:
export PS1="\[\033[1;33m\](\A) \u@\h:\w\$\[\033[0m "

Burn VDs / DVDs / SVCDs

Burning a SVCD under Linux (long time ago ...)

After searching on the web for specific information about making a svcd out of an avi-file, I almost had enough and was about to quit the project. Some more researching and I found out an easy way to create such a cd which appears correctly on my PAL-TV with aspect ratio 4:3.

The first thing is the most important one: the creation of a svcd-valid mpg-file. A video cd is only a svcd, if the resolution of the video is exactly 480x576. This is only right for PAL-SVCD, look at wikipedia for more information. Since most video files have different resolutions, we have to give ffmpeg, the mpg-encoder program, some crucial options.

So let's compute the necessary parameters. We need pads at the top and bottom to get the correct aspect ratio 4:3. But how high should these pads be? A little computation and we're on our way. Open the original video file with mplayer and read out the resolution of this file. For example I can read this at the very beginning of the mplayer output:

VIDEO: [XVID] 448x336 12bpp 25.000 fps 1498.7 kbps (182.9 kbyte/s)

So the resolution is 448x336, but we need 480x576. Let's increase the x-value to 480. In order we get the correct aspect ratio of 4:3 or 1.3333, we need a y-value of 360 (since 480/360 = 4/3). The rest (576-360 = 216) is our pad. 108 at the top and 108 at the bottom. This is all we need.

ffmpeg -i inputfile -target pal-svcd -aspect 4:3 -s 480x360 -padtop 108 -padbottom 108 output.mpg

This will take a lot of time if your inputfile has normal size. If you just want to test your correct settings, you can tell ffmpeg to only work with a piece of the input file. Just add -ss 00:00:00 -t 00:01:00.

View your newly created mpg-file with mplayer to see if your resolution (480x576) and your aspect ratio (4:3) is correct!

Now we can create a svcd using vcdimager:

vcdimager -t svcd -l "title" output.mpg

This will create a videocd.bin and videocd.cue which you can burn with cdrdao:

cdrdao write --device ATAPI:0,0,0 videocd.cue

If your output.mpg is too large for one svcd, you have to split it using mpgtx:

mpgtx -3 output.mpg -b m

This will create three mpgs out of output.mpg. After that proceed with vcdimager for each file.

gentoo-wiki.com/HOWTO_Create_a_VCD_or_SVCD



mp3 to Audio CD (long time ago ...)

#!/bin/bash
for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
for i in *.mp3; do lame --decode "$i" "`basename "$i" .mp3`.wav"; done
normalize *.wav
echo CD_DA > cd
for x in *.wav; do echo "
TRACK AUDIO
AUDIOFILE \"$x\" 0" >> cd; done;

After that use cdrdao and the newly created file cd to burn the tracks on cd:
cdrdao write --device ATAPI:0,0,0 cd



Turn your PC into a Videorecorder (long time ago ...)

lspci -v output:
00:0a.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 02)
Subsystem: Hauppauge computer works Inc. WinTV Series
Flags: bus master, medium devsel, latency 64, IRQ 10
Memory at dddfc000 (32-bit, prefetchable) [size=4K]

00:0a.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 02)
Subsystem: Hauppauge computer works Inc. WinTV Series
Flags: bus master, medium devsel, latency 64, IRQ 10
Memory at dddfd000 (32-bit, prefetchable) [size=4K]

Kernel options:
Device Drivers --->
 I2C Support --->
  <*> I2C Support
  <*> I2C device interface
   I2C algorithms --->
    I2C bit-banging interfaces
    I2C PCF 8584 interfaces
    I2C PCA 9564 interfaces
  I2C Hardware Bus support --->
    VIA 82C596/82C686/823x
 Multimedia devices --->
  <*> Video For Linux
  [*]   Enable Video For Linux API 1 (DEPRECATED)
  Video Capture Adapters ---> 
    BT848 Video For Linux
 Sound --->
   Sound card support
  Advanced Linux Sound Architecture --->
    Advanced Linux Sound Architecture
      Sequencer support
      OSS Mixer API
      OSS PCM (digital audio) API
   [*]     OSS PCM (digital audio) API - Include plugin system
   [*]   OSS Sequencer API
   [*]   Verbose procfs contents
    Bt87x Audio Capture
    (Creative) Ensoniq AudioPCI 1371/1373
    VIA 82C686A/B, 8233/8235 AC97 Controller

The following should be installed after kernel cooking:
/lib/modules/2.6.17.6/kernel/sound/pci/snd-bt87x.ko
/lib/modules/2.6.17.6/kernel/drivers/i2c/algos/i2c-algo-pca.ko
/lib/modules/2.6.17.6/kernel/drivers/i2c/algos/i2c-algo-pcf.ko
/lib/modules/2.6.17.6/kernel/drivers/i2c/algos/i2c-algo-bit.ko
/lib/modules/2.6.17.6/kernel/drivers/i2c/busses/i2c-viapro.ko
/lib/modules/2.6.17.6/kernel/drivers/media/video/bt8xx/bttv.ko

Add snd-bt87x and bttv to your /etc/modules.autoload.d/kernel-2.6. After rebooting, check dmesg | grep bttv. It should give you something like this:
bttv: driver version 0.9.16 loaded
bttv: using 8 buffers with 2080k (520 pages) each for capture
bttv: Bt8xx card found (0).
bttv0: Bt878 (rev 2) at 0000:00:0a.0, irq: 10, latency: 64, mmio: 0xdddfc000
bttv0: detected: Hauppauge WinTV [card=10], PCI subsystem ID is 0070:13eb
bttv0: using: Hauppauge (bt878) [card=10,insmod option]
bttv0: gpio: en=00000000, out=00000000 in=00ffffdb [init]
bttv0: Hauppauge/Voodoo msp34xx: reset line init [5]
bttv0: Hauppauge eeprom indicates model#61324
bttv0: using tuner=1
bttv0: i2c: checking for MSP34xx @ 0x80... found
bttv0: i2c: checking for TDA9875 @ 0xb0... not found
bttv0: i2c: checking for TDA7432 @ 0x8a... not found
bttv0: i2c: checking for TDA9887 @ 0x86... not found
bttv0: registered device video0
bttv0: registered device vbi0
bttv0: registered device radio0
bttv0: PLL: 28636363 => 35468950 .. ok

If you do not get similar lines (or only the first two lines), then there is something missing! Check your card, if it is plugged in the PCI slot correctly! Check your I2C-chipset driver (i2c-viapro is mine). And try looking up your card in /usr/src/linux/Documentation/video4linux/CARDLIST.bttv and /usr/src/linux/Documentation/video4linux/CARDLIST.tuner and load your bttv with modprobe bttv card=10 tuner=1 (these are my values). By the way, you can read /usr/src/linux/Documentation/sound/alsa/Bt87x.txt which will give you important notes for your audio output (if you need a cable or not).

Well, after everything went right after some hours :), I wanted more than just watching. mplayer is my favorite app for watching and recording TV. Run arecord -l and arecord -L and check whether the information is correct. If not, create a file called ~/.asoundrc and put this in it:
pcm.es1371 {
type hw
card 0
}

ctl.es1371 {
type hw
card 0
}

pcm.bt87x {
type hw
card 1
}

ctl.bt87x {
type hw
card 1
}
You can also check whether the /dev/v4l/ is created with files video0, vbi0 and radio0 in it. If not, you have to go back, because these are the device files for the programs following now! Install xdtv or tvtime to receive the frequencies of your television and to watch TV. Check tvwatch.sh and tvrecord.sh in the scripts section!



Burn a DVD Video (13th Oct'07)

First, install the necessary tools (we need mencoder which is part of mplayer - check that the USE-flag encode is set):
USE-Flags:
media-video/ffmpeg encode xvid
media-video/mplayer a52 alsa dvdread encode fbcon win32codecs xvid
media-video/transcode mjpeg mp3 mpeg xvid

emerge dvd+rw-tools mplayer transcode sox toolame ffmpeg mjpegtools dvdauthor
There is a great script called AviToVob which converts almost every video file into a mpeg movie file. You can download it avi2vob.shhere too. Keep in mind to adjust the ntsc / pal setting in the script!

Now run avi2vob which will create a mpeg movie file (please note: this will take hours!!!)
./avi2vob.sh videofile.avi


Now the movie has to be burned - but we need the DVD Video structure. dvdauthor does this for us - copy the dvdauthor into the folder where your mpeg movie is:

The following command creates the DVD video structure (a newly created DVD directory is generated):
dvdauthor -x dvdauthor.xml


And now, finally, burn the DVD:
growisofs -Z /dev/dvdrw -dvd-video DVD/


For more information check out these resources:
[1] HOWTO create a DVD
[2] HOWTO transcode DivX video to DVD
[3] HOWTO author DVD-Video under Linux



Burn using the commandline (19th Oct'07)

Note: delete the whitespace between the - in the command line options!
Make an iso-file:
mkisofs -iso-level 2 -r -o myiso.iso /home

Test burning:
cdrecord - -dummy - -dev=ATAPI:0,0,0 driveropts=burnfree foobar.iso

Burn my.iso:
cdrecord dev=ATAPI:/dev/hdc speed=16 driveropts=burnfree -dao -data -v my.iso

Burn tracks for an audio cd:
cdrecord dev=ATAPI:/dev/hdc speed=16 driveropts=audiomaster -audio -dao -pad -v track*.wav

Blank a CD-RW:
cdrecord - -dev=ATAPI:0,0,0 - -blank=fast

Burn a DVD:
growisofs -dvd-compat -Z /dev/cdroms/cdrom0=image.iso



How to convert a cue/img image to an iso image (20th Mar'08)

Install bchunk, rename the img-file to a bin-file and run bchunk as mentioned below:
bchunk file.bin file.cue file.iso



How to convert a ccd/sub/img image to an iso image (20th Mar'08)

Install ccd2iso and run it as mentioned below:
ccd2iso file.img file.iso



How to convert a nrg image to an iso image (20th Mar'08)

Install nrg2iso and run it as mentioned below:
nrg2iso file.img file.iso



Centericq

Blink when incoming message arrives (long time ago ...)

Nice script for people with a Thinkpad.
    %action Simple auto-responder
    event msg
    proto all
    status all

    %exec
    echo on > /proc/acpi/ibm/light
    sleep 0.125
    echo off > /proc/acpi/ibm/light
    sleep 0.125
    echo on > /proc/acpi/ibm/light
    sleep 0.125
    echo off > /proc/acpi/ibm/light


Firefox

dict.leo.org in toolbar (long time ago ...)

The auto-mechanism on dict.leo.org does not work yet. Get the leo.src and put it in /opt/firefox/searchplugins/ and also get an image file and store it as /opt/firefox/searchplugins/leo.gif.



Java in Firefox (long time ago ...)

If your java support in firefox is missing, check if you have enabled nsplugin for your java-sdk (e.g. sun-jdk). Then reinstall sun-jdk and firefox and use eselect java-nsplugin to activate one of your sdk's for firefox!



My favourite Extensions (29th Sep'07)

Wizz RSS News Reader, Video Downloader, Media Pirate, Tab Mix Plus, PDF Download, Netcraft Toolbar, InFormEnter, Fast Video Download, Down Them All, Vimperator



Opening a tab from console (4th Oct'07)

You can control firefox via a command line interface. To open a tab loading www.google.de, use this:
firefox -remote "OpenURL(http://linuxkp.org, new-tab)" or
firefox -remote "OpenURL(http://linuxkp.org, new-window)"



Using external mail program for mailto-links (10th Oct'07)

There is a nice way to call external applications when one is clicking on a mailto: link. Open the about:config in a new tab and search for network.protocol-handler.external.mailto - look if the value is true, if not toggle it to true.

Now create a new String (context menu) and name it network.protocol-handler.app.mailto with the value mailto.sh.

At last, create a file called mailto.sh, put the following lines into it and put the file into /usr/local/bin/. The file must be - of course - executable (chmod a+x mailto.sh):
#!/bin/sh
urxvt -e mutt "$1"
Click on a link and be happy with it - you just saved some copy-and-paste sessions! You can test it with this link.



Vimperator Extension (9th Mar'08)

The must-have extensions for all vimmers!

:set go=b (also possible: m,T, go = gui-options)
d and D to delete the current buffer and go the next / previous buffer
gh = go home, displays start page
P = open new tab with content of last selected text
gt / gT = go to next / previous tab
o = open new page in current buffer
t = open new page in new tab
r = reload
ZZ = save and close
gg / G = go to the beginning / end of the page
H / L = go one page back / forth
/ and ? = search forward / backward
n / N = go to next / previous found match



Firefox Searchplugins with mozilla-firefox-bin (3rd Apr'08)

While using the vimperator add-on it is really comfortable to google by pressing p, typing in google and then the words you are searching for. Firefox detects automatically to load www.google.de and searches for the given words. That's also possible for other sites like www.ebay.de or www.amazon.de. One disadvantage with the binary version of mozilla-firefox: you have to do the adjustments of the searchplugin XML files within the global /opt/firefox/searchplugins folder; it did not work by editing the files within ~/.mozilla/firefox/USER/searchplugins . Just edit the files and change the specific URLs - eventually, restart firefox and have some by saving more time with firefox, vimperator and your new searchplugins!


Gentoo

Clean up non-used packages (long time ago ...)

After a while, each system is full of software it doesn't use. With emerge --depclean it's possible to track down these packages - they will be removed instantly. However, do this only after an correct update like emerge --pretend --verbose --newuse --deep --update world. Now you can easily run emerge --depclean and finally revdep-rebuild.
emerge --newuse --deep --update --verbose --tree --ask world
emerge --depclean
revdep-rebuild


Important Gentoo files (long time ago ...)

/etc/portage/package.keywords
/etc/portage/package.unmask
/etc/portage/package.use
/var/lib/portage/world
/usr/portage/profiles/use.desc
/etc/make.conf
/etc/layman/layman.conf


Uninstall protected files while un-installing packages (long time ago ...)

Sometimes, an emerge -C package doesn't delete all installed files. Files in $CONFIG_PROTECT will not be touched. So this is the clean deinstalling mechanism:
CONFIG_PROTECT="-*" CONFIG_PROTECT_MASK="-*" emerge -Cv package 


Check your world file (long time ago ...)

You can check your world-file /var/lib/portage/world with the following command:
emaint --check world


Testing software (long time ago ...)

If you want to test a huge software with lots of dependencies, you can't just do an emerge -aC programname because the dependencies wouldn't be uninstalled. You could use emerge depclean, but there is another, cleaner and more secure way.

Let's say you want to test kdevelop - but you do not know whether you want to use it for a long time. So create the dependencies-file:
emerge kdevelop -p | 
sed -ne '/^\[ebuild[^]]*N[^]]*\]/{s/^\[ebuild[^]]\+\] ([^[:space:]]\+\).*$/=\1/;p}' \ 
> kdevelop.deps
This ensures that no packages are listed in the deps-file which has just been updated and not newly installed. If you want to get rid of kdevelop in the future, use this:
emerge -aC $(

		More infos on forums.gentoo.org

	


Setting up UTF-8 with Gentoo (1st Oct'07)

First, one has to specify locales for glibc. Add the locales into the /etc/locale.gen and run locale-gen afterwards.
en_US ISO-8859-1
en_US.UTF-8 UTF-8
de_DE ISO-8859-1
de_DE@euro ISO-8859-15
de_DE.UTF-8 UTF-8
Test with locale -a whether the locales were installed correctly and to list their correct names. It should something like that:
C
POSIX
de_DE
de_DE.utf8
de_DE@euro
en_US
en_US.utf8
Next, the environment variables LANG and LC_ALL have to be set to a correct UTF-value. This can be done for example in the /etc/env.d/02locale. Test with env-update && source /etc/profile && locale whether the output of the environment variables is correct.


Gimp

Darken an image (long time ago ...)

Open the image and go to Ebene - Farben - Kurven. Play with the curve to see the effects immediately. That saved me from hell,


hdparm

Using hdparm (long time ago ...)

Just run hdparm -Tt /dev/hda to get the current speed of your hard disk. After that you can tune it a bit: therefore, just run hdparm without any parameters on your hard disk: hdparm /dev/hda. This will print some attribute values (e.g. it will tell you whether DMA is activated or not).

multcount gives the number of sectors which should be read in with each I/O-interrupt. Possible values are normally 2, 4, 8, 16. You can get the value of your hard disk by running hdparm -i /dev/hda and reading the MaxMultSect value. But be cautious: this value is not always true, data loss could be the consequence. If you're trying it anyway, then do hdparm -mnum /dev/hda.

Another tuning parameter is the I/O-Support-Mode. This should be nowadays 3, so try -c3 and see man page for more infos.

The Using_dma flag can be enabled with -d1, -X66 tells the mode (which is here Ultra-DMA-Mode 2) and -u1 tells the controller driver to unmask other interrupts.

To keep the settings also if an IDE reset appears, add -k1 to your parameters.

If you have found your best configuration parameters for hdparm, write it to local.start so that it runs on each boot!



ImageMagick

Make a color transparent (long time ago ...)

Just do a convert -transparent black if you want to get the black color transparent.


Irssi

Hide parts/joins/kicks/quits messages (long time ago ...)

There is a built-in function called ignore to get rid of several lines in irssi (see /help ignore). Here some examples which should be self-explanatory:
/ignore #channel JOINS
/ignore ALL QUITS
Instead of JOINS and QUITS you can use one of the following levels:
CRAP, CTCPS, JOINS, PARTS, QUITS, KICKS, TOPICS, PUBLIC
SNOTES, NOTICES, MODES, DCC, NICKS, ACTIONS, WALLOPS, MSGS
INVITES, DCCMSGS, CLIENTNOTICE, CLIENTCRAP, CLIENTERROR
Another way to hide special lines use the script crapbuster.pl in the autorun folder and test it:
/script load autorun/crapbuster.pl
/set crapbuster_levels QUITS KICKS PARTS JOINS
If it works, add this line to the perl/core/scripts section of your irssi config:
crapbuster_levels = "QUITS KICKS PARTS JOINS"
The difference to ignore is that with crapbuster the lines arent hidden at once; instead you have to invoke /crapbuster. Have fun!


Let the ThinkLight blink! (long time ago ...)

IBM Laptops have the ThinkLight technology in their notebooks: you can use that as an information for incoming messages. Load the script beep_beep.pl in the autorun folder. In the core settings:
beep_msg_level = "PUBLIC MSGS";
And in the perl/core/scripts section:
beep_cmd = "echo on > /proc/acpi/ibm/light; sleep 0.1; echo off > /proc/acpi/ibm/light";
Keep in mind that you must have the permission to set the light file under /proc!


Latex

Print | in Latex (long time ago ...)

$\mid$ will print |



UTF-8 and latex files (long time ago ...)

There is a bug with utf8-encoded latex files - utf8.def is missing. Just invoke the following commands and the problem is gone:
cd /usr/share/texmf/tex/latex/latex-unicode/
ln -s utf8x.def utf8.def
texhash


Some Latex commandos one should know (1st Oct'07)

Add a math formula in the same line:
\( MATH-FORMULA \) 
Add an indented math formula:
\[ MATH-FORMULA \]
Adding vector arrow to a variable:
\( \vec{x} = ... \)
Using lower and higher indices:
\( x = x_{1} + x_{2}^{3} \)
What's the world without infinity...
\( \infty \)
And what about some Greek letters...
\( \alpha \beta \gamma \delta \epsilon \phi \psi ... \)
Fractions can also be displayed easily:
\( one half = \frac{1}{2} \)
A sum sign (look at the \limits):
\( \sum\limits_{i=0}^{10} i \)
An integral sign (look at the \limits):
\( \int\limits_{i=0}^{10} i \)


How to add new Latex Packages to the System (9th Mar'08)

Search your package with your favourite search engine: "ctan csquotes". Unpack it in /usr/share/texmf/tex/latex/csquotes and run texhash.


Linux System

Adding swap partition / file (long time ago ...)

For a swap partition just invoke the following command:
swapon /dev/hda9
For a swap file invoke these commands:
dd if=/dev/zero of=/swapfile bs=1024 count=65536
mkswap /swapfile 65536
sync
swapon /swapfile


umask (long time ago ...)

Each file which is created gets a default file permission. This can be controlled via umask. You have to give umask one argument - the opposite octal value of the mode you want. i.e. you wanna have 700 as default file permission, you have to invoke umask 077 (700 + 077 = 777 as a hint).


Display power management (long time ago ...)

For your X session (/etc/X11/xorg.conf):
Section "Monitor"
	...
	Option	"DPMS"
	...
EndSection

...

Section "ServerLayout"
	Option "BlankTime" 		"2"
	Option "StandbyTime" 	"4"
	Option "SuspendTime" 	"6"
	Option "OffTime" 		"8"
EndSection

For the console (~/.bashrc):
setterm -blank 2
setterm -powersave on
setterm -powerdown 5


Enabling all Thinkpad features (long time ago ...)

On my IBM T43 some hotkeys - the ones using Fn - are deactivated. To enable functions like disabling the LCD write this to /etc/conf.d/local.start. Don't forget to load the kernel module called ibm_acpi / thinkpad_acpi.
echo enable,0xffff > /proc/acpi/ibm/hotkey


Making a partition user-writeable (long time ago ...)

Example entry in /etc/fstab for a reiserfs partition:
/dev/hdb1 /mnt/storage reiserfs users,rw,noatime,owner 0 0
The mount point should have 777.



Make your login cooler (long time ago ...)

Feeling the red vine of last night in my guts, it's better not to study... better start playing again :-D

Does your login also look so boring and standardized? Make it a bit cooler using some nice tools (checkout Gentoo Forums).

Some "background knowledge": /etc/issue is responsible for the output before the user login and /etc/motd is the message of the day displayed right after the login of a user. Here comes linux-logo into play, and of course don't forget cowsay (moooooh :-)) and fortune...
echo "games-misc/fortune-mod offensive" >> /etc/portage/package.use
emerge linux-logo cowsay fortune-mod fortune-mod-starwars
linux_logo -L 3 > /etc/issue
echo "fortune starwars | cowsay > /etc/motd" >> /etc/conf.d/local.start

May the force be with you! Good night!!


Installing Windows *after* Linux (long time ago ...)

Normally, you should install Windows first and then Linux because if you do it the other way, the Windows installation will delete your MBR (master boot record) installed by grub.

Of course there is a possibility to achieve the other way: After having installed Windows boot with a live cd and run the following commands (taken from Gentoo Weekly Newsletter):
mount /dev/rootpart /mnt/gentoo
mount /dev/bootpart /mnt/gentoo/boot
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile
grep -v rootfs /proc/mounts > /etc/mtab
(Assuming your hard drive is /dev/hda)
grub-install /dev/hda


Sansa SanDisk e250 (long time ago ...)

I've got a new mp3 player, the Sansa SanDisk e250 with 2GB hard disk. Before you plugin the sansa, change the usb setting to MSC. After that add a udev rule as described below:
nano /etc/udev/rules.d/10-local.rules
KERNEL=="sd?1", BUS=="usb", SYSFS{product}=="Sansa e250", NAME="%k", SYMLINK+="sansae250"

mount the device as a normal storage device: mount /dev/sda1 /mnt/sansa


Using Bash shortcuts (long time ago ...)

First of all some nice shortcuts (Emacs mode):
TAB auto-complete
Ctrl-r search for commandos
Ctrl-l clean screen
Ctrl-e go to end of line
Ctrl-a go to beginning of line
Ctrl-u delete whole line
Ctrl-k
Ctrl-d delete character under
Alt-b go one word backward
Alt-f go one word forward

If you prefer vi-Mode, then type set -o vi

You can see all bindings using bind -p; bind -l will list all available functions! Use bind -u function and bind -q function to set new shortcuts.



Using dd and mkisofs (long time ago ...)

dd stands for "convert and copy" - weird? No, because cc is the C compiler :-D

So for what is dd good for? Perhaps for saving your MBR (master boot record):
dd if=/dev/hda of=bootsector bs=512 count=1
Or raw copy a whole cd (not mounted):
dd if=/dev/cdrom of=foobar.iso

This is fine for raw data - but CDs (compact discs) need a iso files: mkisofs is your friend
mkisofs [options] -o outputfile.iso /tmp/data
options can be -r (Rockridge), -j (Joliet), -R (Rockridge + Owner + Permissions), and many more, see the man page!
Here some more: -V "Volume-ID" sets a volume ID for the CD

Before you actually write your data onto the CD, you can test it using the loop device:
mount -o loop foobar.iso /mnt/tmp
After testing your data unmount /mnt/tmp and finally burn it on CD:
cdrecord --dev=ATAPI:0,0,0 driveropts=burnfree foobar.iso


Using split and cat (long time ago ...)

Home directories and other data could be burned as follows:
mkisofs -o /tmp/backup.iso /home/user
cdrecord -v --dev=ATAPI:0,0,0 driveropts=burnfree /tmp/backup.iso

But what to do when the file is too big for one compact disc? Use split!
split -b 695m backup.iso backup.iso.split.

This command will create files which have exactly the size of 695 MB (except the last one). Restoring the original file is as simple:
cat backup.iso.split.* > backup.iso

The only problem with this scheme is that files are twice on the machine! If you have a small disk with vast space, use the pipe:
tar cz /home/user | split -b 695m - archiv.tar.gz.split.
cat archiv.tar.gz.split.* | tar xz


Understanding diff output (long time ago ...)

diff file1 file2 assumes that file2 is newer than file1. Thus, the output has to be interpreted as which changes have to be made to file1 to get the contents of file2!

13c13 
means: line 13 in file1 has changed to line 13 in file2

81a82,84 
means: lines 82 through 84 of file2 follow line 81 of file1

with large outputs use these ones:
diff file1 file2 | less 
diff file1 file2 > changes.diff

If you're just interested if two files are identical than invoke:
diff --brief file1 file2 (or just -q)

Another perspective can be shown:
diff --context file1 file2 (or just -c)
! stands for changed lines, + for added lines and - for removed lines.
Patch files are changes in the Unified-Diff-Format. You can get them using the --unified (-u) parameter.


Unicode / UTF-8 support in Linux (9th Oct'07)

If you don't have the smallest idea about unicode / UTF-8, read this article.

Be sure that your locales are configured correctly:
locale
locale -a
locale -m
Since I have a keyboard with US layout (which really rocks at programming) I miss my German Umlaute ae, oe, ue, ss and the Euro sign. Add this to your .xinitrc:
 
xmodmap -e "keycode 113 = Mode_switch Mode_switch"
xmodmap -e "keysym a = a NoSymbol Adiaeresis NoSymbol Adiaeresis"
xmodmap -e "keysym o = o NoSymbol Odiaeresis NoSymbol Odiaeresis"
xmodmap -e "keysym u = u NoSymbol Udiaeresis NoSymbol Udiaeresis"
xmodmap -e "keysym s = s NoSymbol ssharp NoSymbol"
xmodmap -e "keysym e = e NoSymbol EuroSign NoSymbol"
AltRight has keycode 113 and is therefore used as a mode_switch for my Umlaute and special characters. Look at /usr/include/X11/keysymdef.h to find the correct names for the xmodmap commands.

If you want to test your console client, load a unicode test file and cat it. For comparison, watch it in firefox (which has decent UTF-8 support) or run the cat command within a xterm invoked by LC_CTYPE=en_US.UTF-8 xterm -fn '-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1'.

Another way to test your console client is to invoke some perl one-liners (should print the Euro sign):
 
perl -C -e 'print pack("U",0x20ac)."\n"'
perl -C -e 'print "\x{20ac}\n"'


mail

My own mail setup (1st Oct'07)

It's a combination of client-server-architecture with IMAP / POP support. The main idea is: keep the mails within the imap folders on the server and have several clients syncing with this server. The problem was that there are a lot of different mail addresses with whom I had to struggle with.

Here's what's happening, in short: I'm outside with my laptop and want to receive mail. First, I check whether there are differences on my IMAP server using offlineimap. After that, I use a fetchmail and procmail to receive mail via POP3 from my different mail addresses - I use several filters in procmail and mutt to keep the messages in the correct (local) IMAP folder. Before quitting, changes to these folders are synchronized to the IMAP server so that access in the future from other PCs for example results in a consistent and up-to-date mail directory!

The quick and dirty way: copy the mutt, procmail, fetchmail, offlineimap and msmtp configuration into the home directory, see the configuration files on the other page on this website. Adjust them for your own needs!

So what to do when you want to add a mailing list for example. First, create the mailboxes in your .maildir/ folder and on the remote server where the IMAP server is. Of course the names must be identical. After that you can move the mails from INBOX.FOO to INBOX.FOO.2007-10 using mutt: tag the messages you want to move with t, and save them using ;s. Mutt has to know about mailboxes etc. and because of that you have to configure it in the .muttrc. Look at your mbox-hooks, lists and mailboxes command. Also check your procmail configuration so that the mails are stored in the correct mailbox.


mail

Minimal mailing w/ mail (long time ago ...)

Starting mail without any parameter, the INBOX is shown in an interactive window. The handling is a bit difficult and circumstantial, but if no other MUA is available, this is just fine. Here some shortcut infos (similar to mutt):
? help screen
+ go to next mail
- go to previous mail
NUM read message number NUM
d delete (also d 1 2 or d 1,5 or d *)
u undelete
q quit
x exit
r reply
m mail
You write mails until a line appears which consists only of ".". If you wanna switch to your favorite editor type ~v after you've typed in your subject line (the $VISUAL variable is read out).

The real strength of mail comes out when it is used automatically (e.g. in scripts):
echo "foobar bla bla" | mail -s "Subject" -b "bcc1@domain.de" -c "cc1@d.de,cc2@d.de" foo@bar.de
mail -s "Subject" foo@bar.de < file

Use -v if you wanna watch the SMTP connection and get more infos about the mail delivery!



Midnight Commander

Some shortcuts (9th Mar'08)

C-x j = show background jobs
C-s = search within directory
insert = select file / directory


Mplayer

Extracting audio from video (long time ago ...)

mplayer -ao pcm movie-file
Note: this would have gone faster if I had used -vc null -vo null -ao pcm:fast as arguments!
for i in *.wav; do lame -h $i `basename $i wav`mp3; done;


Muttprint

Printing inside of mutt (1st Oct'07)

Add this to your existing mutt-configuration:
set print_command="muttprint"
set print="yes" 
set print_split

macro index p "display-toggle-weed> print-message> display-toggle-weed> exit>"
macro pager p "display-toggle-weed> print-message> display-toggle-weed>"
I didn't have luck when I tried it the first time. muttprint ended with "error in charset conversion". After looking in the log-file (debug set to "1" in ~/.muttprintrc) I found out that latex was missing a utf8.def file. To solve this problem you must install latex-unicode and change utf8 into utf8x in commondefs.tex.

Linux User article about muttptrint


Nameserver

List of nameservers (long time ago ...)

If you dont know what you should write into the /etc/resolv.conf :D
search freenet.de
nameserver 62.104.196.134 #DNS Freenet
nameserver 192.76.144.66 #DNS MSV

search t-online.de
nameserver 212.185.252.73 #DNS tonline
nameserver 62.225.252.16 #DNS tonline
nameserver 194.25.2.129 #DNS tonline


NFS

NFS installation and usage (long time ago ...)

Kernel configuration:
Filesystems
	Network Filesystems
    	M NFS Filesystem Support 
    	* provide NFSv3 client support 
    	M NFS Server support 
	    * provide NFSv3 server support

Steps the client / server has to do:
both: emerge nfs-utils
both: vim /etc/hosts
NFS-Server: echo "/mnt/media thinktuxwireless(async,no_subtree_check,rw)" >> /etc/exports
NFS-Client: mount -t nfs gateway:/mnt/media /mnt/nfs/




nmap

Using nmap (long time ago ...)

nmap is a scanning-tool for hackers and admins - it detect ports / services on hosts.

possible responses:

open - connection was accepted by one service
filtered - a firewall filters this port
unfiltered - there is no firewall

Scan methods:
-sS = tcp syn scan: "half-open" scanning; only the syn paket is sent; if syn/ack returns, this port is listened and finally RST is sent; if port returns with RST, there is no service!
-sT = tcp: "full" scans, full connection establishment!
-sF = FIN scan: use FIN package to test if port is open, because many firewalls do not accept SYN packages
-sX = Xmas Tree... like -sF, but FIN, URG and PUSH are used
-sN = Null scan, turns off all flags
-sP = ping scans; either with ICMP echo requests, ACK requests or normal SYN packages
-sU = UDP scans: one 0 byte UDP package is sent to the host; if ICMP message "port unreachable" returns, then port is closed; otherwise it is assumed it's open;
-sO = ip protocol scans: scans protocols; if "protocol unreachable", protokoll doesn't exist on host
-sA = ACK scans: test, whether a stateful firewall is used; if RST, then port is unfiltered, otherwise it's filtered;
-sR = rpc scan
-sL = list scan: list all hosts without pinging or scanning ports

Options:
-P0 = do not ping before port scan
-O = fingerprinting
-oN file = write results to file
-p 20-30,139,6000- = list of ports to be scanned
-n = do not do any reverse dns
-v = verbose mode


Open Office

Extract pictures from Word documents (14th Oct'07)

Convert the doc file into an OpenOffice document (odt) and unzip it. That's it!



Perl

Find version of installed perl modules (long time ago ...)

Check version of CGI.pm modul: perl -MCGI -e 'print $CGI::VERSION'



PHP

Configuring mod_evasive for DOS-prevention (long time ago ...)

/etc/apache2/mod_evasive20.conf contains the configuration of the evasive-module for apache which prevents DOS-attacks.
DOSHashTableSize 3097
DOSPageCount 10
DOSSiteCount 100
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 5
DOSEmailNotify email@addy.de
DOSLogDir "/tmp/evasive"

This has to be interpreted as follows:
It will log an attack to /tmp/evasive if the threshold for the same page / URI (PageCount) is exceeded per PageInterval or if the same client exceeds the SiteCount threshold per SiteInterval. The IP will be blocked for BlockingPeriod seconds and a notification Email is sent to EmailNotify.

To receive this Email, you have to check whether the system variable $MAILER is set. You can check this running echo $MAILER on console. If it's not set like on my system, edit ~/.bashrc and type in it:
export $MAILER="/bin/mail -t %s"

Use the incoming log mails to tune your configuration! More information under [1].

[1] README


PHP mail() with UTF-8 (2nd Oct'07)

If you want to convey mails with special characters using utf you have to transmit several headers and you must encode your strings using utf8_encode().

The headers are:
Content-type: text/plain; charset=utf-8 Content-encoding: utf-8 Content-transfer-encoding: utf-8



Psutils

Extract pages from PostScript files (4th Oct'07)

If you do not want to use the whole ps file with all its pages, you can use psselect to select only the even or odd pages for example.

psselect -e infile outfile will produce outfile with the even pages, -o with the odd pages and with -ppages you can give the number of pages you want as a comma separated list or with the format start-end.


Root-Tail

Root-Tail with Xfce 4.4 (long time ago ...)

#!/bin/bash
deskid=`xwininfo -int -name 'Desktop' | grep 'Desktop' | awk -F' ' '{ print $4 }';`
root-tail -g 900x450+500+50 -font 8x13 -id ${deskid} -f \
/var/log/messages,white


Samba - connection to evil M$

Mount windows shares (long time ago ...)

For this, you do NOT have to start samba for this.
mount -t smbfs -o username="Administrator",password="xxx" //WIN-IP/C$ /mnt/samba/

Same in fstab:
//WIN-IP/C$            /mnt/samba    smbfs           username=Administrator,password=WIN-PASS        0 0


Connect to SMB share from Win 98 (long time ago ...)

Be sure that both machines are in the same workgroup, then create this /etc/samba/smb.conf:
[global]
workgroup=LAN
browseable = yes
server string=%h (Samba %v)
dns proxy=no
name resolve order=lmhosts wins bcast host
log file=/var/log/samba/log.%m
max log size=1000
syslog=0
panic action=/usr/share/samba/panic-action %d
security=SHARE
encrypt passwords=true
passdb backend=tdbsam guest
obey pam restrictions=yes
#invalid users=root
map to guest=Bad User
passwd program=/usr/bin/passwd %u
passwd chat=*Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
client use spnego=no
load printers=no
printing=cups
printcap name=cups
socket options=TCP_NODELAY
display charset=iso8859-1
unix charset=iso8859-1
preserve case=yes
case sensitive=no
short preserve case=yes
os level=20
;   preexec = /bin/mount /cdrom
;   postexec = /bin/umount /cdrom

[public]
path = /home/smashor
public = yes
writable = yes
create mask = 0000
browseable = yes
Win98 computers (and maybe others too) only respond to smbclient when you take the netbios name. Instead of smbclient -L 192.168.0.99 or smbclient -L rentner (name of /etc/hosts) you have to use smbclient -L BLABLA. You get this name with nmblookup -A 192.168.0.99.


Screen

Fx keys in screen (long time ago ...)

For the Fx keys where x is one of 0-9 use this:
bindkey -k kx command

If you have more Fx keys use this:
bindkey -k Fx command (which means 1x)

So to bind F1 to "go to window 1" and to bind F12 to "go to next window" use these lines:
bindkey -k k1 select 1
bindkey -k F2 next


SMART tools

SMART Tools (long time ago ...)

S.M.A.R.T. stands for Self Monitoring Analysis and Reporting Technology - it gives information about the state of the hard disk (e.g. warmth, age, number of errors). To receive the SMART attributes one will need smartmontools (smartctl to get the information, smartd is a background daemon).

First, you have to activate SMART for your disk:
smartctl -s on /dev/hda
Then you can get an overview page:
smartctl -A /dev/hda
Since there is no standard, the developers provide information for hard disks. To see, if your hard disk is in the database, invoke:
smartctl -P show /dev/hda
The column named "UPDATED" indicates how often the attributes are updated. Always means data is updated all the time, while Offline means that the data is updated every hours e.g. You can update at once the "offline attributes":
smartctl -t offline /dev/hda
The column named "TYPE" can have two values: "Pre-Fail" or "Old_age". Old_age attributes are interesting, but they do not indicate a damage. Thus the Pre-Fail attributes exist!

The higher the absolute value of "VALUE", the more sane is your hard disk. "THRESHOLD" gives a lower bound which should not be undergone.

You should regularly look at the "Pre-Fail" values!

You can run some tests:
smartctl -t short /dev/hda
smartctl -t long /dev/hda
smartctl -l selftest /dev/hda
Some manufacturer information can be received with this one:
smartctl -i /dev/hda
By the way, the temperature of current hard disks is about 45 C, the value should not be regularly over this value!

For S-ATA disks, you have to add -d ata at each smartctl command.

You need smartctl -o on /dev/hda to update the attribute values each 4 hours.

To receive mails on faults and errors, write -m email@address.de in your /etc/conf.d/smartd and restart smartd (don't forget to add rc-update add smartd boot)


SPIM - MIPS Simulator

Get SPIM working on Gentoo (long time ago ...)

SPIM - the MIPS simulator - does not work in Gentoo out of the box (or Linux in general, don't know) if you install the package spim. After xspim the window appears, but the subwindows don't show anything!
emerge "< flex-2.5.33"
emerge spim
emerge flex


SSH

SSH connection to ATIS server (long time ago ...)

ssh s_xxxxx@i08fs1.ira.uni-karlsruhe.de


Understanding ssh and scp (long time ago ...)

connecting to a remote host using ssh
ssh user@remotehost or
ssh -l user remotehost

invoking a command
ssh user@remotehost "ls -l /tmp/*"
ssh -t user@remotehost mutt (use -t for programs which will acquire the screen control)

secure copy
scp file.tar.gz user@remotehost:/home/foobar/
Options like -r and -p are available here, too.



Authenticating using a key instead of pass phrases (1st Oct'07)

First, generate a key using ssh-keygen which will create two files in your ~/.ssh directory: identity and identity.pub. The former key is your private key and the latter one your public key! Then copy the public key to the remote host home directory and add the contents of this public key to the .ssh/authorized_keys file: mkdir -p .ssh && cat identity.pub >> .ssh/authorized_keys. You should delete now the public key in the home directory (remote host). Everything is set up now, just connect to the remote host. If there are problems try to set the correct permissions: chmod go-w ~ chmod 700 ~/.ssh (remote host).


Syslog-ng

Configuring and understanding syslog-ng (long time ago ...)

Available facilities:
auth auth-priv cron daemon ftp kern lpr mail
mark news syslog user uucp local0 - local7

Available priorities:
debug info notice warn err crit alert emerg

Simple /etc/syslog-ng/syslog-ng.conf
options {
        long_hostnames(off);
        sync(0);

        # The default action of syslog-ng 1.6.0 is to log a STATS line
        # to the file every 10 minutes.  That's pretty ugly after a while.
        # Change it to every 12 hours so you get a nice daily update of
        # how many messages syslog-ng missed (0).
        stats(43200);
};

#
## messages
#
source messages_src { unix-stream("/dev/log"); internal(); };
destination messages_dest { file("/var/log/messages" perm(0644)); };
log { source(messages_src); destination(messages_dest); };

#
## kernel related logs to /var/log/kernel
#
source kernel_src { file("/proc/kmsg"); };
filter kernel_filter { facility(kern) and level(info,notice,warn,err,crit,alert,emerg); };
destination kernel_dest { file("/var/log/kernel"); };
log { source(kernel_src); filter(kernel_filter); destination(kernel_dest); };

# kernel debug output in /var/log/debug
destination debug { file("/var/log/debug"); };
filter f_debug { not facility(auth, authpriv, news, mail); };
log { source(src); filter(f_debug); destination(debug); };

Resources:
[1] Gentoo Doc about syslog-ng


Uni

VPN tunnel to university (long time ago ...)

Sometimes I need a secure connection to the university. Just install vpnc and visit this site if you have an encrypted group password.

Afterwards, edit the configuration file /etc/vpnc.conf:
IPSec gateway rz-ipsec.rz.uni-karlsruhe.de
IPSec ID unika
IPSec secret ********
Xauth username username
Be sure that you have selected the kernel module tun (Device Drivers - Network - Universal TUN/TAP) - otherwise you will get an error message saying you do not have /dev/net/tun i.e.

Finally, invoke vpnc and have fun! To check whether you're using the VPN, look at the output of route -n !


Vim

Fixing man page problem in vim (long time ago ...)

echo "export MANPAGER=more" >> ~/.bashrc

Ctags and Vim (long time ago ...)

If you wanna work in a large code project, you have to know ctags in combination with vim! In your source code directory enter exuberate-ctags *.c *.h which will create the tags file. After that, you can browse through the source code and jump through the definitions of constants, variables and functions using CTRL+]. If you have read enough switch back to your starting point using CTRL+T.


Folding in Vim (16th Oct'07)

Source Files can grow very rapidly and for a better structure and overview vim has the facility to fold and unfold parts of your code. To make a fold for a visual selection, just press zf. Using zo opens a fold. If you want to close it again, use zc. zO opens all folds while zC closes all. zi toggles all folds.

Foldings are not saved within the .viminfo, but you can save foldings with :mkview and load them with :loadview!


Color scheme for gvim (long time ago ...)

In .gvimrc
color colorscheme


IDE like vim (long time ago ...)

First of all the great IDE-like winmanager plugin. Just extract the winmanager.zip in your ~/.vim directory. The help-file says you also need bufexplorer: then do it again for that one .


Teach vim spelling (long time ago ...)

emerge vim-spell-de vim-spell-en

After that open vim (or gvim) and read :help spell. Here's a short summary:

:setlocal spell spelllang=de (or de_19 (before the German reform), de_20 (the new one), en_us)
zg store a marked word as a good word into the spell file
zw store a marked word as a wrong word into the spell file
]s go to the next misspelled word
[s go to the previous misspelled word
z= get a list of suggestions for a word marked as wrong

Of course this is only efficient if you do not have to type in these cryptic commands. So here some mappings:
map  :set spelllang=de:set spell!:echo "German spell check: " . strpart("OffOn", 3 ASTERISK &spell, 3)
map  :set spelllang=en_us:set spell!:echo "English spell check: " . strpart("OffOn", 3 ASTERISK &spell, 3)


Using the vim help files (16th Oct'07)

Don't forget to use CTRL-] and CTRL-t to jump within the help files, the words are marked specially.

If you need help, just type :h word / shortcut / option. For example to get help on the hls option invoke :h 'hls' or to know something about the shortcut CTRL-K type in :h C-K

If you don't know exactly what you're searching for you can type in :h word and then instead of completing the ex-commando with Return try CTRL-D. A list will appear with help sections similar to your request.

Another way to search for inexact patterns is to use some regular expressions: :helpg pattern is your friend!

The names of the keycodes are listed in :h keycodes.


More about making programming / text editing easier with vim (16th Oct'07)

You can open an imported file in a new buffer using CTRL-W-F. The same can be done with gf, but the file is shown in the same buffer as the old file.

Jump to local / global declaration of a variable using gd / gD. You can also jump to system wide declarations using [<Tab>. An alternative is to use CTRL-W-D.

A way to find all occurences of a word under the cursor is to invoke [I - it will open a small buffer with all found lines in files.

Compiling a program using a make command can be done with :make and the use of quickfix: :copen, :cnext, :cclose, :clist

Vim is also good for writing mails - some standard values here should be: tw=0 or 78, wrap, linebreak. And if you want to reformat a text block, then you should probably try gqap - the output is a nice reformatted text block.

Vim can be started with a folder as a parameter - it will list all files within this folder. Type i to get several views of the directory listings. Another command line parameters are -R and -M with open a file in read-only mode respectively modifiable-off mode.

If you really work heavy on some files with foldings, marks etc. and you want to have these things set after a restart of mutt, you have to know these commands: for working with viminfo files use :wviminfo [!] [file] and :rviminfo [!] file. The problem is that with viminfo not everything is stored, e.g. no foldings are saved: to get them use these: :mkview [!] [number] and :ldview number. Even more information is stored with sessions: :mksession [!] [datei]. To load these on vim startup you can pass some arguments: vim -i infofile -S sessionfile.

Another possibily is to export the current settings and mappings into a vimrc file using :mkvimrc [!] [file]. It can be loaded with vim -u file. A special startup is vim -u NONE.

Really helpful is to get the last visual selection with gv.

Ever tried to capitalize a word? Visual select it, type u for lower and U for upper leters - ~ in normal mode reverts a character.

Sometimes marks are a nice thing - you can show the existing ones with :marks, create one with mLETTER, jump to the mark with `LETTER and jump back with ``.

Some shortcuts / things to know:
ZZ save and close buffer

"a3dw delete three words and store them in register a

I vs. gI: insert at the beginning of a line vs. insert at column 0

78i-<ESC> will produce a line of 78 -

i_CTRL-D / i_CTRL-T make one indentation less / more in insertion mode

i_CTRL-V ASCII/UTF-CODE / ga type in CODE / show CODE information for character under cursor

i_CTRL-W / i_CTRL-U delete last word / line you typed in

^ / $ jump to beginning / end of current line

( ) { } jump to previous / next sentence / paragraph

% jump to the next parenthesis

J join the current and the next line into one line

q/ q? popup search history in forward / backward direction

window movements see :help CTRL-W and :help window-moving

i_CTRL-P / i_CTRL-N for completing words

xp swap current with next character - ideal for typos which happen more than often.



Haskell mode for vim (17th Oct'07)

Installation is really simple: you need a functional ghc with docs (USE flag doc) and then of course haskellmode.

Configuration is a bit tricky: be sure that you have the following lines in your .vimrc:
 			filetype plugin on
			filetype indent on
			au BufEnter *.hs compiler ghc
			let g:haddock_browser="/usr/bin/firefox"
			let g:haddock_docdir="/mnt/storage/code/haskell/haskell.org/"
		
Open a Haskell file and type in :ExportDocIndex. After that :DocSettings should be possible which indicates that your installation was successful.

Now let's show a few features (see [3] for a full list):

GHC compiler intregration
    _si is used to show information
    _t is used to show the type
    _T is used to add a type declaration
    _ct creates a tags file in the currenct directory
    i__CTRL-X_CTRL-O is used for insertion-mode completion based on GHCi browsing
    _opt shows a list of common ghc options


Haddock integration:
    _? looks up identifier in haddock
    :IDoc {identifier} looks up identifier in haddock
    :MDoc {module} looks up module in haddock
    _. fully qualifies an unqualified identifier
    _i adds import statement for the identifier under the cursor
    _im adds import module statement
    i_CTRL-X_CTRL-U user-defined insert mode name completion based on all names known to the Haddock index, including package names


HPaste integration:
    :HpasteIndex makes a list of current entries from hpaste.org
    :HpastePostNew takes the current buffer and makes a new hpaste.org entry out of it


Resources:

[1] Claus Reinke's Vim Haskell page
[2] Claus Reinke's graphical tour
[3] Claus Reinke's Haskellmode manual


Webalizer

Create nice Web-Reports with webalizer (long time ago ...)

Just install it, create a directory for the output and run webalizer -T logfile inside this new directory. The output is really create and helps finding bottlenecks and failures in your web presence!


Xmonad - the Haskell tiling window manager

Installation and first configuration on Gentoo (28th Sep'07)

Install layman to get access to the haskell overlay. Since it is accessed through darcs which needs haskell to compile and as we do not yet have haskell installed, we download a pre-compiled one and use that (which it is removed after adding the haskell overlay using layman):
emerge subversion layman
layman -a haskell
wget http://www.pps.jussieu.fr/~jch/software/files/darcs-1.0.7-i386-linux.gz
gunzip darcs-1.0.7-i386-linux.gz
mv darcs-1.0.7-i386-linux /usr/bin/darcs
chmod +x usr/bin/darcs
layman -a haskell
rm /usr/bin/darcs
Add these lines to the /etc/make.conf (only if this was your first overlay installation):
#PORTDIR_OVERLAY="/usr/portage/local/layman/haskell"
source /usr/portage/local/layman/make.conf
Now one has to set some USE-flags in /etc/portage/package.use ...
dev-lang/ghc binary
x11-wm/xmonad-darcs extensions
... and some keywords in /etc/portage/package.keywords (if you want to use the latest version, uncomment the darcs lines and comment the appropriate lines):
=dev-lang/ghc-6.6.1
=dev-haskell/mtl-1.1.6.2
dev-haskell/regex-base
dev-haskell/regex-compat
dev-haskell/regex-posix
dev-haskell/cabal
dev-haskell/filepath
dev-util/darcs
dev-haskell/quickcheck
dev-haskell/html
x11-wm/xmonad
#x11-wm/xmonad-darcs
dev-haskell/x11
dev-haskell/x11-extras
#dev-haskell/x11-extras-darcs
Now install ghc and xmonad using emerge -av dev-lang/ghc x11-wm/xmonad-darcs


Xorg

US keyboard and German Umlaute (long time ago ...)

The main concept: use the us layout and add the special characters to it.
Section "InputDevice"

Identifier "Keyboard1"
Driver "kbd"
# Option "Protocol" "Xqueue"
Option "AutoRepeat" "500 30"
Option "XkbRules" "xorg"
Option "XkbModel" "pc104"
Option "XkbLayout" "us,de"
Option "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll"
Option "XkbVariant" "nodeadkeys"
EndSection

Some notes for this snippet. You can change always between German and US layout by pressing ALT and Shift, but the US layout is the default one. Now we use xmodmap to add our special keys. Put the following in your ~/.xinitrc:
# right alt
xmodmap -e 'keycode 113=Mode_switch'
xmodmap -e 'keycode 38=a A adiaeresis Adiaeresis'
xmodmap -e 'keycode 32=o O odiaeresis Odiaeresis'
xmodmap -e 'keycode 30=u U udiaeresis Udiaeresis'
xmodmap -e 'keycode 26=e E EuroSign EuroSign'
xmodmap -e 'keycode 39=s S ssharp ssharp'


Reloading .Xdefaults w/o restarting X (long time ago ...)

xrdb .Xdefaults


Using xset (long time ago ...)

Options:
-d display = server
-DPMS = switches on "Energy Star" functions
+DPMS = switches off "Energy Star"
m acceleration = acceleration for mouse in x
q = informations about current settings

Write the settings in ~/.bashrc


Trackpoint configuration (2nd Oct'07)

Starting from 2.6.13 config files for this driver are located in /sys/devices/platform/i8042/serio0/serio2.

Press-to-Select allows you to tap the control stick which will simulate a left click.
enable:  # echo -n 1 > /sys/devices/platform/i8042/serio0/serio2/press_to_select
disable: # echo -n 0 > /sys/devices/platform/i8042/serio0/serio2/press_to_select


You can control the sensitivity and the speed of the trackpointer with values between 0 and 255.
# echo -n 120 > /sys/devices/platform/i8042/serio0/serio2/speed 
# echo -n 250 > /sys/devices/platform/i8042/serio0/serio2/sensitivity 


Scrolling while holding mouse button 3: just add these two lines to your existing mouse section in /etc/X11/xorg.conf.
Option          "EmulateWheel"          "on"
Option          "EmulateWheelButton"    "2"

Resources:
[1] ThinkWiki article about trackpoint


Install Xcursor themes (9th Oct'07)

Install some Gentoo Xcursor packages like gentoo-xcursors and look into /usr/share/cursors/xorg-x11/ where the themes are installed.

You can choose your theme using ~/.Xdefaults or by creating the /usr/share/cursors/xorg-x11/default/index.theme. The local variant:
Xcursor.theme: THEME_NAME

And the global variant:
Inherits=THEME_NAME


ZIP

How to make a zip file (long time ago ...)

zip -r file.zip dir/*





made with vim ...