Skip to content

Instantly share code, notes, and snippets.

View fduran's full-sized avatar

Fernando Duran fduran

View GitHub Profile
@fduran
fduran / Linux Server Utilization.sh
Created February 20, 2012 17:52
Linux Server Utilization
#!/bin/bash
# www.fduran.com
date;
echo "uptime:"
uptime
echo "Currently connected:"
w
echo "--------------------"
echo "Last logins:"
last -a |head -3
@fduran
fduran / gist:1870429
Created February 20, 2012 18:15
Linux disk space email alert
#!/bin/bash
# www.fduran.com
# script that will send an email to EMAIL when disk use in partition PART is bigger than %MAX
# adapt these 3 parameters to your case
MAX=95
EMAIL=alert@example.com
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
@fduran
fduran / gist:1870436
Created February 20, 2012 18:16
Linux Rootkit check
# chkrootkit & rkhunter:
# www.fduran.com
http://www.chkrootkit.org/download/
http://sourceforge.net/projects/rkhunter/
cd /usr/local/src/
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
tar zxvf chkrootkit.tar.gz
cd chkrootkit-0.49/
./chkrootkit
@fduran
fduran / gist:1870438
Created February 20, 2012 18:16
Linux encryption and decryption
# symmetric encryption and decryption
# www.fduran.com
# encryption:
gpg -c filename
# that creates filename.gpg, filename remains as original, optionally:
rm filename
# decryption:
@fduran
fduran / gist:1870444
Created February 20, 2012 18:17
Linux server stats with munin
# munin stats http://munin-monitoring.org/
# www.fduran.com
apt-get update; apt-get install munin munin-node
# Apache: add at the end of .conf file or as new sites-available:
# Alias /munin "/var/www/munin"
# you may want to password-protect the directory
/etc/init.d/munin-node start
@fduran
fduran / gist:1870446
Created February 20, 2012 18:18
Linux server monitoring with monit
# monit monitoring http://mmonit.com/monit/
# www.fduran.com
apt-get update; apt-get install monit
cp /etc/monit/monitrc /etc/monit/monitrc.orig
# edit /etc/monit/monitrc see examples at http://mmonit.com/wiki/Monit/ConfigurationExamples
# Respawn:
@fduran
fduran / gist:1870451
Created February 20, 2012 18:18
Linux file integrity with tripwire
# crucial files integrity check with tripwire http://sourceforge.net/projects/tripwire/
# www.fduran.com
apt-get update
apt-get install tripwire (enter 2 passwords)
# in /etc/tripwire/twpol.txt :
# a) in /root section comment out all of them minus result of:
ls -la /root
# ex:: .bash_history , .bashrc , .profile
@fduran
fduran / gist:1870460
Created February 20, 2012 18:20
Linux protecting critical directories
# protecting critical linux directories my making them immutable
# www.fduran.com
chattr +i dir
# system dirs to protect:
/sbin
/bin
/usr/sbin
/usr/lib
@fduran
fduran / gist:1870463
Last active September 30, 2015 22:17
Linux cloning packages (Debian/Ubuntu)
# Linux cloning packages (for Debian/Ubuntu -type)
# in server of origin:
dpkg --get-selections > packages.txt
# in destination server:
dpkg --set-selections < packages.txt
apt-get -u dselect-upgrade
# most packages will work even if destination server is newer distro version
@fduran
fduran / gist:1870471
Created February 20, 2012 18:21
Linux SSH Filesystem
# Use SSH filesystem to mount locally a remote directory through SSH
# www.fduran.com
# at local server:
apt-get update; apt-get install sshfs
mkdir /path/to/local/dir
# Mounting -persists on logout- (for other ssh port add: -p port):
sshfs remoteserver.example.com:/path/to/remote/dir /path/to/local/dir