Scripting

Shell script for removing duplicate files

The following shell script finds duplicate (2 or more identical) files and outputs a new shell script containing commented-out rm statements for deleting them. You then have to edit the file to select which files to keep – the script can’t safely do it automatically! OUTF=rem-duplicates.sh; echo “#! /bin/sh” > $OUTF; find “$@” -type f […]

Read More
Linux

Monitoring /var/log/secure for break-in attempts

date >> ssh-intruders.log ; cat /var/log/secure | grep -i “sshd.*authentication failure” | sort | awk ‘{FS=”rhost=”; print $2}’ | awk ‘{FS=”user=”; print $1}’ | grep “.*\..*\.” | grep -v “knownhost.com” | grep -v “knownhost2.com” | sort | uniq | while read i; do counter=`grep -i “$i” /var/log/secure | wc -l` ; echo “$counter attempts by […]

Read More