Skip to content

Instantly share code, notes, and snippets.

@risha700
Last active December 13, 2019 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save risha700/8ce985df997ef7caa308812d7962d718 to your computer and use it in GitHub Desktop.
Save risha700/8ce985df997ef7caa308812d7962d718 to your computer and use it in GitHub Desktop.
Clean linux users

get current ssh active users

usr=`awk -F: '{ print $1}' /etc/passwd`
usr=`getent passwd|grep -v 'root'|awk '/home/'| awk -F: '{ print $1}'`
for user in $(echo $usr); do if [ $user != `whoami` ];then  sudo userdel -r $user; fi; done

kill the stale process

stale=`ps aux |grep ssh |egrep -v 'root'| awk '{print $2}'`
for process in $stale;do sudo pkill -9 $process;done

@risha700
Copy link
Author

path_to_del=$(mdfind -name 'pycharm'|sed -e 's/ /\ /g')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment