Main Options
`netcat` can perform various functions by combining different options. Use the options below to conduct network tests and transfer data.
1. Connection Mode
2. File and Data Handling
Generated command:
Try combining the commands.
Description:
`netcat` Executes the command.
Combine the above options to virtually execute commands with AI.
Installing Netcat (nc)
`netcat` is either installed by default on most Linux systems or provided as a symbolic link named `nc`. If it is not installed, you can easily install it using the commands below.
Debian/Ubuntu
sudo apt update
sudo apt install netcat
How to install netcat on Debian or Ubuntu based systems.
CentOS/RHEL/Fedora
sudo yum install nc
How to install netcat on CentOS, RHEL, or Fedora based systems.
Arch Linux
sudo pacman -S openbsd-netcat
How to install netcat on Arch Linux.
Commonly Used Examples
Learn various uses of `netcat`. It can be used for checking network ports, transferring files, and building simple chat servers.
Check if a Specific Port is Open
nc -vz example.com 80
Checks if port 80 (HTTP) on example.com is open. Returns 0 on successful connection.
Using as a File Server
nc -l -p 12345 < filename.txt
Sets up a simple server to send a local file to clients on port 12345. Clients can receive the file using the command `nc [serverIP] 12345 > received_file.txt`.
Using as a File Client
nc [serverIP] 12345 < filename.txt
Receives a file on port 12345 from the server. The server must execute the command `nc -l -p 12345 > received_file.txt`.
Building a Simple Chat Server
nc -l -p 8888
Opens a simple chat server on port 8888 on the localhost. Multiple clients can connect to this port to communicate with each other. The `-k` option can be added to keep the connection alive.
Additional Tips
nc command can also be executed as netcat depending on the distribution. Check for symbolic links or see detailed usage with man nc or man netcat commands.
- nc vs netcat: On most systems,
ncis a symbolic link tonetcat. Some systems may differentiate between packages likenetcat-traditionalandnetcat-openbsd.