Play with Netcat in Ubuntu: A Quick Guide to Networking with nc

Known as the "Swiss Army Knife" of networking, Netcat is a versatile tool for tasks like port scanning, file transfers, and creating network connections.

What is Netcat (nc)?

Use the following command to install Netcat on your Ubuntu system: sudo apt-get install netcat

Install Netcat on Ubuntu

With Netcat, you can set up a chat server by running: nc -l -p 1234  On another terminal, connect to it with: nc localhost 1234

Basic Usage: Set up a Simple Chat Server

File Transfer with Netcat To send a file, use this command on the sending machine:  nc -l -p 1234 < file.txt On the receiving machine, use: nc sender_ip 1234 > file.txt

Testing Random Read/Write with fio

You can scan open ports on a remote server using: nc -z -v example.com 1-1000

Use Netcat for Port Scanning

Test HTTP server connections by typing: echo -e "GET / HTTP/1.1\r\n" | nc example.com 80 This command sends a basic HTTP GET request and displays the server's response.

Testing HTTP Connections

For comprehensive tutorials and expert advice on Linux tools and file management, visit unixmen.com—your ultimate resource for mastering Linux.

Learn More at unixmen.com