Using-HowTo

yet another Linux HowTo for allday use

fluffi

Release 0.5


1. OpenSSH - the secure shell

To generate a key for protocol version 1 type:

fluffi@donkey:~> ssh-keygen -t rsa1 

or to create a key for a ssh2-key.

fluffi@donkey:~> ssh-keygen -t rsa 

You will be promted for a passphrase. The transfer of the key to the remote destination and the remote session could look like this:

fluffi@donkey:~> ssh-copy-id user@remotehost 
fluffi@donkey:~> ssh user@remotehost 

at the foreign host check the permissions:

user@remotehost:~> chmod 700 .ssh 
user@remotehost:~> chmod 600 .ssh/authorized_keys 
user@remotehost:~> exit 

Henceforth you can login to the foreign host with the passphrase only. If you use X11, this little proggy.AH makes sure, you only have to type the passphrase once per X11-session.

fluffi@donkey:~> sudo apt-get install \ 
  ssh-askpass-gnome 
#!/bin/sh

# $@: [command1] [command2] [...] 
pathContains() {
    type -a "$@" 1>/dev/null 2>/dev/null
}

# $@: [command1] [command2] [...] 
ensurePathContains() {
    if ! pathContains "$@"
    then
    	RET=$?
	echo "command(s) \"$@\" not in PATH."
    	echo "exiting ..."
	exit $RET
    fi
}

ensurePathContains ssh-add
ensurePathContains ssh

# list identities
OUT="$(ssh-add -l 2>[ampersand?]1)"
RET=$?

#echo OUT=\"$OUT\"
#echo RET=\"$RET\"

# are there identities?
if [ $RET -ne 0 ]
then
    echo "Problem contacting ssh agent."
    echo "\"ssh-add -l\" says:"
    echo "$OUT"
#else
    # checkin' the output...
    echo "$OUT" | fgrep -q "no identities."
    if [ $? -eq 0 ]
    then
	echo "$OUT"
	ssh-add lt /dev/null
    else
    	true
    fi
fi

exec ssh "$@"

Creating tunnels with ssh (-L local vs. -R remote):

user@remotehost:~> ssh -g -L 80:webserver:80 www-data@webserver 
user@remotehost:~> ssh -g -R 8080:remotehost:8080 www-data@webserver 

2. Unleash the power of the Zsh

Configuration of the interactive Zsh is mainly done in .zshrc in the home directory of the current user. During the startup process the following files - order does matter - are used:

/etc/zshenv
~/.zshenv
as login shell:
/etc/zprofile
~/.profile
/etc/zlogin
~/.zlogin
interactive shell:
/etc/zshrc
~/.zshrc

During the logout process:

/etc/zlogout
~/.zlogout

Set paranoid default permissions to newly created files. This configuration is done in .zprofile or .zshrc

#flu: setting restrictive file permissions
umask 077

Wandering around

Table 1. 

commandaction
fluffi@donkey:~> cd 
change to home directory
fluffi@donkey:~> cd - 
change back to latest directory

manipulating multiple files

Table 2. 

commandaction
fluffi@donkey:~> touch tmp.{00..42}.log 
create lots of files
fluffi@donkey:~> ls -la tmp.{12..20} 
list selected files

Navigating within a gnome-terminal

Table 3. 

typecode
forward-word ^[[5D
backward-word ^[[5C
beginning-of-line ^[OH
end-of-line ^[OF
#flu: adding cursor navigating in a gnome-terminal
bindkey "^[[5C"   forward-word
bindkey "^[[5D"   backward-word
bindkey "^[OH"    beginning-of-line
bindkey "^[OF"    end-of-line

Tuning the Zsh history:

# flu: extended history, no dups :)
HISTFILE=${HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=2000
setopt histignorealldups

3. The Vi(m)

:syntax off

4. The Mutt

? -> Hilfe, Esc + c :( und c change folder

5. Documents using Docbook

Docbook.org and The Definitive Guide

This document shows how to build a book using fop.

fluffi@donkey:~> sudo apt-get install \
  fop lib-saxon-java libxml2-utils 

lib-saxon-java contains a xslt preprocessor. libxml2-utils the xml verify tool xmllint.

Docbook items

Table 4. short commands

typesourcedemo
acronym<acronym>NASA</acronym>NASA
emphasis<emphasis>emphasis</emphasis>emphasis
envar<envar>HTTP_PROXY</envar>HTTP_PROXY
guimenuitem<guimenuitem><accel>Q</accel>uit</guimenuitem>Quit
subcriptH<subscript>2</subscript>OH2O
supercriptx<superscript>2</superscript>x2

Table 5. complex commands

typesourcedemo
program listing
<programlisting>

mvcut -d " " 3
</programlisting>
  

mvcut -d " " 3
terminal session
<screen>
<prompt>fluffi@shrek:~> </prompt>
<userinput>echo test</userinput> 
test
</screen>
  
  fluffi@shrek:~> 
  echo test 
test
footnote
42<footnote>
<para>is 6 times 7</para>
</footnote>
  
42[a]
note
<note><title>Debian Users</title>
<para>
  can use 
  <application>aptitude</application>
</para>
</note>
  
[Note]Debian Users

can use aptitude

tip
<tip><title>Debian Users</title>
<para>
  can use 
  <application>aptitude</application>
</para>
</tip>
  
[Tip]Debian Users

can use aptitude

warning
<warning><title>Debian Users</title>
<para>
  can use 
  <application>aptitude</application>
</para>
</warning>
  
[Warning]Debian Users

can use aptitude

important
<important>
<para>
Breaking this seal 
voids all warranties.
</para>
</important>
  
[Important]Important

Breaking this seal voids all warranties.

ulink
<ulink url="http://www.debian.org">
  <citetitle>
    Debian Homepage
  </citetitle>
</ulink>
  
Debian Homepage
link
<link linkend="docbook">
Docbook
</link>
  
Docbook
menuchoice
<menuchoice>
  <shortcut>
    <keycombo>
      <keysym>C-x</keysym>
      <keysym>C-c</keysym>
    </keycombo>
  </shortcut></row>

  <guimenu>Files</guimenu>
  <guimenuitem>
    Exit Emacs
  </guimenuitem>
</menuchoice>.
  
Files->Exit Emacs (C-x-C-c).
itemizedlist
<itemizedlist>
<listitem>
<para>
first
</para>
</listitem>
<listitem>
<para>
second
</para>
</listitem>
<listitem>
<para>
third
</para>
</listitem>
</itemizedlist>
  
  • first

  • second

  • third

[a] is 6 times 7

6. MySQL administration

How to grant priviledges/add users in a MySQL database:

fluffi@fiona:~> mysql -u root -p
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,\
  CREATE,DROP,REFERENCES ON WM2006.* TO user@localhost IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
[Note]Note
If you are using MySQL 4, you can also grant LOCK TABLES and CREATE TEMPORARY TABLES permissions.
mysql> GRANT LOCK TABLES ON WM2006.* TO user@localhost;
mysql> GRANT CREATE TEMPORARY TABLES ON WM2006.* TO user@localhost;
mysql> FLUSH PRIVILEGES;

Creating a database:

mysql> CREATE DATABASE WM2006;
Query OK, 1 row affected (0.00 sec)

7. The CVS

cvs remove | cat CVS/Entries| cut -d / -f2

leere Ordner löschen: cvs -q up -P

leere Ordner löschen: cvs -q up -P

cvs co -d localDir foo/bar

8. The Subversion

svn diff -r 32:31 MyClass.java

svn log MyClass.java

9. The Firefox