Awk command to kill multiple process
Sometime killall -9 will not work. Then you can try using awk command.
ps -ef | grep httpd | grep -v grep | awk ‘{print “kill -9″, $2}’ | sh
Here I am taking the case of httpd. Replace that with the process that you want to kill
awk command with more examples
The special variable FS (Field Separator) determines how awk will split up each record into fields. This variable can be set on the command line.
For example, /etc/passwd has its fields separated by colons.
#awk -F: ‘{print $1,$3 }’ /etc/passwd
Print the second field, then the first. All other fields are ignored.
#awk ‘{print $2,$1}’ filename
How to find out all failed login attempts via ssh/telnet?
Use grep command to find out authentication failure message from /var/log/messages file
Use awk and cut command to print IPs/hostname
Use sort command to sort them
Use uniq command to print total failed login attempts
Login as root then run the following command
# grep “authentication failure” /var/log/messages|awk ‘{ print $13 }’ | cut -b7- | sort | uniq -c
or
grep “authentication failure” /var/log/messages | sed -n -e “s/.*rhost=\([^ ]*\).*/\1/p” | sort | uniq -c
Category: Linux Administration
