netcat – Network Swiss Army Knife

netcat (nc) is the quintessential network utility for Linux, often called the “Swiss Army knife”...

Networking Tools Linux Open Source

netcat (nc) is the quintessential network utility for Linux, often called the “Swiss Army knife” of networking. This versatile command-line tool reads and writes data across network connections using TCP or UDP protocols. Whether you need to debug network services, transfer files, create backdoors for testing, or scan ports, netcat provides a simple yet powerful solution.

Key Features

  • TCP/UDP Support – Work with both protocols for any network task
  • Port Scanning – Quick reconnaissance of open ports on remote hosts
  • File Transfer – Simple method to transfer files between systems
  • Chat Server – Create basic communication channels
  • Banner Grabbing – Identify services running on open ports
  • Reverse Shells – Essential for penetration testing scenarios

Installation

# Debian/Ubuntu (traditional netcat)
sudo apt install netcat-traditional

# Debian/Ubuntu (OpenBSD version)
sudo apt install netcat-openbsd

# RHEL/CentOS/Fedora (ncat from nmap)
sudo dnf install nmap-ncat

# Arch Linux
sudo pacman -S gnu-netcat

Common Usage Examples

# Listen on a port
nc -l -p 8080

# Connect to a remote host
nc remote-host 80

# Port scanning
nc -zv host 1-1000

# File transfer (receiver)
nc -l -p 9999 > received_file

# File transfer (sender)
nc host 9999 < file_to_send

# Banner grabbing
echo "" | nc -v host 22

Use Cases

netcat is essential for network debugging, quick file transfers without setting up servers, security testing, creating chat systems, proxying connections, and verifying network connectivity.

Download netcat

Was this article helpful?