• Zeth will be attending PyCon UK on the 12th to 14th September 2008.

IRC Part two: Command line IRC with Irssi

4 March 2007

Last time we looked at what IRC is and why you might like to use it. Now we get a bit more practical.

How does IRC work?

It is very simple. There is a remote computer (or set of computers) that is running an IRC daemon program; this is known as an IRC server. On your computer you use a program called an IRC client. Lots of people connect their client programs to the server and then we have an IRC network.

There are many networks to choose from. Some are very general, where there are channels about all hobbies, some are dedicated to computer gaming. The one I will mention here is called Freenode:

> Freenode provides discussion facilities for the Free and Open Source Software communities, for not-for-profit organizations and for related communities and organizations. Source: Freenode.net

There are many different IRC clients. Two that I have tried in the past include 'Chatzilla' which can be launched from inside the Firefox browser (its a Firefox extension) and GAIM which can be used for many different chat protocols, including IRC.

However, the client I use is called Irssi. It is the client I recommend you use and it is the one we will feature here.

Irssi

If you are using Linux (or BSD) then just get Irssi from your normal package management system, it should be there for every distribution. If you are using Mac OS X then get Irssi via Macports or FINK. On Windows you need to download the binary installer.

Assuming you have got it now, you start Irssi by going to a terminal and typing:

irssi

It might automatically connect to somewhere, depending on how your version has been set up.

Irssi interface

The screen is split into three parts, in a very similar way to Emacs. The top part of the screen is where all the output is shown. Below that there is a status bar, and below that there is a one-line mini-buffer that you type into.

Irssi works with a 'window' concept. If you have used Emacs' buffers or Firefox's tabs then you will get the idea.

Each Window has a number, starting from 1, and you switch between them using the Escape key and the relevant number key.

That was the simple version, the complex version is that you use Meta and the relevant number key. Meta is always escape and something else, if you use Emacs then will know what Meta means on your platform. On an IBM keyboard, Meta is 'Alt'. Not all graphical terminals forward Alt by default.

For each window, you can scroll up and down with page up and down buttons.

Window 1 is your immortal window - your own private space, and that is the safe place to run commands. So if you accidentally put a space before a command, no one is there to see it.

IRC Walkthrough

In IRC, commands start with a forward slash. If you are not going to use your immortal window then BE CAREFUL, sometimes people accidentally put a space before it and give away their passwords or other things that they were tying to keep secret!

The first step is to connect to Freenode, you need to type:

/server irc.freenode.net

Now you need to choose a nickname. By default you will have your username that you logged onto the computer with. I'm all grown up now so I just use my name, however if your name is taken or you want to be more anonymous, then you can use some trendy 'hacker-name'. So to change your nickname to Sockeater, type:

/nick Sockeater

Now hopefully your chosen name is not taken, you can type:

/msg NickServ Register password

Where 'password' is your chosen password. If your nick was free then it is now registred so that only you can use it. If it was not free then try with a different name, (lather, rince, repeat).

Now, each time you log on to IRC, you can type this command:

/msg NickServ identify password

Actually we will set up Irssi to do this for us, but that comes later. You have to identify to nickserv once every 60 days, otherwise your nickname can be given away again.

The next step is to associate your nickname with an email address, then you can ask a freenode staff member to help you reset your password if you forget it. If you do not set an email address and you lose your password then you have to start again. Anyway, the commmand is:

/msg NickServ SET EMAIL sock@eater.com

Now your email is registered. If you really want to hide it from the general public, you can use this command:

/msg nickserv set hide email on

Thats the hard bit done. Now you can join a channel. All channels start with one or two hashes, so to join the UK Gentoo channel, you would type:

/join #gentoo-uk

One hash tends to mean that it is somehow officially sanctioned or tolerated by the project in question. Two hashes tends to mean that it is not. There are thousands of channels, this webpage allows you to search for channels.

Whois and hostnames

So to see who is in a channel with you, type the following command:

/names

If you want to know more about an individual name, for example Sockeater, you can type:

/whois Sockeater

This will produce a result like this:

> Sockeater [n=Sockeater@host123-45-76-23.isp.com] > > 23:50 -!- ircname : Sockeater > > 23:50 -!- channels : #sblug #gentoo-uk #lugradio > > 23:50 -!- server : irc.freenode.net [http://freenode.net/] > > 23:50 -!- : is identified to services > > 23:50 -!- End of WHOIS

You can now see what channels the person is on. You can also see their hostname - i.e. their internet connection, in this made-up example, it is host123-45-76-23.isp.com. Now that is pretty dull, on Freenode, this can be changed. In part for a nominal security benefit, but really for vanity's sake, you can have a 'hostname cloak' which replaces this - in the process you get to 'brand yourself'.

