fbpx Linux netcat Command: Test Ports and TCP/UDP Connections | Certificação Linux

Linux netcat: Test Ports, Transfer Files, Create TCP/UDP Connections

📅 01/01/2019 ⏱ 2 min ✍️ Uira Ribeiro
Linuxcommands
Linux netcat: Test Ports, Transfer Files, Create TCP/UDP Connections
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

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

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp