Find all ServerNames and ServerAliases in several vhosts.conf files

In Apache one specify the servername and serveralias in a virtualhost directive in possible a single .conf file.

We had an Apache webserver with hundreds of such .conf files. With this bash one-liner you can find all ServerName and ServerAlias’s:

cd /etc/httpd/vhosts.d/ ; find . -type f | xargs egrep -i 'servername|serveralias' | awk {'print $3'} | sort | uniq

Use a variable counter in a bash one-liner

I had 70 different domain names that I need to add in a ssl cnf file for creating a certificate request.

The 70 different domain names was in a text file, one per line:

domainname1.something.com
domainname2.somehing.com
...

In order to create the alternative names list, I used this bash oneliner:

teller=1; for i in `cat /tmp/disse2`; do echo "DNS.$teller = $i"; teller=$((teller+1)); done

which then would give me:
DNS.1 = domainname1.something.com
DNS.2 = domainname2.somehing.com
...
DNS.70 = and-so-forth-until 70

This could be useful, if you have for instance hundreds or thousands of lines where you have to add a incremental value per line.

Pimp my shell!

Got a tip from my colleague JB!

Want to refresh your terminal? Is it spring and time to freshen things up? Look at: http://ohmyz.sh/

Easy to install on Redhat:

yum -y install zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Result in my Putty in Windows 7: