Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while read linea; do
- # entra la linea entera
- # al indice pese a los espacios
- arr[$indice]=$linea
- ((indice++))
- done < /etc/passwd
- # llamar al array con comillas
- # aplica a cada cadena de cada incide
- for user in "${arr[@]}"; do
- usuario=$(echo $user | cut -d ":" -f1)
- id=$(echo $user | cut -d ":" -f 3)
- shell=$(echo $user | cut -d ":" -f 7)
- if [ $id -ge 1 ] && [ $id -le 999 ];then
- if grep -w $shell /etc/shells;then
- echo -e "\033[1;31mWARNING\033[0m: special user has shell"
- echo "archivos abiertos por $usuario (lsof -u $id)"
- lsof -u $id
- echo "elimando procesos a nombre de $usuario (pkill -U $id)"
- pkill -U $id
- echo "eliminar usuario"
- userdel -f $usuario
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment