script to copy a template directory and omit files

The following script will copy a directory structure from a source to a target and omit files, copying only folders (directories) #!/bin/sh if [ -z "$1" ] ; then echo "Please give a source dir" echo "otherwise I will assume that the source is ".`pwd` echo "Synax: sourcedir/ targetdir/" sourcedir="./" fi if [ ! -z "$1" ] ; then sourcedir=$1 fi if [ -z "$2" ] ; then echo "Please give give a target dir" exit fi find $sourcedir -type d -links 2 -exec mkdir -p "$2/{}" \;

Creating a large single network drive

Normally to create a network drive you'd use NFS. However, gluster lets you merge multiple network drives into one single drive. I'll post more here as I go.

Identify traffic sources in bulk

 Say you have a list of IP addresses from a log file of hackers/losers/DDoSers. Step 1, install geoiplookup sudo apt-get install geoip-bin Step 2, for i in `cat list` ; do ( echo -n $i" " ; geoiplookup $i ) ; done | grep -v "South Africa" This basically will let you look up who they are and ignore IPs from home country, in this case South Africa. Once you decide which countries are likely to be hackers (Hello, former soviet bloc!) - then you block their IPs.

throttle traffic on apache

sudo apt install apache2-utils sudo apt install libapache2-mod-evasive vi /etc/apache2/mods-enabled/evasive.conf service apache restart edit it and set values as per below or whatever else you like, the time quantities are seconds     DOSSiteInterval     1     DOSBlockingPeriod   10     #DOSLogDir           "/var/lock/mod_evasive"

botnet ip addresses

 As I block botnets IP addresses I will put them here for yall to block as well. Botnet file list

blocking lame botnets

  #!/bin/sh if [ -z "$1" ] ; then echo please provide the ip to ban exit fi if [ -z "$2" ] ; then echo please provide the reason as a string with underscores echo eg tried_to_hack_dns echo if you provide the reason as http-hacker it will echo prevent this ip from accessing http ports exit fi  if [ -z "`grep $1 /etc/hosts.deny`" ] ; then echo "# "$2 >> /etc/hosts.deny if [ "$2" != "http-hacker" ] ; then echo "sshd,pop,pop3,smb,imap,afp,ftp: "$1 >> /etc/hosts.deny fi if [ "$2" = "http-hacker" ] ; then         echo "sshd,pop,pop3,smb,imap,afp,ftp,http,https: "$1 >> /etc/hosts.deny         fi echo "Added the following to hosts.deny:" tail -n2 /etc/hosts.deny ourIp="[insert here]" echo "iptables -t filter -I INPUT -s $1 -p tcp --dport 22 -d $ourIp -j REJECT etc, etc" iptables -t fil

Pause a program which is using too much CPU

Sometimes your battery is running low and you need to pause a program without quitting it or force-quitting it, so that you can preserve battery but not lose the job that the program is doing. To do this,  Step 1. open a terminal Step 2. type:  ps ax | grep -i  "<program name>" so for example, if it's photoshop you need to pause, replace "<program name>" with "photoshop" Step 3. Next to the results on the far left you'll see a number, usually with 5 digits. E.g. 12345. Step 4. Type:  kill -STOP 12345 where 12345 are the numbers obtained in Step 2-3. Step 5. When you want to resume the program, type kill -CONT 12345 It should then continue to operate or run as usual without problems.