# reiniciar demonios restart() { if [ -f /etc/init.d/$1 ]; then /etc/init.d/$1 restart else echo "*** non existant daemon $1 ***" fi } # calculadora function calc { echo "${1}"|bc -l; } # Generador de Passwords (requiere paquete agp) function gen-pass { apg -a 0 -n 1 -q -MNCL -m 12; } # Generador de Passwords (no requiere nada) function genpasswd() { local l=$1 [ "$l" == "" ] && l=16 tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs } # Envia mails para recordar tareas function task { mail -s "$*" mate@yoquese.es < /dev/null 2>/dev/null } # lista de Ășltimos archivos lsnew() { ls -lt ${1+"$@"} | head -20; } # host en mis subnets con puerto SSH abierto sshearch() { nmap -p22 -oG - $(ip addr | awk '/inet .*global/ {print $2}' | tr '\n' ' ') | awk '/22\/open/ {print $2}' | uniq;} # convertir ficheros NRG (nero) en ISO nrg2iso() { dd bs=1 if=$1 of=$2 skip=300; } # tree == subdirectorios y capacidades en human readable tree() { du -Sh | sort -n; } # mirar ficheros con permisos de escritura (potencialmente peligrosos en entorno multiusuario) # hay 2 variantes para hacer solo de determinados directorios o para eliminar las lineas que no nos interesan writable() { find / -perm -2 ! -type l -ls; # find /etc /var -perm -2 ! -type l -ls; # find / -perm -2 ! -type l -ls | sed "/proc/d" | sed "/dev/d"; } # comandos favoritos favorites() { history | awk '{print $2}' | sort | uniq -c | sort -rn | head; } #favorites2() { history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr }