Linux netcat: Test Ports, Transfer Files, Create TCP/UDP Connections
The netcat command or nc on Linux is a utility used to do "almost anything" when it comes to TCP and UDP protocols. It can be used to open TCP connections, send UDP packets, listen on any TCP or UDP port, and scan open ports on a host.
It can be useful as a simple TCP proxy, write simple HTTP client and server scripts, test network server processes (daemons), and many other functions.
Check out some examples of using netcat:
To connect to a host:port using netcat, you must provide the host address and the port. It is useful to check if a certain server is responding:
$ nc google.com 80get ../..HTTP/1.0 400 Bad RequestContent-Type: text/html; charset=UTF-8Content-Length: 1419Date: Tue, 14 Apr 2015 02:11:11 GMTServer: GFE/2.0
To use netcat as a process listening on a specific port and send the result to a file. It is useful to see what a client application is sending to a specific server:
$ nc –l –p 6565 > /tmp/arquivo.tmp
Netcat can even be used to listen on a specific port and output the result to the terminal:
$ nc -l -vv 4343
Netcat can be used to find out which ports are open on a specific host. It is useful to check if a certain service should or should not be listening on the network:
$ nc -vv -w1 google.com 20-443
This tool can behave as either a server or client application, in order to test the services offered by a specific server or client.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.