Archive for April, 2010

Gentoo eix

By Mark Davidson on April 19th, 2010

eix is a tool that allows for fast and highly flexible searching of the gentoo portage system. There is a guide of how to get it installed and basic usage instructions on the Gentoo Wiki.

In this post I would just like to point out the two most useful commands I have found while using eix.


First of all the format argument is one of the most powerful features of eix. I have found it to be very useful when using the available versions parameter. Which allows you to see all the available versions of a particular program, available on the portage tree.

Here is an example of using it to find all the avaliable versions of nmap within the portage tree

eix --format '<availableversions:NAMEVERSION>' -e nmap

Which will give you an output like

net-analyzer/nmap-4.76
net-analyzer/nmap-4.85_beta9
net-analyzer/nmap-4.90_rc1
net-analyzer/nmap-5.00
net-analyzer/nmap-5.00-r2
net-analyzer/nmap-5.10_beta1
net-analyzer/nmap-5.20
net-analyzer/nmap-5.21

Then if you wanted to install say version 5.20 of nmap you can just do

emerge =net-analyzer/nmap-5.20

Another really useful command is multi installed which as is implied allows you to find all packages that have multiple versions installed.

The command with it arguments for this is

eix -i

Since the output from this is quite big on my system I will give a different command and its output for example. This command does the same as mentioned above but is limited by category of ‘dev-lang’ and also used verbose output to make it a bit clearer.

The resulting command is

eix -C dev-lang -v -i

Which reveals that I have quite a few versions of python installed


Those are the quick two commands I wanted to point out for now. I highly recommend checking out eix as it makes a really good alternative to qsearch. When using eix checking out the manual is an absolute must as its over 50 pages long and gives you a true idea of the ammount of functionality avaliable.

Get Unique Hostnames from Apache Config Files

By Mark Davidson on April 8th, 2010

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

Interesting Ubuntu Terminal Keyboard Shortcut

By Mark Davidson on April 7th, 2010

A really quick post this one as I can’t find any documentation on it but thought it was fairly cool. If you use the “SHIFT + ALT + {” keyboard shortcut combo it does autocomplete to match all the files / folders in a directory or some of the files / folders if you have already started typing. Not sure if that makes any sense so an example is in order.

So say in your directory you have the following files ( This is my Zend/Validate/ dir incase anyone wonders)

Abstract.php  Alnum.php        Alpha.php         Barcode         Barcode.php
Between.php   Callback.php     Ccnum.php         CreditCard.php  Date.php
Db            Digits.php       EmailAddress.php  Exception.php   File
Float.php     GreaterThan.php  Hex.php           Hostname        Hostname.php
Iban.php      Identical.php    InArray.php       Interface.php   Int.php
Ip.php        Isbn.php         LessThan.php      NotEmpty.php    PostCode.php
Regex.php     Sitemap          StringLength.php

In this directory if you just do

SHIFT + ALT + {

{A{bstract.php,l{num.php,pha.php}},
B{arcode{,.php},etween.php},
C{allback.php,cnum.php,reditCard.php},D{ate.php,b,igits.php},
E{mailAddress.php,xception.php},F{ile,loat.php},
GreaterThan.php,H{ex.php,ostname{,.php}},
I{ban.php,dentical.php,n
{Array.php,t{.php,erface.php}},p.php,sbn.php},
LessThan.php,NotEmpty.php,PostCode.php,
Regex.php,S{itemap,tringLength.php}}

While if you type a “C” then do it you get

C{allback.php,cnum.php,reditCard.php}

I appreciate its not the most amazing thing in the world but can be pretty handy when you need something a tad more custom than a stand * wildcard. If anyone else knows of some cool keyboard shortcuts for Ubuntu I would be interested in hearing them I have not found any other site that documents this one so I would be interested to know if other people have come across any where that does talk about it.