Linux

Hammer script to get output from Job by id

This is a simple script I use to export the details from a Job run in Red Hat Satellite 6.2 using hammer from the console. #!/bin/bash # Redhat Satellite Job query by id using hammer if [ $1 -eq $1 ] 2>/dev/null; then # get hosts run by ID JOBHOSTS=$(hammer job-invocation info –id $1 | […]

Read More
Linux

One-liner to mail when someone logs in as root

This is a short post describing how to automatically send an email every time someone logs in as root on a linux server. Add the following line to /root/.bash_profile if you are using bash as your default shell interpreter. Refer to /etc/passwd. (echo “Subject: ALERT: servername Root Shell Access from `who | awk ‘{print $5}’`”; […]

Read More
Scripting

My 10 most used linux commands

This is a oneliner bash command to determine my 10 most used linux commands according to my history file history | awk ‘{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] ” ” CMD[a]/count*100 “% ” a;}’ | grep -v “./” | column -c3 -s ” ” -t | sort -nr | nl | head -n10 The […]

Read More
Scripting

Apache web connections pr hour

This is a bash oneliner to show Apache web connections pr hour. It lists up the IPs that has accessed your webserver and the amount og accesses. # cat /var/log/apache2/access_log_pario.no | grep “21/Jan/2008:..” | awk {‘ print $4″:”$1 ‘} | sed ‘s/\[//g’ | awk -F : {‘ print $1″:”$2″\t\t”$5 ‘} | sort | uniq -c […]

Read More
Network

Allow NFS through iptables

This is one way to determine the ports needed to open in your iptables rules to get NFS to work properly. First we need to determine the ports NFS uses rpcinfo -p | awk -F ” ” ‘{print $3 “, ” $4 “, ” $5}’ | sort | uniq Notice! Since portmap assigns ports on […]

Read More