Sunday, September 09, 2012

IRC via irssi

Haven't blogged for quite a while, been really busy with various things. So, just thought I'd have a little techie post about IRC.

A lot of people have forgotten IRC as a chat facility, but it really is the granddaddy of them all and it is certainly still very popular, especially in the techie world. A lot of techie and developer discussions about subjects as Linux, Firefox, Oracle and the hacker fraternity all meet in IRC, in fact, it's probably fair to say that IRC is the primary communication facility for developers of certainly the first two technologies in that list. There's are many advantages with using IRC as a chat facility and that is its simplicity of basic use, anyone can use it, it doesn't take long to get to grips with the basics. For the advanced user, you can script to your heart's content, or even run your own server for your own purposes (even embedding the technology in your own product, just check out how the chat facility in the python-based MMORPG "Eve Online" works!

There are many IRC client and server software available, whether you like GUIs or command line, the choice is yours. I tend to prefer command-line software for most things, so this blog post will concentrate on my favourite client, irssi using a Lubuntu Linux OS.

So, the first step is to install the client, which as with most things on Debian-based distros, is quite easy :
$ sudo apt-get install irssi
Once the install has completed, you then have to modify your settings. All settings can be done through the command-line UI, and for those commands I will direct you to the irssi documentation. However, all settings are stored in $HOME/.irssi/config and is probably quicker to manually change the file (vim is your friend!). The only thing to point out is to issue a /save command if you do change the settings via the front-end otherwise this file won't be updated.

So, most of the settings can be left as-is, all settings such as default and custom aliases are defined in here. However, the important entries are the hostname, real_name and nick(name). These should be changed to whatever you require.

Once this is done, that's pretty much it. You can then connect to an IRC server by either using the /connect IRC command or via the command-line as :
$ irssi -c irc.undernet.org
Once you are connected, you can then issue any of the IRC commands that you might know, such as /join, /msg, /alias etc. This blog entry will not go into them, a quick Google for "IRC commands" or the irssi documentation will give you plenty of resources.

If you are connected to multiple channels, then you can use ALT- to switch between contexts, i.e. ALT-2 might be #oracle, ALT-3 might be #python etc. You can connect to multiple servers via the /connect command, and then Ctrl-X will switch between connections.

If anyone is interested and wants to chat (about linux/oracle/python), then, I use the nick "tackd" and am generally found on #oracle #linux and/or #python on DALnet, Undernet or EFnet (the major IRC networks really).

Wednesday, February 10, 2010

Quick and easy (tm) Ubuntu Netbook Remix

I've blogged about UNR before, but just thought I'd email just how easy it is to get up and running with this great version of Ubuntu specifically for Netbooks.

1. Download the ISO from http://www.ubuntu.com/GetUbuntu/download-netbook
2. Use the USB Startup Disk Creator to burn it to a USB stick (or burn it to a CD, but you'd need an external CD drive for that, USB sticks are MUCH easier)
3. Boot from the USB stick and install Ubuntu via the installer

That's the main bit. I've just done it in 10 minutes from start to finish.

As additional extras, if you enable the "partner" repositories in Software Sources, then install the "ubuntu-restricted-extras" and "sun-java6-plugin" packages, you'll have all the common software such as flash and java all pre-configured.

Wonderful.

Saturday, January 23, 2010

DNS caching in Ubuntu

DNS caching in Ubuntu is really straightforward and can make a big difference to the speed of your general network activities, including browsing. Why? Well, on an average home network, a DNS request can take 40ms+, and given that (unless your on a webpage using direct IP addresses of course) pretty much every actual HTTP request, i.e. one that doesn't result in a local cache get, results in an initial DNS lookup. So, multiply every non-cached object on the webpage by your DNS lookup time, and you can have a big overhead.

Windows has had a local DNS cache for ages now, certainly since XP (and probably before that), but Linux distros have not, for various reasons. In fact, as far as I'm aware, only openSUSE has had a DNS cache enabled by default (the excellent ncsd).

There are many different DNS caching daemons available, but my favourite is dnsmasq. You can find more information about the advanced features of this software here, i.e. you can run it as a fully-fledged DNS and DHCP server for your network. Here I'll explain how to do simple DNS caching with it.

Firstly, install it (obviously). The repository for your distro will almost certainly have it, here I'm using Ubuntu 9.10, and the standard repository.

$ sudo apt-get install dnsmasq

Once it's installed, modify the /etc/dnsmasq.conf, and specify the listening IP address. Here, we're obviously going to use the local host address, so uncomment the following line :

listen-address=127.0.0.1

Now, you need to modify your DHCP configuration to use the local DNS cache first, if there isn't one, then fall back on your main DNS server. So,

$ sudo vi /etc/dhcp3/dhclient.conf

include the "prepend domain-name-servers 127.0.0.1" line

Note, that "prepend" puts the dns server ABOVE everything else, so ensure that the prepend statement above is LAST in the list.

The following is my setup, note I use OpenDNS, hence the IPs 208.67.222.222 and 208.67.220.220.

prepend domain-name-servers 208.67.222.222;
prepend domain-name-servers 208.67.220.220;
prepend domain-name-servers 127.0.0.1;

Now, when you DHCP lease expires the order of DNS servers should be 127.0.0.1 and then your existing DNS setup.

If you don't want to wait until your DHCP lease expires, you need to manually modify the /etc/resolv.conf file (which gets overwritten when the lease expires) :

$ sudo vi /etc/resolv.conf

And add

nameserver 127.0.0.1

to the top of the nameserver lists already in there.

Once this is done, restart your dnsmasq daemon, i.e.

$ sudo /etc/init.d/dnsmasq restart

So, how can you test that all this has had a positive effect? Well, you use the wonderful
dig command. Here's the example from my local machine :

$ dig chaddersblog.blogspot.com

; <<>> DiG 9.6.1-P2 <<>> chaddersblog.blogspot.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23451
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;chaddersblog.blogspot.com. IN A

;; ANSWER SECTION:
chaddersblog.blogspot.com. 2886 IN CNAME blogspot.l.google.com.
blogspot.l.google.com. 294 IN A 216.239.59.191

;; Query time: 31 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Sat Jan 23 10:33:56 2010
;; MSG SIZE rcvd: 91

$ dig chaddersblog.blogspot.com

; <<>> DiG 9.6.1-P2 <<>> chaddersblog.blogspot.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27521
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;chaddersblog.blogspot.com. IN A

;; ANSWER SECTION:
chaddersblog.blogspot.com. 2884 IN CNAME blogspot.l.google.com.
blogspot.l.google.com. 292 IN A 216.239.59.191

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)

;; WHEN: Sat Jan 23 10:33:58 2010
;; MSG SIZE rcvd: 94

You can see from the bold sections that the first time I ran the command, the "Query time" was 31 msec (because it didn't have the DNS entry for that address), but the second time it did, so the Query time was instantaneous.

Sunday, December 13, 2009

Grub

Haven't posted for a while, so thought I'd go a bit geeky and give some information on the usage of various technologies (since I get asked these types of questions a lot on various IRC / IM channels). My first post will be on the architecture and usage of GRUB (note, the latest versions of Ubuntu etc using GRUB2 which is a complete rewrite of GRUB. I'll try and highlight some of the differences as I'm going along, but I'm still getting my head around GRUB2. For a complete breakdown of the differences between GRUB and GRUB2, then look here), then (at some point in the future) I'll blog about Xorg. These are the two most common queries and, in my opinion, the two most unappreciated pieces of software in existence.

So, what is GRUB? Well, simply put, it's a bootloader. However, that really is simplifying it rather too far. For one, it's the reference implementation of the Multiboot specification on the GNU OS. What this means is that it pretty much defines the de-facto standard for bootloaders. Without GRUB, you wouldn't have UNIX, Linux or even Solaris (since v10).

So, what's a bootloader? Well, generally speaking, when a computer is powered on, the BIOS reads the first 512 bytes of the hard disk (known as the Master Boot Record (MBR)). The MBR contains code known as the "bootstrap" program. Control is then passed to the bootstrap program. This is known as "Stage 1".

Stage 1 generally does little more than just load and execute code located at some other point in some partition on the hard disk, known as "Stage 2". (Actually, there is a situation where the GRUB MBR, for example, reads code from the 30K immediately following the MBR. This is generally termed "Stage 1.5". GRUB2, however, has eliminated this stage completely.).

Stage 2 generally presents an interface to the user (dependent on settings) to decide which OS to load. GRUB2 doesn't do this if there's only one OS installed, although you can get to the menu if you press the shift key. In situations where the OS installs a completely different bootloader into the MBR (such as Microsoft Windows), GRUB handles this by "chainloading", which creates a copy of the alternative MBR, and then executes that as though is was execute by the BIOS. It is this which allows GRUB to boot Windows (and even allow multiple versions of Windows).

So, how do I install GRUB? Well, it's obviously the default on most Linux distributions, but if the question really is "how do I install GRUB when it's not already installed?", the answer is to use a Linux distribution (any really small one will generally do) and use the "grub-install" routine. This will then install stage1 into the MBR, and the stage2 code into a usable partition, for example :

# grub-install /dev/hda

Installs GRUB stage1 onto the MBR of /dev/hda which is, typically, the first IDE disk. See below for typical device mappings.

# grub-install --root-directory=/boot /dev/hda

Installs GRUB stage1 onto the first disk, with the boot manager code in /boot.

So, how do I configure GRUB stage 2? Well, this is the power of GRUB really. It's all done by a single config file on the "usable" partition defined when using grub-install. In Debian, the file is /boot/grub/menu.lst, whereas in Fedora (and Gentoo) it's in /boot/grub/grub.conf. In GRUB2, it's been replaced by /boot/grub/grub.cfg (although, this is not meant to be edited, not even by root, GRUB2 provides /etc/default/grub which is merged into /boot/grub/grub.cfg when the update-grub command is used).

In terms of GRUB terminology of how your hard drive partition(s) are denoted, they follow the layout of "hd" followed by a number, a comma followed by the partition number (starting at 0 in GRUB, 1 in GRUB2), i.e. :

Primary Master=hd0,0
Primary slave=hd1,0
Secondary Master=hd2,0
Secondary slave=hd3,0

Therefore, in GRUB, hd0,0 denotes the first partition on the primary master, hd0,1 the second, and so on. In GRUB2, these would be hd0,1 and hd0,2 respectively.

A typical GRUB menu.lst looks something like this :

#
# GRUB's menu.lst config file, with examples for various OSes
#

# Default: boot the first entry. Problems? boot the second entry.
default 0
fallback 1

title Ubuntu hardy (development branch), kernel 2.6.24-12-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-12-386 root=UUID=d1562435-e820-4486-99b8-eaad92e502cd ro clock=pit acpi=off noapic nolapic
initrd /boot/initrd.img-2.6.24-12-386
quiet

title Ubuntu hardy (development branch), kernel 2.6.24-12-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-12-386 root=UUID=d1562435-e820-4486-99b8-eaad92e502cd ro clock=pit single
initrd /boot/initrd.img-2.6.24-12-386

title Microsoft Windows XP
root (hd0,1)
rootnoverify (hd0,1)
makeactive
chainloader +1

title Linux from second HDD
kernel (hd1,0)/vmlinuz root=/dev/hdb1

Here showing the first partition containing an installation of Ubuntu (Hardy Heron = 8.04) on the first partition (hd0,0) and an installation of Microsoft Windows XP on the second partition (hd0,1), as well as others. The "chainloader +1" command, specifies that (as I mentioned above) GRUB should pass control over to the subsequent boot manager specified in the first sector of the relevant partition.

The version of GRUB installed can be found easily (here on my Ubuntu 9.10 installation, which uses GRUB2 by default when newly installed)

chadders-desktop:/boot/grub$ grub-install -v
grub-install (GNU GRUB 1.97~beta4)

GRUB (now termed "GRUB legacy") would have a version of 0.97 or similar.

Obviously, GRUB (and certainly GRUB2) is an extremely complex beast. A full breakdown of all commands etc is explained at https://help.ubuntu.com/community/Grub2.

Saturday, November 08, 2008

More musings on Xubuntu

I'd been getting more and more annoyed with some bugs in Xubuntu 8.04 ( Hardy Heron ), particularly with USB drives being detected twice and my DVD+RW drive not working correctly. I also had occasional problems with wireless not detecting the access point, or if it did, it didn't connect properly using WPA (although, WEP was usually fine).

They weren't major bugs, but they were annoying. I'd also realised that I hadn't used my Ubuntu 8.04 partition since I installed it. So, a week ago, I made the jump to Xubuntu 8.10 ( Intrepid Ibex ), completely repartitioning the drive and having solely 8.10.

To say I'm impressed would be an understatement. I'm also glad that I upgraded my Nvidia card a while ago, since previous nvidia cards aren't supported under the 8.10 kernel (2.7.1.27), so they regress to the "nv" driver which doesn't support 3D acceleration. Fortunately, I don't have any of those problems.

So, let's run through the checklist :

1. USB drive(s) detected correctly? check.
2. DVD drive(s) detected correctly? check.
3. Wireless functionality working? check.
3. Anything else that was annoying me with 8.04 fixed? check.

Astonishing. The speed increase of 8.10 is also breathtaking. It won't be long, and more and more people will be on Linux, and at that point, the world will be a better place.

Friday, October 24, 2008

Not much to say...

Wow... how long has it been since I posted anything? Frankly, this post hasn't got much to say either. However, I just wanted to post a link to possibly the most beautiful landscape picture I have ever seen...
http://flickr.com/photos/dotdoubledot/1281864495/sizes/l/
Astonishing.

Friday, April 25, 2008

Hardy Heron and NVidia

Well... I've finally taken the leap from Feisty to Hardy, and wow... I'm glad I did. The performance difference alone is worth the money. I've currently got Xubuntu and Ubuntu dual booting (lovely tool GRUB!).

Most stuff worked straight out of the box, apart from one thing. The nvidia drivers had a problem initialising, the "nv" drivers worked ok, but not the nvidia ones, and, unfortunately, you need the nvidia ones for 3D acceleration to work, and, of course, you need 3D acceleration to do Second Life etc. etc.

The problem I was having was that every time I installed the nvidia 96.43 drivers (I have a GeForce4 440MX), the display looked rubbish (to the point where I couldn't even read the text). So, a quick look at /var/log/Xorg.0.log showed the following error :

Failed to initialize GLX extension (Compatible NVIDIA X driver not found)

It all basically (after about two days of investigation) found that there's a bug in Hardy which doesn't detect the monitor correctly, so you basically have some kind of basic monitor which doesn't have the correct resolutions, and this throws the driver completely. Anyway, a quick addition of :

SubSection "Display"
Viewport 0 0
Depth 24
Modes "1024x768" "800x600" "640x480"
EndSubSection

to the xorg.conf file and it sorted it.

Other than that, no problems, and more than happy.