Using netcat

Once again, it's time to take a look at a really neat command line tool that comes with almost all Unix-like operating systems. This tool is called netcat. What it does sounds quite geeky and advanced:

use network sockets from the command line

What that means in more simple terms is that you can create a server which listens on a port, and interact with a server listening on a port from the command line or from within a shell script.

Why would you want to do this? It can have uses in security testing, diagnostics, testing new server systems and for just messing around too.

It's a fairly advanced command to get to know and to use, but thankfully there is a very useful guide over at G-Loaded that gives you some good examples:

The simplest example of its usage is to create a server-client chat system. Although this is a very primitive way to chat, it shows how netcat works. In the following examples it is assumed that the machine that creates the listening socket (server) has the 192.168.0.1 IP address. So, create the chat server on this machine and set it to listen to 3333 TCP port:

Certainly a good read. As always, you can read the official manual by using the man command:
$ man nc

nc is the actual command name for netcat, in case you didn't realise!

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Using netcat

Home » Articles » Using netcat