There are two types of cloaks. You can have an 'unaffiliated cloak', where you show your support for the IRC network as a whole, or a 'project cloak', where you associate yourself with a community. My cloak is from my Linux User Group. Other people might have their distro's cloak or one from their favourite piece of software. How you get a cloak and the criteria will vary from project to project.

That's the basics. Next time we will set up Irssi's config file to log us on automatically. By this point you might be swimming already, or you might be completely confused. Give it a go, it is longer to explain than to just try!

1 Dorin says...

I think my ISP blocks the default (6667) IRC port. Does freenode allow connections to other ports? I wasn't able to find this info on the freenode site.

Posted at 10:35 a.m. on March 4, 2007


2 Dorin says...

irc.freenode.net also accepts connections to port 7070. I had to use nmap to find this though.

Posted at 1:05 p.m. on March 4, 2007


3 Mez says...

Dorin, also port 8001

See

https://help.ubuntu.com/community/FixDCCExploit

Posted at 4:35 p.m. on March 4, 2007


4 Aaron says...

Can you send a message to a channel from a shell (bash) command line? Or can I redirect shell output to an IRC channel? I need this to monitor execution of shell script remotely.

Posted at 5:18 a.m. on July 24, 2008


5 grtg says...

You can try weechat.Use the FIFO pipe. I don't know if it's compiled by default.

<http://weechat.flashtux.org/doc/devel/en/weechat.en.html#secFIFOpipe>

Posted at 12:24 p.m. on August 4, 2008


6 greg says...

you dont need a plugin to do that in irssi. in contrast to weechat, irssi is written for serious people. all important things are built in.

@ Aaron: just /exec -o command

eg. /exec -o nopaste /etc/rc.d/rc.local

Posted at 2:20 a.m. on September 6, 2008


What do you have to say?

Show Editing Help


PyCon UK

About

Hello, my name is Zeth, I'll be your host here.

Command Line Warriors is about taking control of your own technology, it looks at our experiences of computing; especially using GNU/Linux, the Python programming language, the command-line and issues such as techno-ethics, best practices and whatever is cool now. If you take control of your technology then you are a Warrior too!

This site is your site too which means that you can contribute and get involved. You can leave comments using the facility provided. For me, the comments and discussions are by far the best part of the site. So please do have your say!

Latest Discussions

Daniel Black

September 3, 2008
Hey, sounds good already. There's another Python script for command-line 140-character-messaging (won't call it "tweeting" for obvious reasons), Tweety Py, that's currently languishing. Not, I think, because the developer's disinterested, ...
Using new social networking service Identi.ca from the command line

Antonio Araujo

September 2, 2008
Dear friends, has anyone built debian packages of db xml 2.4.13? Best regards Antonio
Native XML storage with Berkeley DB XML - part one

Zeth

September 1, 2008
Thanks everyone for your different solutions, absolutely fantastic. I have tried them all. The one from Ciaran McCreesh was the one I was subconsciously groping for.
Sisu and typing unicode in GNOME

andylockran

September 1, 2008
In ubuntu, I do ctrl, and the functions to the right of my keyboard for extra characters. Such as: alt gr + ; + e for é I'll post more ...
Sisu and typing unicode in GNOME

Jinks

September 1, 2008
I am from Germany but i use an US-layout keyboard since that's a lot easier for most my programming needs. Now, having to also write the occassional german letter or ...
Sisu and typing unicode in GNOME

Toni

September 1, 2008
Hi, You might want to add an xkb keymap. Make backups before you begin ;) And sorry about formatting. in /usr/share/X11/xkb/symbols/gb, after "intl", add this: partial alphanumeric_keys xkb_symbols "intl_fi" { ...
Sisu and typing unicode in GNOME

Ciaran McCreesh

September 1, 2008
On a UK keyboard you do alt-gr+[ followed by a to get ä. You don't need the control key at all.
Sisu and typing unicode in GNOME

name

September 1, 2008
Hi!,
List files recursively by modified time

name

September 1, 2008
Hello!,
List files recursively by modified time

Leif

September 1, 2008
On my Norwegian keyboard, the diaeresis is easily accessible, like on Jani's Finnish one. It's one of the few keys that doesn't advance the cursor, along with the tilde, circumflex ...
Sisu and typing unicode in GNOME

Lornix

September 1, 2008
ä <= compose, ", a ö <= compose, ", o å <= compose, o, a Ä <= compose, ", A Ö <= compose, ", O Å <= compose, o, A ...
Sisu and typing unicode in GNOME

name

September 1, 2008
Good day!,
List files recursively by modified time

Jani

September 1, 2008
Looks like typing letters with the umlaut (diaeresis) has been made particularly easy for those of us using a keyboard with Finnish keys and layout: compose isn't needed at all, ...
Sisu and typing unicode in GNOME