Currently where I work we are in progress of doing a big server move and we wanted to get a list of all the domains currently running on one of the servers. So I wrote this bit of Command Line Kung Fu to do just that. Thought that it was quite cool and handy so decided to share it.

So if you run the following (This is with a default Ubuntu configuration of Apache might need to change the path if your configuration is different)

cat /etc/apache2/sites-enabled/* | egrep 'ServerAlias|ServerName' | tr -s " " | sed 's/^[ ]//g' | uniq | cut -d ' ' -f 2 | sed 's/www.//g' | sort | uniq

You will get output like this

subdomain.mysite.com
mysite.com
anothersite.com
pablumfication.co.uk
Share this post

Leave a Reply

CAPTCHA (required) Time limit is exhausted. Please reload CAPTCHA.