Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
# www.fduran.com
# what is this process? - mini forensics on unknown running process
ls -l /proc/$pid/exe
dpkg -S /path/to/process_binary
strings /path/to/process_binary
hexdump -C /path/to/process_binary
netstat -tapn|grep tang
lsof $pid
# www.fduran.com
# exclude a process from being killed by oom killer
echo -17 > /proc/$PID/oom_adj
# The possible values of oom_adj range from -17 to +15. The higher the score, more likely the associated process is to be killed by OOM-killer: https://lwn.net/Articles/317814/
@fduran
fduran / Linux Bash generate a number of files of random sizes in a range
Last active May 21, 2024 12:42
Linux Bash generate a number of files of random sizes in a range
#!/bin/bash
# generate a number of files with random sizes in a range
min=1 # min size (MB)
max=10 # max size (MB)
nofiles=20 # number of files
for i in `eval echo {1..$nofiles}`
do
dd bs=1M count=$(($RANDOM%max + $min)) if=/dev/urandom of=./files/file$i
@fduran
fduran / mysql optimization
Created October 1, 2014 17:11
MySQL Optimization
# see http://mysqltuner.com/
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
perl mysqltuner.pl
@fduran
fduran / WordPress Error establishing database connection
Last active August 29, 2015 14:07
WordPress Error establishing database connection
# WP "Error establishing database connection"
# substitute with site's index static page (when it's up, not with the error duh)
wget http://example.com -O [/path/to/wp]/wp-content/db-error.php
@fduran
fduran / calculate mysql schema disk size
Created October 1, 2014 17:14
Calculate MySQL schema disk size
# calculate mysql schemas disk size
mysql -h dbhost.example.com -u theuser -pThePassword -e 'select table_schema as DB, round(sum((data_length+index_length)/1024/1024),1) as MB from information_schema.tables group by table_schema order by MB desc'
@fduran
fduran / check and alert if mysql slave is not running
Created October 1, 2014 17:15
Check and alert if mysql slave is not running
#!/bin/bash
# check if mysql slave is running
log=/var/log/mysqlslave.log
[email protected]
date >> $log
res=`mysql -u root -pPassword -h db.example.com -N -B -e "show status like 'Slave_running'"|cut -f2`
if [ $res = 'ON' ]
@fduran
fduran / tail log file in browser
Created October 1, 2014 17:17
tail follow log file in browser
# tail log file in browser
# go to server.example.com:777
pip install tailon
tailon -f /var/log/example.log -b 0:0:0:0:777 &
@fduran
fduran / Checking for Shellshock attempts in web server logs
Created October 1, 2014 17:19
Checking for Shellshock attempts in web server logs
# Checking for Shellshock attempts in web server logs
egrep "};|}\s*;" /var/log/apache2/access.log
@fduran
fduran / django_install_apache.md
Last active February 12, 2017 15:34
Django Install - Apache

Django Install - Apache

Once per server:

apt-get update && apt-get upgrade
apt-get install libapache2-mod-wsgi
apt-get install python-setuptools python-dev build-essential
easy_install -U pip