Linux Dump

scanning all network devices using arp-scan on network:
arp-scan –interface=eth1

or using nmap:
nmap -sP

iptables -t nat -A PREROUTING -p tcp -i eth0 -d –dport 10001 -j DNAT –to

iptables -A INPUT -i eth0 -s -j DROP

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

iptables-t nat-A PREROUTING -i eth0 -p TCP –dport4662 -j DNAT –to
iptables-t nat-A PREROUTING -i eth0 -p UDP –dport4672 -j DNAT –to

proxy port forwarding linux.
ssh -f -L 8080:localhost:8080 [email protected] sleep 9999

Limit traffic on the interface down to 220kbit/s
tc qdisc add dev eth0 root tbf rate 220kbit latency 50ms burst 1540

fixing table in mysql after crash:


SQL Error : 145 Table ‘./c64forum/phpbb_config’ is marked as crashed and
should be repaired

mysqlcheck –auto-repair c64forum phpbb_config

warning : Table is marked as crashed
warning : 2 clients are using or haven’t closed the table properly
status : OK

Quick backup (dump) of mysql database:

mysqldump -u user -p nameofdatabase > ch01032010.sql

piping ls to xargs:
ls -la|grep 2010-03-03|awk ‘{print $8}’|xargs -i -t mv {} /home/leming/perl/tmp/03032010/

cat access_log|egrep -o [0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+|uniq| while read q; do echo -n “IP:$q,”;host $q|awk -F’pointer ‘ ‘{print “hostname=”$2}’; done

sed -i ‘s/ugly/beautiful/g’ /home/bruno/old-friends/sue.txt

W: GPG error: etch Release: The following
signatures couldn’t be verified because the public key is not available:

apt-get install debian-archive-keyring

apt-get update

or rather this: (replace the key with the key thats popped up)
gpg –keyserver –recv-key 010908312D230C5F
gpg -a –export 010908312D230C5F | sudo apt-key add -


bacula compression on the fly – check the options in fileset.

FileSet {
Name = “Full Set”
Include {
Options {
signature = MD5
compression = GZIP
File = /etc
File = /home

———– compare two folders ————–

/usr/bin/comm -12

You can use different iptables parameters to limit connections to the SSH service
for specific time periods. You can use the /second, /minute, /hour, or /day
switch in any of the following examples.

In the first example, if a user enters the wrong password, access to the SSH
service is blocked for one minute, and the user gets only one login try per
minute from that moment on:

iptables -A INPUT -p tcp -m state –syn –state NEW –dport 22 -m limit
–limit 1/minute –limit-burst 1 -j ACCEPT
iptables -A INPUT -p tcp -m state –syn –state NEW –dport 22 -j DROP

In a second example, iptables are set to allow only host to
connect to the SSH service. After three failed login tries, iptables allows
the host only one login try per minute:

iptables -A INPUT -p tcp -s -m state –syn –state NEW
–dport 22 -m limit –limit 1/minute –limit-burst 1 -j ACCEPT
iptables -A INPUT -p tcp -s -m state –syn –state NEW
–dport 22 -j DROP
reverse SSH
2222 is the port that will appear on remote server.
ssh -nNT -R 2222:localhost:22
/usr/bin/rsync -avCzu –progress –timeout=999 -e ssh [email protected]:/home/user/ /local/folder/
list unique hosts with $9

cat /var/log/daemon.log|grep Compiled|awk ‘{print $9}’|sort|uniq
#list directories and chown each own name
find . -maxdepth 1 -type d|sed ‘s/.\///’|while read q;do chown -R $q.users $q/;done

# list all files within folder and print permissions and ownerships.

find /home/leming/ -type f -print0|xargs -0 stat -c “%a %U.%G %n”
working on:
find . -maxdepth 1 -type f|sed ‘s/.\///’|grep -e .com -e .net -e .uk -e .tv -e .info|grep -v ‘~$’|wc -l
Cannot find ssl headers on CentOS:
required: yum install openssl-devel
Exim delete from mailq:
exim -Mrm emailID

or automate:
mailq | grep “<>” | awk ‘{print $3}’ | xargs exim -Mrm


grep -H ’′ *.*|cut -d: -f1|while read q;do cp $q tmp/|sed -i ‘s/\s*[0-9]\{10\}\s*;\s*Serial/ 2010083012 ; serial/’ $q|sed -i ‘s/’ $q;done

SELECT * FROM table_name WHERE MONTH(date_column) = 4;
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
The fix was to add;
export LC_ALL=en_GB.UTF-8
export LANG=en_GB.UTF-8
to /etc/profile and then run . /etc/profile.

Sometimes slowish ssh on connect:

Explicitly disable GSSAPI authentication in SSH client program configuration
file, i.e. edit the /etc/ssh/ssh_config and add in this configuration (if
it’s not already in the config file):
GSSAPIAuthentication no
pipe output on remote ssh file:

nohup iostat -dkxt 60 1440|ssh [email protected] ‘cat > /home/amarchwiak/iostat-for-a-day.”f4f-uk-apps-01″‘

Last entry from yesterday

select * from stats where UNIX_TIMESTAMP(date) > UNIX_TIMESTAMP(SUBDATE(CURDATE(), 1)) AND UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP(CURDATE()) order by date DESC limit 1; ——————————– tcpdump -i eth0 -n tcp port 2506 -A -s1500 ——————————— simple queing. annoying ip address limit down to 20kbits. [email protected]:~# tc qdisc add dev eth0 root handle 1: prio [email protected]:~# tc qdisc add dev eth0 parent 1:1 handle 10: sfq [email protected]:~# tc qdisc add dev eth0 parent 1:2 handle 20: sfq [email protected]:~# tc qdisc add dev eth0 parent 1:3 handle 30: tbf rate 20kbit buffer 1600 limit 3000 [email protected]:~# tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip dst flowid 1:3 [email protected]:~# tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src flowid 1:3 ———————- vsftpd xferlog_std_format=no log_ftp_protocol=YES ————————- scsi host scan: echo “- – -” > /sys/class/scsi_host/host#/scan
sftp logging:

Subsystem sftp /usr/libexec/openssh/sftp-server -f AUTH -l VERBOSE

Redirect traffic port to another host:
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp –dport 1111 -j DNAT –to-destination
iptables -t nat -A POSTROUTING -j MASQUERADE
/etc/mail/ to ensure that I had the correct settings

DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA’)dnl

run make to generate a new file, the result was this error

WARNING: ‘’ is modified. Please install package sendmail-cf to
update your configuration.

yum install sendmail-cf
zimbra folder with quarantined emails:

after upgading php to 5.3.2

can edit your php.ini file and put in the following line:

date.timezone = “Europe/London”

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>