Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
@fduran
fduran / gist:1870519
Created February 20, 2012 18:29
Linux: Block IP with iptables
# www.fduran.com
# Block an external attacker's IP address (1.2.3.4) with netfilter (iptables)
/sbin/iptables --append INPUT --source 1.2.3.4 -j DROP
@fduran
fduran / gist:1870522
Created February 20, 2012 18:29
Mysql status, check & repair
# www.fduran.com
# mysql status summary
mysqladmin -u root -pthepasswd process status
# check database mydb
/etc/init.d/mysqld stop; cd /var/lib/mysql; myisamchk --silent --force mydb/*.MYI
# repair mydb
/etc/init.d/mysqld start; mysqlcheck -u root -pthepassed --auto-repair --check --optimize --databases mydb
@fduran
fduran / gist:1870527
Last active November 29, 2022 17:07
Linux making disk space
# www.fduran.com
# disk space usage
df -h
# biggest (10) directories in size (MB)
du -mxS / | sort -n | tail -10
# clean package cache
apt-get clean
@fduran
fduran / gist:1870533
Created February 20, 2012 18:30
Apache password protect directory
# www.fduran.com
# apache password protect directory
# Apache config
<Directory /home/user/public_html>
AllowOverride AuthConfig
# ...
</Directory>
Alias /protected "/home/user/public_html/protected"
@fduran
fduran / gist:1870536
Created February 20, 2012 18:31
Heroku Python
# www.fduran.com
# Heroku notes for python, fixes http://devcenter.heroku.com/articles/python
# Ubuntu 11.04 (Natty Narwhal)
mkdir heroku
cd heroku
# Prerequisites
curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
cp virtualenv.py /usr/bin/virtualenv
@fduran
fduran / gist:1870543
Created February 20, 2012 18:32
Linux shell here document on the fly
# www.fduran.com
# Linux shell "here" document
$ cat > newfile << EOF
> write something
> EOF
# obv also:
$ cat > newfile
# and Ctr-D
@fduran
fduran / gist:1870546
Created February 20, 2012 18:32
Linux check DNS cache snooping
# www.fduran.com
# Linux check DNS cache snooping
# check if somedomain (try popular ones like google.com etc) is cached in a dns_server
# with nslookup
nslookup -norecurse somedomain dns_server
# with dig
dig @dns_server somedomain A +norecurse
@fduran
fduran / gist:1870548
Created February 20, 2012 18:33
Monitoring Plesk with Monit
www.fduran.com
Monitoring Plesk with Monit
Plesk is not mentioned anywhere in monit's site http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=plesk+site%3Ammonit.com and I couldn't find any article or tutorial about how to monitor Plesk using Monit, so I'm writing one myself in the hopes other people with the same problem find it.
Plesk 8.3 on Centos5
etc/init.d/psa status
psa dead but subsys locked
@fduran
fduran / gist:1870549
Created February 20, 2012 18:33
Linux remote syslog
www.fduran.com
Remote syslogging in Linux
1. On logging server 'logserver':
# nano /etc/rsyslog.conf
uncomment:
# provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
@fduran
fduran / gist:1870552
Created February 20, 2012 18:33
Linux honeypots
# www.fduran.com
# Linux honeypots
# nephentes
# (google 'nephentes honepot')
apt-get update; apt-get install nepenthes
nano /etc/nepenthes/nepenthes.conf
/etc/init.d/nepenthes restart
#log: less /var/log/nepenthes.log