-
Recent Posts
Recent Comments
Archives
Categories
Meta
Category Archives: bash
IP Unique Apache logs
#!/bin/bash FILE=/usr/local/apache/logs/access_log; for ip in `cat $FILE |cut -d ’ ’ -f 1 |sort |uniq`; do { COUNT=`grep ^$ip $FILE |wc -l`; if [[ "$COUNT" -gt "10" ]]; then echo ”$COUNT: $ip”; fi }; done
Posted in astuces, bash
Leave a comment
Trouver les fichiers modifiés dans les deux jours
find / -mtime 2 -o -ctime 2
Posted in astuces, bash, linux
Leave a comment
NB SYN SUR UN PORT PARTICULIER
Exemple sur le port 80: tcpdump -ne dst port 80 and ‘tcp[13] & 2 == 2′ Pratique pour detecter un SYN FLOOD
STATS NOMBRE DE CONNEXION LINUX
Exemple sur le port 80 netstat -tan | grep ‘:80 ‘ | awk ‘{print $6}’ | sort | uniq -c
ALERTE MAIL DANS /etc/hosts.deny
ALL: ALL :SPAWN echo “Service %d IP %a Utilisateur %c” | /bin/mail -s “Alerte tcpd” user@domain.fr : DENY
Trouver les 50 repertoires les plus lourds
du -S / | sort -nr | head -n50
Posted in bash, linux, shell
Leave a comment
Chercher les fichiers de plus de 7 jours et les supprimer – sans Xargs
find repertoire -type f -mtime +7d -exec /bin/rm {} ;
Posted in bash, shell
Leave a comment
Lister les lignes triées d’un fichier en éliminant les doublons
ficorig=”fichier_origine”; ficdest=”fichier_destination”; sort -o ${ficorig}.sort ${ficorig}; while read line; do if test “$line” != “$sauve”; then sauve=`echo $line`; echo $line >> $ficdest; fi; done < ${ficorig}.sort;rm ${ficorig}.sort
Posted in bash, shell
Leave a comment
Infos Systeme Linux
Pour avoir des infos sur La machine il suffit de taper : dmidecode
Posted in bash
Leave a comment
Mysql dump with delete more then 3 backups
DATUM=`date ‘+%Y-%m-%d’` mysqldump -u USER –password=PASSWORD DATABASE TABLE > /home/backup/db.sql gzip /home/backup/db.sql mv /home/backup/db.sql.gz /home/backup/db-${DATUM}.sql.gz find /home/backup/ -mtime +2 -type f -print0 | xargs -0 rm
Posted in astuces, bash
Leave a comment