Linux Dump

——————————————————————–
scanning all network devices using arp-scan on 192.168.254.0 network:
arp-scan –interface=eth1 192.168.254.0/24

or using nmap:
nmap -sP 10.25.100.0/24
——————————————————————–

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

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

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

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

————-
proxy port forwarding linux.
ssh -f -L 8080:localhost:8080 leming@ehion.com 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:

DEBUG MODE

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

mysqlcheck –auto-repair c64forum phpbb_config

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: http://ftp2.de.debian.org etch Release: The following
signatures couldn’t be verified because the public key is not available:
NO_PUBKEY 9AA38DCD55BE302B

apt-get install debian-archive-keyring

apt-get update

or rather this: (replace the key with the key thats popped up)
gpg –keyserver pgpkeys.mit.edu –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 193.180.177.13 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 193.180.177.13 -m state –syn –state NEW
–dport 22 -m limit –limit 1/minute –limit-burst 1 -j ACCEPT
iptables -A INPUT -p tcp -s 193.180.177.13 -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 host.dot.com
—————————————————-
/usr/bin/rsync -avCzu –progress –timeout=999 -e ssh root@remotehost.com:/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 ’91.186.3.143′ *.*|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/91.186.3.143/178.17.35.81/g’ $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 amarchwiak@10.25.1.200 ‘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. root@c2h5oh:~# tc qdisc add dev eth0 root handle 1: prio root@c2h5oh:~# tc qdisc add dev eth0 parent 1:1 handle 10: sfq root@c2h5oh:~# tc qdisc add dev eth0 parent 1:2 handle 20: sfq root@c2h5oh:~# tc qdisc add dev eth0 parent 1:3 handle 30: tbf rate 20kbit buffer 1600 limit 3000 root@c2h5oh:~# tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.254.60/32 flowid 1:3 root@c2h5oh:~# tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 match ip src 192.168.254.60/32 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 2.2.2.2:1111
iptables -t nat -A POSTROUTING -j MASQUERADE
—————————–
sendmail
/etc/mail/sendmail.mc to ensure that I had the correct settings

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

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

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

yum install sendmail-cf
—————————–
zimbra folder with quarantined emails:

/opt/zimbra/data/amavisd/quarantine
————–
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>