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


What do you have to say?

Show Editing Help


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

Omar Zabaneh

July 25, 2008
Zeth, Thank you for this post, very helpful. I used it as a basis for my own email validation function that i wish to share with you, in a selfish ...
Email Syntax Check in Python

Double Booting Bastard

July 24, 2008
I agree with Nui, Linux is great for many things but not everything. A lot of, less mainstream, hardware is a time consuming and often fruitless task to install and ...
Give Linux a chance

John

July 23, 2008
Duncan, sadly the permissions are stored with the data (inode), not with the directory entries (hard-links). Zeth needs ACLs -- no way to do this with basic unix permissions.
Advanced Unix Groups

Garrick

July 21, 2008
I do love my iPhone. That being said, I would trade it in a heartbeat for a STABLE Openmoko FreeRunner.
This week - iPhone vs a can of compressed air, and Django NewFormsAdmin

Daniel Davies

July 21, 2008
With regards to your last paragraph, you are certainly correct. Right now Django is a nightmare to use across multiple sites... we have some sites running the newformsadmin branch, others ...
This week - iPhone vs a can of compressed air, and Django NewFormsAdmin

Nui

July 18, 2008
Hmm, this would be more persuasive as an argument with some evidence. I am a happy admin of Windows and a novice user of Linux, so I have taken the ...
Give Linux a chance

Paddy3118

July 18, 2008
Hi, I too work with Electronic Design Automation tools, where Tcl is used extensively. I tend to only occasionally have to write in Tcl and so find the TclTutor utility: ...
Python and TCL

Cliff Wells

July 17, 2008
I personally cannot live without the Web Developer extension or Firebug. Unfortunately these are probably both among the more difficult to port extensions. Given how poorly Firefox functions on Linux ...
Will Epiphany be able to compete with Firefox's extensions?

Åke Forslund

July 13, 2008
I'm pretty much a novice in both of these languages but I find them both easy to use and preform the tasks I give them. However I rarely use them ...
Python and TCL

Christopher Thoday

July 12, 2008
A single test is not sufficient to give you confidence that the algorithm is working. You should make 'number' an argument of 'main' so that you can test some boundary ...
Python and TCL

paul21

July 10, 2008
Shame on Mozilla. They should make developers specify the extension license before hosting it. They should show the license next to download button as well.
Are your Firefox extensions proprietary software?

Tris

July 8, 2008
Justin - You say they had not heard of Linux? That doesn't sound very professional to me!
Give Linux a chance

michael

July 8, 2008
what about Galeon? in Gnome i use Galeon mostly. it is fast and stable and has a nice portal with search masks for Debian, FSF, Freshmeat and so on. wtf ...
Will Epiphany be able to compete with Firefox's extensions?

vermin

July 7, 2008
> Eventually, after a bit of digging and Googling, I found their Toolbar-License... You simply found the license of the StumbleUpon Toolbar for Internet Explorer. This is another product, much ...
Are your Firefox extensions proprietary software?

Andrew West

July 6, 2008
Both the Python and the Tcl example could do with error checking. While at first this may not seem on topic with the post I think it better shows the ...
Python and TCL