Category Archives: linux

Xauthority

Generally when you try opening any X application, say xclock or xterm, as a root user on a remote system, It gives an error saying “Can’t open display”. To get rid of this message what you can do is,

– First ssh with -X into remote system
$ ssh -vX foo@example.com

– Export a variable
$ export XAUTHORITY="~/foo/.Xauthority"

– Start X app (I am assuming user “foo” has a superuser privileges on remote system)
$ sudo xterm

ii aka IRC It – the tiniest IRC Client

Today I came across a wonderful IRC Client http://tools.suckless.org/ii/

Install II
Download it from above URL and RTFM to install.

Start
ii -help

OR

ii -i IRCDIR -s irc.freenode.net -m SOMENICK -f FULLNAME &

Explanation
Use any empty directory name on the place of IRCDIR
“&” will background the process

Now you will get “out” files in IRCDIR . Use “tail -F out” on those files to check what’s going on.

Logging In (for freenode irc)
echo "/j nickserv identify SOMENICK SOMEPASSWD" > IRCDIR/irc.freenode.net/in

Join Channel
echo "/j #CHANNELNAME" > IRCDIR/irc.freenode.net/in

Talk in Channel
echo "SOMEMSG" > IRCDIR/irc.freenode.net/#CHANNELNAME/in

Send Private Message
echo "/privmsg SOMEOTHERNICK SOMEMSG" > IRCDIR/irc.freenode.net/#CHANNELNAME/in

Part / Leave Channel
echo "/l bye" > IRCDIR/irc.freenode.net/#CHANNELNAME/in

Thanks to drewid[rogue]@irc.oftc.net on #ii

easily creating name based virtual hosts in apache

Check if your /etc/apache2/ports.conf has following two lines

NameVirtualHost *:80
Listen 80

Create two directories in /var/www
# mkdir /var/www/{foo,bar}

These two directories in /var/www/ will serve as a document root for our two test sites foo.com and bar.com respectively

Create index.html file in each of these two directories and put some html code in it.
e.g.
I am foo.com
I am bar.com

Put entries in /etc/hosts
You need to also put 2 entries in your /etc/hosts file since we are testing it on localhost. If you are doing it on a server then make sure you have respective A records in DNS.
Open /etc/hosts in your favourite editor and put following two entries at the bottom of the file without disturbing original contents of file

127.0.0.4 foo.com foo
127.0.0.5 bar.com bar

Just make sure that above IPs are not already in use in same file …if any of them is in use, then for your entries you can
use any IP in 127.x.x.x range.

Create virtual hosts
Now create two files, “foo.com” and “bar.com” in /etc/apache2/sites-available/
Contents of foo.com

ServerName foo.com
ServerAlias http://www.foo.com
DocumentRoot /var/www/foo/


Similarly create bar.com with following content


ServerName bar.com
ServerAlias http://www.bar.com
DocumentRoot /var/www/bar/

Enable newly created sites
# a2ensite foo.com bar.com

Reload Apache
# service apache2 reload OR # /etc/init.d/apache2 reload

Open your browser and put “foo.com” in address bar .. you should be able to see the contents of /var/www/foo/index.html file
Repeat same step for “bar.com” as well to confirm that your setup is working

Enjoy!!

ktorrent country flags

How to get country flags in Ktorrent

I love to see country flags in Ktorrents peers tab. Though the database is not much accurate, the flags look nice. 🙂

I upgraded the KDE few months back and came to know that flags are no more shown in Ktorrent. After some googling I found that one should have `kdebase-data` and `libgeoip1` packages installed. Also in Ktorrent ,`infowidget` plugin should be active.

I had both packages already installed and the plugin was also enabled, but still flags were not visible.

The reason behind this is mentioned in README.Debian provided with KTorrent package. So after reading it, I read README.Debian for libgeoip1 package and solved the problem. 🙂 Enjoy.

Install libgeoip1 package
# aptitude install libgeoip1

Create a directory
# mkdir /usr/share/GeoIP/

Run script provided with libgeoip1 package
# cd /usr/share/doc/libgeoip1/examples/
# ./geolitecountryv4.sh
# ./geolitecountryv6.sh

DONE!!!