#!/bin/bashnewPassword=$1mapfile-tusersArray<<(awk-F":" '((($7=="/bin/bash")||($7=="/bin/sh"))&&($1!="root")){print $1}' /etc/passwd)# shellcheck disable=SC2068for elm in ${usersArray[@]};doecho"Changed Password for $elm to $newPassword"skill-kill-u $elmkillall-u $elmecho-e $newPassword'\n'$newPassword'\n'|passwd $elm;done
Disable all Users With Shell Access:
#!/bin/bashcurrentuser=$(whoami)mapfile-tusersArray<<(awk-vcuruser="$currentuser" -F":" '((($7=="/bin/bash")||($7=="/bin/sh"))&&(($1!="root")&&($1!=curuser))){print $1}' /etc/passwd)echo"Found Users: ""${usersArray[@]}"# shellcheck disable=SC2068for elm in ${usersArray[@]};doecho"Disabling: ""$elm"usermod-s/sbin/nologon $elmkillall-u $elmskill-kill-u $elmdone
Get the name:pid of all active TCP/UDP connections:
#!/bin/bashmapfile-tusersArray<<(ss-tulpn|awk-F"users:" '{print $2}' |awk-F"\"" '{print $2}'|awk '!seen[$0]++')# shellcheck disable=SC2068for elm in ${usersArray[@]};do pid=$(ss-tulpn|awk-F"\"$elm\""'{print $2}'|awk-F","'{print $2}'|awk-F"="'{print $2}'|awk'!seen[$0]++')echo $pid:$elmdone