fragmented knowledge

bruchstückhaftes Wissen

svn: create ignore rules

Ignore rules effecting directories and only suport globbing (wildcard *)

svn propedit svn:ignore ./path

*.out
*.aux
*.toc
*.swp
*.tmp
*.log
*.out
*.exe
*.backup

shrink images (prevent data trash)

for i in `ls -1` ; do convert $i  -quality 85 -resize 3000  $i ; done

remote wireshark per ssh

ssh [TARGET] sudo tcpdump -i [INTERFACW] -U -w -port 22 | wireshark -i – -k

sort and rename files according to atime (bash)

IFS=$'\n' ; i=0 ; for file in `ls -1 -u --sort=time -r` ; do let i++; \
newfile=$(printf "%03d-%s" $i $file); mv $file $newfile ; done

SSH Portforwarding

local

I have no direct connection to binfalse.de:443, i have to tunnel through example.com.

CLIENT <--> SSH-GATEWAY <--> SERVER
^^^^^^      example.com      binfalse.de

ssh -L 9000:binfalse.de:443 user@example.com
ssh -L LOCALPORT:DESTADDR:DESTPORT SSH-GATEWAY

remote

I tell the SSH gateway to open up a port and forward this one to my machine.

CLIENT <--> SSH-GATEWAY <--> BigBadInternet
tcp/3000  example.com:9000  

ssh -R 9000:localhost:3000 user@example.com 

no tty

ssh -nNT -L 9000:binfalse.de:443 user@example.com

concatenate pdf files

pdftk *.pdf cat output onepdf.pdf

extract partition from image

sfdisk -l -uS image-file
dd if=image-file of=partition-file skip=NUM count=NUM

Linux Ramdisk

mount -o size=1G -t tmpfs none /mnt/tmpfs

awk oneliners:

http://www.pement.org/awk/awk1line.txt

Linux iptables: statisches NAT:

iptables -t nat -A PREROUTING -d 17.17.17.50 -i eth0 -j DNAT --to-destination 10.200.0.1
iptables -t nat -A POSTROUTING -s 10.200.0.1 -o eth1 -j SNAT --to-source 17.17.17.50

Linux iptables: Portforwarding:

iptables -t nat -A PREROUTING -p tcp -i eth2 -d 10.11.20.25 --dport 2222  -j DNAT --to 10.0.0.4:22

IPv6 privacy extensions unter Linux aktivieren (RFC3041):

sysctl net.ipv6.conf.wlan0.use_tempaddr=2

ASCII-armored PGP with Sylpheed

Der MUA Sylpheed ist nicht in der Lage ascii-armored gpg/pgp Nachrichten zu entschlüsseln. Man kann jedoch mit einer selbstdefinierten “Aktion” Abhilfe schaffen:

urxvt -e /bin/bash -c "/usr/bin/gpg -d %p | less"

convert an hex string to ascii, using perl:

perl -e 'chomp($HEX=); while($i < length($HEX)) {$PART=substr($HEX,$i,2);print chr(hex($PART)); $i=$i+2;}'

bash IFS-variable, only split on Newline:

export IFS=$'\n'

Next post: about