Posts Tagged ‘bash’

Bind Logs – Top DNS Queries

By Mark Davidson on September 3rd, 2010

This week at work we fancied figuring out what the top sites are on are network. So decided an easy way to work this out would be to enable logging on are bind server and then write a script to work out what the top DNS queries are.
Read & Comment ›››

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

fish awesome auto complete and more

By Mark Davidson on February 26th, 2010

Ever since I started using Linux all those years ago I have always been on the look out for a different shell that would top bash. I had tried zsh and a few others but none of them really topped bash in a massive way. Recently a mate of mine told me about fish so I tried it out on my Gentoo dev box.

There are a lot of interesting features in fish most of them to do with the auto completion aspects.

The auto-completion of ls arguments is just a very basic example of how fish really improves on standard auto-complete functionality like in bash. As well as being able to complete the normal long arguments it can complete short ones as well plus giving an actual explanation to what the command does. I think this is absolutely great personally for two reasons. First of all if your new to Linux then it helps you learn. Second if your like me and your mind just falls apart some times as its to full other junk (mine being full of knowing every episode of The Simpsons in full word for word) its handy to get a bit of a prompt.

As well as the improvement of auto-completing arguments the auto-completion for programs is improved as well telling you what the program is where possible but at least telling you what the type of application or program is. The below screen shot is when listing a lot of programs which is output using a less type application if there is only a few it will be output like with the above ls auto-complete.

Next one of my personal favorite features of fish is the auto-completion of wildcards for example if I am at the top of my web directory and wanted to get the details of every PHP file in all the sub directories, I would need to do something like `find . -iname “*.php” -print0 | xargs -0 ls -la` while with fish you could just do `ls –la **.php` and get the same result.
Another example as follows is auto-completing on wild cards something that’s not possible with bash.

The last feature I would like to point out in this quick coverage of fish is a small one using the % symbol you can autocomplete for process IDs which can be really handy.

There are some more screen shots showing some other cool features on their website http://fishshell.org/screenshots.html and further detail on all the features on the documentation page http://fishshell.org/user_doc/index.html
Also if your interested checkout the possible features list http://fishshell.org/doc2/index.html#todo-possible think there is some cool ones coming up.

That’s it for now. I am going to continue using fish over the next few days then I will be putting together a bit of a cheat list which ill be posting up here, so if your interested check back soon.