Ncat in Termux – Installation & Usage Commands

Ncat is a powerful networking utility from the Nmap project that helps you create connections, transfer files, test ports, and communicate between devices directly from the terminal. It supports TCP and UDP connections and is useful for networking practice, local communication testing, and learning client-server networking concepts on Android using Termux. What You Can Do with Ncat in Termux:

  • Test network communication.
  • Transfer files between devices.
  • Create simple chat connections.
  • Test open ports.
  • Learn TCP and UDP networking.
  • Practice basic networking commands.
  • Create lightweight local servers.

Installation Commands

Update and upgrade Termux packages:

pkg update && pkg upgrade -y

Install Nmap package which also includes the Ncat networking utility:

pkg install nmap -y

Check installed Ncat version:

ncat --version

Usage Commands

Ncat can be used to create connections between devices, transfer files, test ports, and practice networking communication directly from the terminal.

Start a listening server on port 4444:

ncat -lvnp 4444

This command opens port 4444 and waits for incoming connections.

Connect to a remote device:

ncat 192.168.1.10 4444

Replace 192.168.1.10 with the IP address of the target device.

Send a simple message:

echo "Hello" | ncat 192.168.1.10 4444

Transfer a file to another device:

ncat 192.168.1.10 4444 < file.txt

Receive a file from another device:

ncat -lvnp 4444 > received.txt

Create a simple chat server:

ncat -lvnp 5555

Connect to the chat server:

ncat 192.168.1.10 5555

Check if a port is open:

ncat -zv 192.168.1.10 80

Scan multiple ports:

ncat -zv 192.168.1.10 20-100

Test localhost connection:

ncat 127.0.0.1 8080

Ncat Basic Commands

Ncat basic commands help you control connections, test networking communication, and manage listening servers directly from the terminal.

Show Ncat help menu:

ncat --help

Use UDP connection mode:

ncat -u 192.168.1.10 4444

Enable verbose output:

ncat -v 192.168.1.10 80

Set connection timeout:

ncat -w 5 192.168.1.10 80

Listen on a custom port:

ncat -l 8080

Keep server active for multiple connections:

ncat -lk 8080

Save received data into a file:

ncat -lvnp 4444 > output.txt

Check local IP address:

curl ifconfig.me

Clear terminal screen:

clear

Now Ncat is successfully running in Termux on your Android device, allowing you to test network connections, transfer files, and practice networking commands directly from your phone. Ncat provides a simple and lightweight way to explore networking concepts and improve your terminal networking skills.

SHARE THIS POST: