Linux

Create a photo collage using imagemagick

I use imagemagick to create index images to my photo albums to get a quick overview without looking through all the pictures. This is how I create a simple photo collage using imagemagicks montage command montage -label ‘%t\n%wx%h’ -resize 150×150 ‘*.JPG’ -geometry +3+3 -tile 3x -frame 5 _Index.JPG

Read More
Linux

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
Linux

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
Linux

Script to customize a linux install

This is a simple bash script I whipped together to make som custom changes on our linux installations, it can be used as a kickstart post-configuration file for RedHat RHEL4 and RHEL5 installations. #!/bin/bash # Enable daily updates of the locate database perl -pi -e ‘s/DAILY_UPDATE=no/DAILY_UPDATE=yes/’ /etc/updatedb.conf # Customize login banners echo “Authorized users only. […]

Read More
Linux

Restart dead daemon automatically

This is a simple bash script to restart a dead daemon, in this example I’ll use apache #!/bin/bash # Automatically restart httpd if it dies netstat -ln | grep “:80 ” | wc -l | awk ‘{if ($1 == 0) system(“/etc/init.d/httpd restart”) }’

Read More