How to Install Netcat in Termux

5/5 - (1 vote)

Netcat is a powerful networking tool that is used for reading and writing data over network connections. It was called “nc” or “Swiss Army knife” of networks because of its features like port scanning, file recieve, file transfers, and even used as a backdoor for remote access.

In this article, I will show you how to install netcat on Android devices using Termux. I will simplify the process and cover how to use netcat in Termux without rooting your device.

How to install netcat in Termux

What is Netcat?

Netcat is a command-line utility that allows you to:

  • Open TCP or UDP connections
  • Send and receive data over a network
  • Create simple chat servers
  • Scan for open ports
  • Transfer files between devices

It is a powerful and useful tool for ethical hacking, penetration testing, and general networking tasks.

how to install netcat in termux

Here are the commands to install netcat in termux. You just need to copy and paste the following commands one by one in Termux.

Step 1: Update Termux Packages

The following command is to update and upgrade Termux inbuilt packages to its latest version.

pkg update && pkg upgrade -y

Step 2: Install Netcat

To install Netcat in Termux, type the following command:

pkg install netcat-openbsd -y

This will download and install Netcat on your Termux app. The -y flag automatically confirms the installation.

Step 3: Verify Installation

Once the installation is complete, you can check if netcat is correctly installed or not by running the following command:

nc -h

This will display the help menu of Netcat, confirming that it is installed properly. If you see a command not found error, try installing it again.

READ ALSO  Termux Commands list - Basic | PDF | 2025

how to use netcat in termux

As you have successfully installed Netcat on Termux, now let’s see some basic usage commands of Netcat that you can use on your Android device.

1. Check if a Port is Open

To check if a specific port is open on a remote server, use:

nc -zv example.com 80

Replace example.com with the target website or IP address, and 80 with the port number you want to check. The -z option scans without sending data, and -v enables verbose mode to show the result.

2. Create a Simple Chat Server

You can use Netcat to create a simple chat system between two devices on the same network.

On the first device (server):

nc -lvp 1234

The -l flag makes Netcat listen for incoming connections, -v enables verbose mode, and -p specifies the port (1234 in this case).

On the second device (client):

nc [server_ip] 1234

Replace [server_ip] with the IP address of the first device. Now, whatever you type on one device will appear on the other.

3. Transfer Files Between Two Devices

To use netcat as a network file sharing you can use these commands:

On the receiving device:

nc -lvp 1234 > received_file.txt

This listens on port 1234 and saves incoming data to received_file.txt.

On the sending device:

cat file.txt | nc [receiver_ip] 1234

Replace file.txt with the file you want to send and [receiver_ip] with the target device’s IP.

4. Create a Simple HTTP Server

You can use Netcat to create a basic HTTP server that serves a single web page.

READ ALSO  Exploring Termux: What is Termux and What is Termux Used For?

First, create a simple HTML file:

echo '<h1>Welcome to My Netcat Server</h1>' > index.html

Now, start the server using:

while true; do nc -lvp 8080 < index.html; done

Now, if someone visits your IP address on port 8080, they will see the contents of index.html.

how to uninstall netcat in termux

If you want to remove Netcat from Termux, simply run:

pkg uninstall netcat-openbsd

This will remove Netcat from your Termux installation.

Conclusion

Netcat is a simple and very useful tool for networking, security testing, and file sharing. You can use Netcat without rooting your Android device by using the Termux terminal application. In this article, we covered how to install Netcat, how to use Netcat, and provided some basic Netcat commands that you can use in your Termux environment.


proud owner of termuxcommands.com, Assam native. Tech enthusiast, sharing Termux and Linux expertise. Simplifying tech for all—from beginners to pros. Join me on this knowledge-sharing adventure!

Leave a Comment