====== Linux Bash Commands ====== ===== for each file in a directory ===== for a in $(ls -1 *.tar.gz); do echo $a; done ===== tailf output weiternutzen ===== function mailIPs { tailf /var/log/mail.log | grep --line-buffered "postfix-in" | grep --line-buffered " connect from" | grep --line-buffered -Eo "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}"; } function handleLine { OUT=$(wget -qO- --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" "http://api.hostip.info/get_json.php?position=true&ip=$1" 2>&1); echo $OUT; } mailIPs | while read -r line; do handleLine $line ; done ===== hping3 SYN Flood ===== Um zu überprüfen wie ein Programm auf eine SYN-Paket Flut reagiert kann dieser Befehl genutzt werden: hping3 -S --flood -p -V ===== iPerf ===== jPerf (Java GUI) Server iperf -s -P 0 -i 1 -p 5001 -f k Client iperf -c 128.53.2.25 -P 10 -i 1 -p 5001 -f M -t 10 ''-P 10'' Parallell streams; ''-t 10'' Transmit in seconds (''-n'' as Bytes) ===== Recursive Directory Size - Sorted - Treesize ===== du -h /home | sort -h ===== Zeitraffer oder Diashow mit ffmpeg ===== ffmpeg -r 30 -i input%03d.jpg -codec copy output.mkv ===== Grep in tar.gz (tgzgrep) ===== function tgzgrep { rm -R /tmp/tgzgrep > /dev/null; mkdir /tmp/tgzgrep; tar -C /tmp/tgzgrep -xzf $2; grep -i "$1" /tmp/tgzgrep/*; } function mailgrep { rm -R /tmp/mailgrep; mkdir /tmp/mailgrep; tar -C /tmp/mailgrep -xzf 2013-03-20.mailarchive-in.tar.gz; grep -i "$@" /tmp/mailgrep/*; } ===== Check Postfix Maillog IPs with DNSBL ===== tac /var/log/mail.log | egrep "postfix-in(.*)client" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 5 | while read line ; do ./check_dnsbl.sh -H $line ; done ===== Run command aganst reqursive filelist ===== find ./ -type f -print0 | while read -d $'\0' -r file ; do md5sum "$file" | grep --line-buffered --only-matching -m 1 '^[0-9a-f]*' | sort done ===== Test Webserver ===== Antwortet mit Test-Server und dem aktuellen Datum while true; do { echo -e 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n'; echo 'Test-Server'; date; } | nc -l 64682; done