#############
# SSH + CVS #
#############
In .bashrc:
-----------
# CVS
CVS_RSH=ssh
#CVSROOT=:ext:simpson@194.8.220.121:/usr/local/cvs
#CVSROOT=:ext:FranzKlammer@222.33.20.75:/home/FranzKlammer/cvsroot
CVSROOT=:local:/usr/local/cvsroot
export CVS_RSH CVSROOT
Auf Kommandozeile:
-----------------
cvs -d :ext:simpson@tom.bennelux.be:/usr/local/cvs co hexi
cvs -d :ext:simpson@tom.bennelux.be:/usr/local/cvs ci hexi
Revision auscecken:
------------------
cvs update -r 1.6 Makefile
CVSROOT anlegen:
-------------------
> cvs init
Repository anlegen:
-------------------
Change to directory you want to import ( Here ~/XML ):
> cvs import -m "test" PATH/IN/REPOSITORY/XML proFILE start
#################
# DATUM + ZEIT: #
#################
Zeit einstellen:
----------------
rosamunde:/usr/people/simpson # date -s '11:09:00' +'%HH:%MM:%SS'
11H:09M:00S
Tag um eins vorstellen:
----------------------
rosamunde:/usr/people/simpson # date -s +"1 day"
Fri Sep 8 12:17:24 MEST 2000
Tag und Zeit einstellen:
-------------------------
rosamunde:/usr/people/simpson # date -s '2001-04-18 22:09:00' +'%Y-%m-%d %HH:%MM:%SS'
2001-04-18 22H:09M:00S
######################
# Der "find" Befehl: #
######################
# find all directories and give those out that are not a CVS directory
$ find . -type d -print | fgrep -v CVS
# find all directorys with the name CVS
$ find . -name CVS -type d -print
# add all files that are not cvs files to repository
$ find . -type f -print | fgrep -v CVS | xargs cvs add
# add all files with ending bz2 to repository
$ find . -name *.bz2 -print -exec cvs add -kb {} \;
# execute something on the found files
$ find /wa/simpson/hexi/ -name *.o -exec echo {} \;
$ find /wa/simpson/hexi/ -name *.o -print
$ find -name *.o -o -name *.moc -o -name .snprj -o -name *.dep -o -name tags -o -iname *.out -o -iname *.bak -o -iname *.old-o -name moc_* -o -name *~ | xargs rm -rvf;
# find all files that are bigger that 1 kilobyte
$ find /var/log/ -type f -size +1k -exec ls -la {} \;
######
# QT #
######
QTDIR=/usr/local/qt
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
########################
# Audio Cd's auslesen: #
########################
> mkdir myCd
> cd myCd
// Liest alle tracks von /dev/hdc aus und gibt
// Ihnen den Name track01.cdda.wav etc.
// Wenn nur ein Cdromlaufwerk vorhanden ist
// kann man -d weglassen. Wenn nur tracks 3-6 dann -B 3-6
> cdparanoia -d /dev/hdc -B
######################################
# Mpeg Dateien aus *.wav generieren: #
######################################
Mit mlame oder auenc ( in den compilierten Sourcen von Lame !)
können mehrere *.wav in einen Rutsch in *.mpeg files geschrieben werden.
Siehe mlame -?
> mlame -f -h *.w
Einzelne *.wav files:
--------------------
lame -h input.wav output.mp3
####################################
# OGG Dateien aus *.wav generieren #
####################################
#!/bin/bash
# encode all *.wav files in the current directory to ogg files
# and replace suffix .wav by suffix .ogg
# ATTENTIONE: do not use empty spaces in Artist and Title name
ARTIST=big_audio_dynamite
ALBUM=this_is_big_audio_dynamite
BITRATE=128
for FILE in `ls *.wav`;
do
echo $FILE;
oggenc $FILE -b $BITRATE -t "`basename $FILE .wav`" -a $ARTIST -l $ALBUM;
done;
# -t title
# -b bitrate
# -a artist name
# -l album name
####################################
# Eins zu eins Kopie mit "readcd": #
####################################
1. Ganze Cd von Laufwerk dev=0,4,0 in file cdiamge.raw auslesen:
> readcd -v dev=0,4,0 f=cdimage.raw
2. Cd Images mit Loopback testen:
> mount cdimage.raw -t iso9660 -o loop /mnt/floppy
3. Cd brennen:
> cdrecord -v speed=4 dev=0,4,0 cdimage.raw
##############
# CD-Brennen:#
##############
> mkisofs -r -J -o /tmp/imageBoot.raw /daten/backup/
> cdrecord -scanbus //Gibt devices aus
> cdrecord -v speed=2 dev=0,2,0 /tmp/imageBoot.raw
On-the-fly brennen:
-------------------
> mkisofs -R -J poster_a3_6-2/ | cdrecord -fs=10m -v speed=2 dev=0,4,0 -
AUDIO BRENNEN:
--------------
> cdrecord -v speed=1 dev=0,4,0 -audio *.wav
OVERBURNING FOR DATA > 700 MB:
--------------------------------
cdrecord -v -eject -dao -overburn dev=0,1,0 big.img
##########################
# Serielle Schnittstelle #
##########################
Serielle Schnittstelle einstellen:
----------------------------------
/usr/people/simpson/Desktop > stty -hupcl -crtscts parenb -parodd cs8 38400 < /dev/ttyS1
bash@: setserial /dev/ttyS0 uart 16550A port 0x03f8 irq 4 spd_normal skip_test
Serielle Schnittstelle abfragen:
-------------------------------
simpson@rosamunde:/usr/people/simpson/Desktop > stty -a < /dev/ttyS1
simpson@rosamunde:/usr/people/simpson/Desktop > stty -a -F /dev/ttyS1
root@simpson:/home/simpson > setserial -G /dev/ttyS1
/dev/ttyS1 uart 16550A port 0x02f8 irq 3 spd_normal skip_test
root@simpson:/home/simpson > setserial /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
root@simpson:/home/simpson > setserial -a /dev/ttyS1
/dev/ttyS1, Line 1, UART: 16550A, Port: 0x02f8, IRQ: 3
Baud_base: 115200, close_delay: 50, divisor: 0
closing_wait: 3000, closing_wait2: infinte
Flags: spd_normal skip_test
#########################
# Interupts beobachten: #
#########################
bash@: xosview
##################################################
# Speicherbelegung einzelner Programme abfragen: #
##################################################
> gtop
####################
# Harddisk clonen: #
####################
Partitionen mit Nullen ausfüllen:
---------------------------------
> df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda7 3980832 1447040 2331564 38% /
/dev/hda5 21927 1403 19392 7% /boot
/dev/hda3 1718872 22700 1608856 1% /tmp
/dev/hda1 2044704 866776 1177928 42% /win
> dd if=/dev/zero of=/boot/rawNull bs=1k count=19392
> rm /boot/rawNull
Schreiben und packen der Partition:
-----------------------------------
dd if=/dev/hda5 | bzip2 > /tmp/boot.raw.bz2
Testen der Partition:
---------------------
> bunzip2 /tmp/boot.raw.bz2
> mount /tmp/boot.raw -t ext2 -o loop /mnt/
oder:
> mount -t iso9660 -o loop /tmp/boot.raw /mnt
Brennen der CD:
---------------
> mkisofs -r -J -o /tmp/imageBoot.raw /tmp/boot.raw.bz2
> cdrecord .....
Zurückschreiben der Partition:
------------------------------
> bunzip2 /tmp/boot.raw.bz2
> dd if=/tmp/boot.raw of=/dev/hda5
#######
# RPM #
#######
RPM Pakete in ein anderes Verzeichniss installieren:
-----------------------------------------------------
1. rpm -i -relocate /usr/bin=/sbin --badreloc deinpacket.rpm
2. RPM Pakete probeweise auspacken:
Bin?rpakete im RPM Format sind recht praktisch, denn alle Dateien werden
automatisch und ohne manuelle Arbeit an die richtige Stelle kopiert.
Manchmal ist die richtige Stelle aber nicht die gew?nschte.
Mit folgender Zeile kann man ein RPM Paket im lokalen Verzeichniss
auspacken. Dabei wird ein neuer Verzeichnissbaum angelegt, so daá man
leicht verifizieren kann wohin die einzelnen Dateien kopiert werden.
rpm2cpio paket.rpm | cpio -i -d
Abfagen welche Pakete instaliert sind:
--------------------------------------
> rpm -qa
####################
# Pcmcia Ethernet: #
####################
> cardctl ident 0
product info: "PCMCIA", "LNT-10TN", "1.0"
manfid: 0x0000, 0x0100
function: 6 (network)
> lsmod
Module Size Used by
pcnet_cs 9600 1
8390 6868 0 [pcnet_cs]
ds 6920 2 [pcnet_cs]
i82365 23864 1
pcmcia_core 48192 0 [pcnet_cs ds i82365]
nls_cp437 3744 1 (autoclean)
vfat 9404 1 (autoclean)
fat 31104 1 (autoclean) [vfat]
#########
# whois #
#########
whois -h whois.ripe.net 79.131.2.214 // Europa
whois -h whois.arin.net 79.131.2.214 // USA
whois -h whois.apnic.net 79.131.2.214 // ASIA / PACIFIC
whois -h whois.nic.mil %79.131.2.214 // Military
############
# nslookup #
############
wird durch "host" befehl ersetzt !
simpson@simpson:~ > nslookup
Default Server: lisi.mundi.com
Address: 222.33.20.10
> lucona.com
Server: lisi.mundi.com
Address: 222.33.20.10
Non-authoritative answer:
Name: lucona.com
Address: 212.172.124.124
> set domain=lucona.com
> set type=ANY
> lucona.com
Server: lisi.mundi.com
Address: 222.33.20.10
Non-authoritative answer:
lucona.com nameserver = ns1.ams-firmen.de
lucona.com nameserver = ns2.ams-firmen.de
lucona.com internet address = 212.172.124.124
Authoritative answers can be found from:
lucona.com nameserver = ns1.ams-firmen.de
lucona.com nameserver = ns2.ams-firmen.de
ns1.ams-firmen.de internet address = 64.133.174.2
ns2.ams-firmen.de internet address = 64.133.115.2
> set type=WKS
> lucona.com
Server: lisi.mundi.com
Address: 222.33.20.10
lucona.com
origin = ns1.ams-firmen.de
mail addr = hostmaster.ams-firmen.de
serial = 2000031001
refresh = 28800 (8H)
retry = 7200 (2H)
expire = 604800 (1W)
minimum ttl = 86400 (1D)
> set type=MX
> lucona.com
Server: lisi.mundi.com
Address: 222.33.20.10
lucona.com preference = 10, mail exchanger = ams-firmen.de
lucona.com preference = 20, mail exchanger = mail.lucona.com
lucona.com nameserver = ns1.ams-firmen.de
lucona.com nameserver = ns2.ams-firmen.de
ams-firmen.de internet address = 64.133.210.23
mail.lucona.com internet address = 64.133.210.2
ns1.ams-firmen.de internet address = 64.133.174.2
ns2.ams-firmen.de internet address = 64.133.115.2
####################
# Display umleiten #
####################
AUF ANDEREN RECHNER:
--------------------
simpson@lisi:~/wa > setenv DISPLAY simpson.mundi.com:0.0
bash: setenv: command not found
simpson@lisi:~/wa > export DISPLAY=simpson.mundi.com:0.0
simpson@lisi:~/wa > echo $DISPLAY
simpson.mundi.com:0.0
AUF EIGENEN RECHNER:
--------------------
simpson@modda:~ > xhost lisi
access control enabled, only authorized clients can connect
INET:localhost
INET:modda.mundi.com
LOCAL:
simpson@modda:~ > man xhost
Formatiere xhost(1x) neu, bitte warten...
simpson@modda:~ > xhost +
access control disabled, clients can connect from any host
simpson@modda:~ > grep modda /etc/hosts
222.33.20.70 modda.mundi.com modda
###############
# Framebuffer #
###############
XF86Config:
-----------
# SaX autogenerated XF86Config file
# This file was generated from the SaX
# Version: 2.8 - sax@suse.de
# Date: Thu Apr 27 19:51:16 CEST 2000
# Xserver:FBDEV
# MouseVendor:Unknown
# MouseName:Unknown
# RamDac:204
# Dac8:204
# Dac16:204
# Dac24:204
# Dac32:204
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/URW"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
EndSection
Section "ServerFlags"
AllowMouseOpenFail
EndSection
Section "Module"
EndSection
# This section is no longer supported
# See a template below
# Section "XInput"
# EndSection
Section "Keyboard"
Protocol "Standard"
XkbRules "xfree86"
XkbModel "pc104"
XkbLayout "de"
XkbVariant "nodeadkeys"
EndSection
Section "Pointer"
Protocol "PS/2"
Device "/dev/psaux"
SampleRate 60
Emulate3Buttons
Emulate3Timeout 200
BaudRate 1200
EndSection
Section "Monitor"
Identifier "Primary-Monitor"
VendorName "!!! VESA !!!"
ModelName "1024X768@75HZ"
HorizSync 31-69
VertRefresh 50-85
Modeline "1024x768" 90.44 1024 1040 1216 1328 768 768 778 802
Modeline "800x600" 55.33 800 816 928 1040 600 600 608 626
EndSection
Section "Device"
Identifier "Primary-Card"
VendorName "!!! GENERIC SERVER SELECTION !!!"
BoardName "FRAMEBUFFER"
EndSection
Section "Screen"
Driver "fbdev"
Device "Primary-Card"
Monitor "Primary-Monitor"
# DefaultColorDepth 8
SubSection "Display"
Depth 16
Modes "default"
Virtual 1024 768
EndSubSection
++++++++++++++++++++++++++++++++++ END XF86Config +++++++++++++++++++++++++++++++++++++++++++++++++++++
##############################################
# Mehrere Seiten auf einen Blatt ausdrucken: #
##############################################
> acroread -toPostScript -size a4 -level3 text.pdf
> psnup -n 2 text.ps text2.ps
> lpr text2.ps
p.s. psnup -n 4 muesste auch gehen, hab ich aber noch nie probiert.
#########
# CTAGS #
#########
Ctags merken sich die Funktionsaufrufe in C files and man kann Sie verwenden um
z.b: einen markierten Funktionsnamen in nedit anzuspringen, wenn man zuerst das
entsprechende ctag file geladen hat.
> find . \( -name '*.cc' -or -name '*.h' \) -print | xargs ctags -x --c-types=+c+d+e+f+C | more
###############
# Latex2Html: #
###############
Kommandozeile:
--------------
latex2html -no_math -html_version 4.0,math,frame -accent_images textrm -scalable_fonts -short_index -split 4 -link 3 -toc_depth 6 -t LaTeX2HTML Net.tex
oder:
latex2html -split 0 -index_in_navigation -contents_in_navigation -show_section_numbers admin_setup.tex
#############
# Sendmail: #
#############
BEFEHL:
-------
> mail -v -s "Letter from myself" arno@quirxi.com < MyMail.txt
arno@quirxi.com... Connecting to local...
arno@quirxi.com... Sent
> mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/arno": 1 message 1 new
>N 1 arno@arno.profile.co Mon Dec 17 18:01 459/22711 "Letter from myself"
& 1
Message 1:
From arno Mon Dec 17 18:01:31 2001
Date: Mon, 17 Dec 2001 18:01:31 +0100
From: Arno Wilhelm <arno(ad)qurixi.com>
To: arno(ad)qurixi.com
Subject: Letter from myself
...
...
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ODER:
> mail -s "Kommandozeilen Mail" simpson.humer@mundi.com
Hallo Arno,
Wie geht's ? Ich wollte nur mal testen, ob es mit den Kommandozeilenmail auch funktioniert.
Grüsse, Arno
.
EOT
>
########################
# "diff" und "patch": #
########################
OLD FILE:
---------
> cat difftest_old
This is the old text !
This is the old text !
This is the old text !
This is the old text !
This is the old text !
NEW FILE:
---------
> cat difftest_new
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the END :-]
CREATING PATCH FILE:
-------------------
> diff difftest_old difftest_new > difftest.patch
PATCH FILE:
-----------
> cat difftest.patch
2c2
<
---
> This is the new text !
4c4
<
---
> This is the new text !
6,8c6
<
< This is the old text !
<
---
> This is the new text !
9a8,9
> This is the new text !
> This is the END :-]
PATCHING "difftest_old" WITH "difftest.patch" AND WRITING OUTPUT TO "difftest.patched":
----------------------------------------------------------------------------------------
> patch -o difftest.patched difftest_old difftest.patch
patching file difftest_old
NOW PATCHED FILE LOOKS LIKE NEW FILE:
-------------------------------------
> cat difftest.patched
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the old text !
This is the new text !
This is the END :-]
##############################
# Infrared with Siemens S25: #
##############################
Enable Infrared in your Bios;
Enable Infrared in your Kernel -> see HowTo;
Download irda-utils and install them;
Have a look under Windows witch port + irq;
Make device files for Irda:
woaka@modda:../configs> ls -la /dev/ir*
crw-r--r-- 1 root root 161, 0 Jan 21 20:36 /dev/ircomm0
crw-r--r-- 1 root root 161, 1 Jan 21 20:32 /dev/ircomm1
crw-r--r-- 1 root root 161, 16 Jan 15 00:13 /dev/irlpt0
crw-r--r-- 1 root root 161, 17 Jan 15 00:11 /dev/irlpt1
with:
mknod /dev/ircomm0 c 161 0
Put in your /etc/modules.conf:
# IrDA over a normal serial port, or a serial port compatible IrDA port
alias tty-ldisc-11 irtty
alias irlan0 irlan
# IrCOMM (for printing, PPP, Minicom etc. )
alias char-major-161 ircomm-tty
Run:
woaka@modda:../configs> depmod -a
woaka@modda:../configs> irattach /dev/ttyS1 -s
IMPORTANT: you should now here the infrared detection !
After this, detection should start (due to the -s option) and IRDA devices
within the range should be reported by
woaka@modda:../configs> cat /proc/net/irda/discovery
IrLMP: Discovery log:
nickname: SIEMENS S25, hint: 0x9024, saddr: 0xb7b9fd35, daddr: 0x0000c201
Note that you have to specify a different /dev/ttyS? if you use a IR port setup other than COM2.
3.2 SIR using irport
Make sure the IR port is not configured as an ordinary serial device.
woaka@modda:../configs> setserial /dev/ttyS1 uart none
Then, load the irport driver (make sure the `irda' module is already
loaded)
woaka@modda:../configs> modprobe irda
When using minicom, set the serial device to /dev/ircomm0.
Settings for Nokia S25:
9600 8N1
/dev/ircomm0
HardwareFlow
################################################
# GENERATING SOURCES FROM DESIGNERS *.ui FILES #
################################################
#Generating a *.pro file:
TEMPLATE = app
CONFIG = qt warn_on release
HEADERS = HumphreyAdmin.h HumphreyAdminImpl.h
SOURCES = main.cc HumphreyAdminImpl.cpp HumphreyAdmin.cpp
INTERFACES = HumphreyAdmin.ui
TARGET = HumphreyAdmin
------------------------------------------------------------------
#The main.cc file:
#include <qapplication.h>
#include "HumphreyAdminImpl.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
HumphreyAdminImpl * humphrey = new HumphreyAdminImpl;
humphrey->show();
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
return a.exec();
}
------------------------------------------------------------------
#Generating the header file out of the *.ui file:
> uic -o HumphreyAdmin.h HumphreyAdmin.ui
------------------------------------------------------------------
#Generating the header file out of the *.ui the file:
> uic -i HumphreyAdmin.h -o HumphreyAdmin.cpp HumphreyAdmin.ui
------------------------------------------------------------------
#Generating the implementations header file:
> uic -subdecl HumphreyAdminImpl HumphreyAdmin.h HumphreyAdmin.ui > HumphreyAdminImpl.h
------------------------------------------------------------------
#Generating the implementations *.cpp file:
> uic -subimpl HumphreyAdminImpl HumphreyAdminImpl.h HumphreyAdmin.ui > HumphreyAdminImpl.cpp
------------------------------------------------------------------
#Generating the Makefile:
> tmake -o Makefile HumphreyAdmin.pro
------------------------------------------------------------------
####################################
# Sourcenavigator external editor: #
####################################
nc -noask -svrname snav -line %l %f
#################################
# Targets aus Makefile filtern: #
#################################
> make -qp | egrep '^[\ \t]*[A-Za-z0-9_-]+[:]+[^:=]*$'| sed 's,:.*$,,g'
##############
# Autotrace: #
##############
Speichern eines Schriftzuges, Bildes etc. als tga, pbm, pnm, pgm, ppm oder bmp.
z.B.: test.bmp
> autotrace test.bmp > test.eps
Anschauen des *.eps Bildes mit gv oder ghostview !
########################
# Shell Proammierung: #
########################
#!/bin/sh
for file in $( ls *.tar.gz ); do \
tar xvzf $file; \
echo $file; \
done
----------------------------------
# 2 Version
ls *.gz | while read a; do echo $a; done
cat MYTEXT | while read line; do "echo > $line"; done
----------------------------------
# Endlessloop
while true; do netcat -l -p 3333 > OUTFILE; done
----------------------------------
while [ condition ]
do
statements
done
"While" statements are typically used to loop a certain number of times,
as in the following example, which will loop exactly 10 times:
myvar=0
while [ $myvar -ne 10 ]
do
echo $myvar
myvar=$(( $myvar + 1 ))
done
You can see the use of arithmetic expansion to eventually cause the
condition to be false, and the loop to terminate.
"Until" statements provide the inverse functionality of "while"
statements: They repeat as long as a particular condition is false.
Here's an "until" loop that functions identically to the previous
"while" loop:
myvar=0
until [ $myvar -eq 10 ]
do
echo $myvar
myvar=$(( $myvar + 1 ))
done
################################################
# Changing pathnames in several files at once: #
################################################
#!/bin/bash
FILELIST="files.txt"
FIND=`which find`
GREP=`which grep`
SED=`which sed`
RM=`which rm`
MV="mv -vf"
MYNAME=`basename $0`
$FIND . -type f | xargs $GREP -lz 'net/igel' > $FILELIST
for FILE in `cat $FILELIST`; do
FILENAME=`basename $FILE`
if [ ${FILENAME} != ${MYNAME} ]; then
$SED "s/net\/igel/net\vogel//g" ${FILE} > ${FILE}.tmp
$MV ${FILE}.tmp ${FILE}
fi
done
$RM $FILELIST
##########
# TMPFS: #
##########
- Ab Kernel 2.4 !
> mkdir MOUNTPOINT
> mount tmpfs MOUNTPOINT -t tmpfs
Creating a tmpfs filesystem with a maximum size is easy.
To create a new tmpfs filesystem with a maximum filesystem size of 32 MB, type:
> mount tmpfs /dev/shm -t tmpfs -o size=32m
This time, instead of mounting our new tmpfs filesystem at /mnt/tmpfs,
we created it at /dev/shm, which is a directory that happens to be the "official" mountpoint for a tmpfs filesystem.
If you happen to be using devfs, you'll find that this directory has already been created for you.
Also, if we want to limit the filesystem size to 512 KB or 1 GB,
we can specify size=512k and size=1g, respectively.
In addition to limiting size, we can also limit the number of inodes (filesystem objects)
by specifying the nr_inodes=x parameter.
When using nr_inodes, x can be a simple integer,
and can also be followed with a k, m, or g to specify thousands, millions, or billions (!) of inodes.
Also, if you'd like to add the equivalent of the above mount tmpfs command to your /etc/fstab, it'd look like this:
tmpfs /dev/shm tmpfs size=32m 0 0
##########################################################
# Ifconfig -> Beispiel zum einrichten einer Netzwekkarte #
##########################################################
ifconfig eth0 222.33.20.63 broadcast 222.33.20.255 netmask 255.255.255.0 up
#
# Beispiel zum runterfahren einer Netzwekkarte
#
ifconfig eth0 down
#####################
# The netlink tools #
#####################
# Getting ip address/devices (you have to be root and the netlink tools installed)
#
# allowed shortcuts:
#
# address a
# route r
# show s
# add a
# delete d
# set s
# get g
#
# syntax:
#
# ip address|route|link show|add|delete|set|get [ip-addressss/mask] [dev [device]] [up|down]
#
# getting the ip addresses
> ip address show # is the same as: "ip a s" or: "ip a"
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:03:47:c4:0d:75 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 brd 192.168.0.255 scope global eth0
13: ppp0: mtu 1500 qdisc pfifo_fast qlen 3
link/ppp
inet 80.121.6.248 peer 172.19.92.167/32 scope global ppp0
# getting the routing table
> ip route show # the same as: "ip r s" or: "ip r"
172.19.92.167 dev ppp0 proto kernel scope link src 80.121.6.248
192.168.0.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 172.19.92.167 dev ppp0
# getting the devices
> ip link show # the same as: "ip l s" or: "ip l"
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:03:47:c4:0d:75 brd ff:ff:ff:ff:ff:ff
13: ppp0: mtu 1500 qdisc pfifo_fast qlen 3
link/ppp
# deleting an ip address
# before deleting:
> ip a s dev eth0 # = ip address show dev eth0
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:03:47:c4:0d:75 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 scope global eth0
# deleting the ip: "ip address delete 192.168.0.1/24 dev eth0"
> ip a d 192.168.0.1/24 dev eth0
# after deleting:
> ip a s dev eth0
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:03:47:c4:0d:75 brd ff:ff:ff:ff:ff:ff
# shutting down a device ( ip link set dev eth0 down ):
>ip l s dev eth0 down
# adding an ip address ( = ip address add 192.168.0.1/24 dev eth0 ):
> ip a a 192.168.0.1/24 dev eth0
# the result:
> ip a s dev eth0
2: eth0: mtu 1500 qdisc pfifo_fast qlen 100
link/ether 00:03:47:c4:0d:75 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 scope global eth0
# starting up a device ( not always necessary )
> ip l s dev eth0 up
# getting the route to a specific address ( = ip route get 198.168.0.10 )
> ip r get 198.168.0.10
198.168.0.10 via 172.19.92.167 dev ppp0 src 80.121.6.248
cache mtu 1500 advmss 1460
# deleting a route ( = ip route delete 192.168.0.0/24 dev eth0 ):
> ip r d 192.168.0.0/24 dev eth0
# the result
>ip r
172.19.92.167 dev ppp0 proto kernel scope link src 80.121.6.248
127.0.0.0/8 dev lo scope link
default via 172.19.92.167 dev ppp0
# setting a route ( ip route add 192.168.0.0/24 dev eth0 ):
> ip r a 192.168.0.0/24 dev eth0
# the result
root@Jambalaya root # ip r
172.19.92.167 dev ppp0 proto kernel scope link src 80.121.6.248
192.168.0.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 172.19.92.167 dev ppp0
# settin the default route
# before setting the default route
> ip r
172.19.92.167 dev ppp0 proto kernel scope link src 80.121.6.248
192.168.0.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
# setting the default route ( = ip route add default dev ppp0):
> ip r a default dev ppp0
# after setting the default route
> ip r
172.19.92.167 dev ppp0 proto kernel scope link src 80.121.6.248
192.168.0.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default dev ppp0 scope link
#########################################################
# Schnelles kopieren von ganzen Verzeichnissen mit tar: #
#########################################################
tar cBf - . | (cd /usr/dist; tar xBf -)
#######################################
# Sourcecode zum drucken aufbereiten: #
#######################################
> enscript kamera.cpp -pkamera_cpp.ps
oder mit a2s:
> a2ps kamera.cpp -o kamera_cpp.ps
###########################################
# Meaning of special keys on the console: #
###########################################
Attention: the "^" sign means the <Strg> key on german keyboards !
^l = clear screen
^c = clear line
^m = enter
^o = enter
^j = enter
^a = go to beginning of line
^e = go to end of line
^d = delete char under cursor ( delete forwards )
^h = delete char defore cursor ( delete backwards )
^8 = delete char defore cursor ( delete backwards )
^w = delete from char before cursor till beginnng of this word
^u = delete from char before cursor till beginnng of line
^k = delete from char under cursor till end of line
^ä = delete from char under cursor till end of word
^7 = undo
^ß = repeat last commands like ^p
^p = arrow up ( previous )
^n = arrow down ( next )
^b = arrow left ( back )
^f = arrow right ( forward )
^t = exchange two chars before cursor
^r = search in bash history
^q = clear input buffer in case someting is broken !
#######################################
# Hexdump and formatting it's output: #
#######################################
-> Formatfile "hexformat_1.txt":
------------ snip ------------
"%06.6_ad : " 16/1 "%02.2X "
"\t\t" "%_p "
"\n"
------------ snip ------------
-> Usage:
---------
> hexdump -f hexformat_1.txt -n 400 FILE2DUMP
-f: formatfile to be used (see above)
-n: number of bytes to dump
-s: offset from where to begin to dump binary file in bytes
FILE2DUMP: binary file that should be dumped
-> Output:
----------
000000 : 7F 45 4C 46 01 01 01 00 00 00 00 00 00 00 00 00 . E L F . . . . . . . . . . . .
000016 : 02 00 03 00 01 00 00 00 90 A7 04 08 34 00 00 00 . . . . . . . . . . . . 4 . . .
000032 : 41 AC 03 00 00 00 00 00 34 00 20 00 06 00 28 00 A . . . . . . . 4 . . . . ( .
000048 : 1B 00 1A 00 06 00 00 00 34 00 00 00 34 80 04 08 . . . . . . . . 4 . . . 4 . . .
000064 : 34 80 04 08 C0 00 00 00 C0 00 00 00 05 00 00 00 4 . . . . . . . . . . . . . . .
000080 : 04 00 00 00 03 00 00 00 F4 00 00 00 F4 80 04 08 . . . . . . . . . . . . . . . .
000096 : F4 80 04 08 13 00 00 00 13 00 00 00 04 00 00 00 . . . . . . . . . . . . . . . .
000112 : 01 00 00 00 01 00 00 00 00 00 00 00 00 80 04 08 . . . . . . . . . . . . . . . .
000128 : 00 80 04 08 D7 9B 03 00 D7 9B 03 00 05 00 00 00 . . . . . . . . . . . . . . . .
000144 : 00 10 00 00 01 00 00 00 E0 9B 03 00 E0 2B 08 08 . . . . . . . . . . . . . + . .
000160 : E0 2B 08 08 BC 06 00 00 64 10 00 00 06 00 00 00 . + . . . . . . d . . . . . . .
000176 : 00 10 00 00 02 00 00 00 EC A1 03 00 EC 31 08 08 . . . . . . . . . . . . . 1 . .
000192 : EC 31 08 08 B0 00 00 00 B0 00 00 00 06 00 00 00 . 1 . . . . . . . . . . . . . .
000208 : 04 00 00 00 04 00 00 00 08 01 00 00 08 81 04 08 . . . . . . . . . . . . . . . .
000224 : 08 81 04 08 20 00 00 00 20 00 00 00 04 00 00 00 . . . . . . . . . . . . . .
000240 : 04 00 00 00 2F 6C 69 62 2F 6C 64 2D 6C 69 6E 75 . . . . / l i b / l d - l i n u
000256 : 78 2E 73 6F 2E 32 00 00 04 00 00 00 10 00 00 00 x . s o . 2 . . . . . . . . . .
000272 : 01 00 00 00 47 4E 55 00 00 00 00 00 02 00 00 00 . . . . G N U . . . . . . . . .
-> Formatfile "hexformat_2.txt":
------------ snip ------------
"%06.6_ad : " 8/1 "%3_u "
"\t\t" "%_p "
"\n"
------------ snip ------------
-> Usage:
---------
> hexdump -f hexformat_2.txt -n 400 FILE2DUMP
-f: formatfile to be used (see above)
-n: number of bytes to dump
-s: offset from where to begin to dump binary file in bytes
FILE2DUMP: binary file that should be dumped
-> Output:
----------
-------
000000 : del E L F soh soh soh nul . E L F . . . .
000008 : nul nul nul nul nul nul nul nul . . . . . . . .
000016 : stx nul etx nul soh nul nul nul . . . . . . . .
000024 : 90 a7 eot bs 4 nul nul nul . . . . 4 . . .
000032 : A ac etx nul nul nul nul nul A . . . . . . .
000040 : 4 nul nul ack nul ( nul 4 . . . . ( .
000048 : esc nul sub nul ack nul nul nul . . . . . . . .
000056 : 4 nul nul nul 4 80 eot bs 4 . . . 4 . . .
000064 : 4 80 eot bs c0 nul nul nul 4 . . . . . . .
000072 : c0 nul nul nul enq nul nul nul . . . . . . . .
000080 : eot nul nul nul etx nul nul nul . . . . . . . .
000088 : f4 nul nul nul f4 80 eot bs . . . . . . . .
000096 : f4 80 eot bs dc3 nul nul nul . . . . . . . .
000104 : dc3 nul nul nul eot nul nul nul . . . . . . . .
000112 : soh nul nul nul soh nul nul nul . . . . . . . .
000120 : nul nul nul nul nul 80 eot bs . . . . . . . .
000128 : nul 80 eot bs d7 9b etx nul . . . . . . . .
000136 : d7 9b etx nul enq nul nul nul . . . . . . . .
000144 : nul dle nul nul soh nul nul nul . . . . . . . .
000152 : e0 9b etx nul e0 + bs bs . . . . . + . .
000160 : e0 + bs bs bc ack nul nul . + . . . . . .
000168 : d dle nul nul ack nul nul nul d . . . . . . .
000176 : nul dle nul nul stx nul nul nul . . . . . . . .
000184 : ec a1 etx nul ec 1 bs bs . . . . . 1 . .
000192 : ec 1 bs bs b0 nul nul nul . 1 . . . . . .
000200 : b0 nul nul nul ack nul nul nul . . . . . . . .
000208 : eot nul nul nul eot nul nul nul . . . . . . . .
000216 : bs soh nul nul bs 81 eot bs . . . . . . . .
000224 : bs 81 eot bs nul nul nul . . . . . . .
000232 : nul nul nul eot nul nul nul . . . . . . .
000240 : eot nul nul nul / l i b . . . . / l i b
000248 : / l d - l i n u / l d - l i n u
000256 : x . s o . 2 nul nul x . s o . 2 . .
000264 : eot nul nul nul dle nul nul nul . . . . . . . .
000272 : soh nul nul nul G N U nul . . . . G N U .
###########
# webcpp: #
###########
> webcpp INPUTFILE OUTPUTFILE.html -l -c=neon.scs
##################
# for i in `ls`: #
##################
$ for i in `ls`
> do
> gunzip $i
> done
##########
# ngrep: #
##########
$ ngrep -i -d ppp0 'user|pass|ogin'
interface: ppp0 (62.47.42.235/255.255.255.255)
match: user|pass|ogin
###############
T 62.47.42.235:32842 -> 137.226.116.98:21 [AP]
USER ftp..
##
T 137.226.116.98:21 -> 62.47.42.235:32842 [AP]
331 Anonymous login ok, send your complete email address as your password...
##
T 62.47.42.235:32842 -> 137.226.116.98:21 [AP]
PASS aaaa@bbbb.com..
##########
T 137.226.116.98:21 -> 62.47.42.235:32842 [AP]
some iso-CD images). Users from inside RWTH Aachen,..
################exit
48 received, 0 dropped
############
# useradd: #
############
> useradd -c "jonnni liliengraz" -d /home/jonni -g users -u 102 -s /bin/bash -m jonnni
#################
# change group: #
#################
> usermod -G video,dialout,audio,floppy,wheel,disk,uucp arno
###################
# removing CR-LF: #
###################
> tr -d '\015' < $OLDFILE > $NEWFILE
#######################
# Iindex and Isearch: #
#######################
# Index all xml files in the current directory recusively
# first collect the name of all xml files in files.txt
# then pass the names to Iindex.
> find . | egrep "\.xml$" > files.txt
i$ cat files.txt | Iindex -d index/TMP -m 20 -f -
# -m 20 means that Iindex can use 20 MB of memory
# -d index/TMP is the directory and name of the index to be created
# -f means that it should read the filenames from STDIN
# Now search a file:
Isearch -d index/TMP quirxi
# -d gives the index that should be searched for the name quirxi
# If the search is sucessful the filenames of the files containing
# the keyword quirxi are listed.
#############
# UUENCODE: #
#############
Encode binary files, so that they can be transmitted via Email.
SYNTAX: uuencode -m INFILE NAME_OF_FILE_IN_ATTACHMENT [>|] [OUTPUTFILE OUTPUTCOMMAND]
-m: encode with base64
> gzip Makefile
> uuencode Makefile.gz Makefile.gz | mail -s "uuencode test" a.w@quixi.com
Unpacking encoded file.
First save attachment in mail to ATTACHMENT, then decode it like this:
> uudecode ATTACHMENT
> ls -l
-rw------- 1 arno users 1244 Feb 14 00:33 ATTACHMENT
-rw-r--r-- 1 arno users 881 Feb 14 00:34 Makefile.gz
##############
# PS + TREE: #
##############
> ps -aux --forest
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 985 0.0 0.0 1320 376 tty3 S Jan25 0:00 /sbin/agetty 38400 tty3 linux
root 1018 0.0 0.0 2496 492 ? S Jan25 0:00 /usr/bin/kdm
root 10665 0.0 7.1 90704 36784 ? S Feb01 10:58 \_ /usr/X11R6/bin/X -auth /var/lib/kdm/authfiles/A:0-SLnWkT
root 18225 0.0 0.1 3288 840 ? S Feb05 0:00 \_ -:0
arno 18248 0.0 0.1 2216 864 ? S Feb05 0:00 \_ /bin/sh /usr/X11R6/lib/X11/xdm/Xsession kde
arno 18253 0.0 0.1 2204 804 ? S Feb05 0:00 \_ /bin/sh /usr/X11R6/bin/wm/kde
arno 18254 0.0 0.1 2220 876 ? S Feb05 0:00 \_ /bin/bash --login /usr/bin/startkde
arno 18356 0.0 0.9 12392 4776 ? S Feb05 0:00 \_ ksmserver --restore
root 18013 0.0 0.3 3888 1804 ? S Jan27 0:03 /usr/sbin/cupsd
...
...
############################
# Vgetty ansering machine: #
############################
##################
# AUFNEHMEN:
------------
> arecord -t 10 -s 7200 -w foobar.wav
##################
# UMWANDELN:
------------
> wavtopvf monty_python.wav | pvfspeed -s 7200 > monty_python.pvf
> pvftormd Elsa 2 monty_python.pvf monty_python.rmd
##################
# ABSPIELEN:
------------
> rmdtopvf monty_python.rmd | pvfspeed -s 8000 | pvftobasic > /dev/audio
##################
# INFO:
-------
> rmdfile monty_python.rmd
monty_python.rmd: RMD1
modem type is: "Elsa"
compression method: 0x0002
sample speed: 7200
bits per sample: 2
#########
# AWK : #
#########
# listing all *.mpg files and calculating the sum of their sizes by piping the std-output to awk.
ls -la *mpg | awk
'
BEGIN { printf "\n"; }
{ TOTAL += $5; printf "%s: = %d MB\n", $9, ( $5 / 1024 ) / 1024; }
END { printf "\n\nTOTAL = %d MB\n\n", (TOTAL / 1024) /1024; }
' -
# little command line renices all processes with the name transcode to priority 15.
> ps x | awk '/transcode/ { if ($5 != "awk") {printf "%s: %d\n", $5, $1; system( "renice 15 " $1 ); } }' -
###########
# NETCAT: #
###########
Syntax:
Server: netcat -l -p PORT
Client: netcat IP PORT
-l listening mode for server
-p portnumber
Example:
########
SERVER:
> netcat -l -p 3333
asdf
asdf
>
CLIENT:
> netcat localhost 3333
asdf
asdf
punt!
>
########
--> To write output of incoming connections to file:
> netcat -l -p PORT > OUTFILE
--> To respawn netcat server, after connection has been closed:
--> Attention: in order to get rid of process you have to kill -9 parent shell!
> while true; do netcat -l -p 3333; done
--> To transmit output of a commando to a server
> COMMAND | netcat IP PORT
--> If compiled with -DGAPING_SECURITY_HOLE the -e switch works: on new connection executable is called without parameters !
> netcate -l -p PORT -e EXECUTABLE
--> Send text to client
> echo MYTEXT | netcat -l -p PORT
----------------------------> Comunication with netcat:
SERVER:
-------
> netcat -l -p 3333
Hallo
Hi du
Wie geht's!
GUAAT..
punt!
>
CLIENT:
-------
arno@geaeini: arno> netcat localhost 3333
Hallo
Hi du
Wie geht's!
GUAAT..
>
-----------------------------> Cmd-Line:
CLIENT:
------
> nc
Cmd line: localhost 3333
Hi
du
Ei
!
punt!
>
SERVER:
-------
> netcat -l -p 3333
Hi
du
Ei
!
>
----------------------------> Puttin input in fifo and parsing output
> mkfifo fifi
SERVER:
-------
> netcat -l -p 3333 > fifi &
CLIENT:
------
> netcat localhost 3333
line 1
line 2
line 3
line 4
line 5
line 6
punt!
>
PARSER:
------
> X=0
> cat fifi | while read line; do echo $X: $line; let X=X+1; done
0: line 1
1: line 2
2: line 3
3: line 4
4: line 5
5: line 6
----------------------> Why does this not work???
CLIENT SENDING:
--------------
> netcat localhost 3333
line 1
> Line 4 received
line 2
line 3
punt!
>
PARSER:
-------
> cat IN | while read line; do echo "> Line $X received" > OUT ; echo $line; let X=X+1; done
line 1
SERVER:
-------
> cat OUT | netcat -l -p 3333 > IN &
[1] 13345
arno@geaeini: tmp>
#############################
# #
# Regular Expressions in C: #
# #
#############################
Test for using regularexpressions in C(++);
Since the GNU extensions did not work I had to use the Posix Regex Functions.
Here are some examples for test and use:
/////////////////////////////////////////////////////////////////////////////
//
// matching for videomachines: [second][second]:[frames][frames]
// where frames can maximal be 24
//
/////////////////////////////////////////////////////////////////////////////
a
aa
1
12
123
12:
12::
12::1
12:1
12:10
12:101
99:24
99:25
Matches single inputs:
^[0-9]{0,2}(:?)(([0-9]$)|([0-1][0-9]$)|([2][0-4]$))
Matches the whole:
^([0-9]?[0-9]):(([0-1][0-9]$)|([0-9]$)|([2][0-4]$))
/////////////////////////////////////////////////////////////////////////////
//
// matching for hardwareaddresses eg.: 00:02:44:37:7e:fd
//
/////////////////////////////////////////////////////////////////////////////
0:2:44:37:7e:fd
00:02:44:37:7e:fd
00:23:A3:11:FF:78
00:23:a3:11:ff:78
Pattern:
--------
^((([0-9 a-f A-F]{1,2}:){5})[0-9 a-f A-F]{1,2})$
/////////////////////////////////////////////////////////////////////////////
//
// matching of IP4 ip addresses
//
/////////////////////////////////////////////////////////////////////////////
Gesamte IpAdresse:
-----------------
^(([1]?[0-9]?[0-9]\.)|([2][0-5][0-5]\.)){3}(([1]?[0-9]?[0-9])|([2][0-5][0-5]))$
Eingabe IpAdresse:
------------------
(^(([1]?[1-9]?[0-9])|([2][0-5][0-5]))$)|(^((([1]?[1-9]?[0-9]\.)|([2][0-5][0-5])\.)){1,3}(([0-1]?[0-9]?[0-9])|([2][0-5][0-5]))?$)
127.0.1.0
192.168.0.20
255.255.255.0
256.255.224.88
10.20.0.122
10.20.0.122ddd
10.20.0.122222
2.12.133.9
.....
/////////////////////////////////////////////////////////////////////////////
//
// Others
//
/////////////////////////////////////////////////////////////////////////////
- Email validity, will only match email addresses which are valid, for instance user@host.com:
[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+
- Email validity #2, matches email addresses with a name in front, for instance "Joe Doe ":
("?[a-zA-Z]+"?[ \t]*)+\<[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+\>
- Protocol validity, matches web based protocols such as htpp://, ftp:// or https:// :
[a-z]+://
- C/C++ includes, matches valid include statements in C/C++ files:
^#include[ \t]+[<"][^>"]+[">]
- C++ end of line comments:
//.+$
- C/C++ span line comments, it has one flaw, can you spot it?:
/\*[^*]*\*/
- Floating point numbers, matches simple floating point numbers of the kind 1.2 and 0.5:
-?[0-9]+\.[0-9]+
Hexadecimal numbers, matches C/C++ style hex numbers, 0xcafebabe
0x[0-9a-fA-F]+