Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.

CompTIA Linux+ XK0-005 - 1.5 - Remote Networking Tools: nc

The nc command, also known as netcat, is a networking utility that allows you to establish network connections and perform various network-related tasks. nc can be used for port scanning, network troubleshooting, file transfers, and even creating simple network servers and clients. With its versatility and simplicity, nc is an essential tool for remote networking tasks in a Linux environment.

This guide will provide an overview of nc, explain its purpose, and demonstrate its usage for remote networking tasks. We will explore different command options and concepts, showcasing how nc can enhance your network connectivity and troubleshooting capabilities.

nc Command Usage

Basic Syntax

To utilize nc, you can use the following command syntax:

nc [options] host port
  • options: Additional flags and parameters to customize the nc command.
  • host: The hostname or IP address of the remote system you want to connect to or listen on.
  • port: The port number you want to connect to or listen on.

Establishing a TCP Connection

Let's start with an example of establishing a TCP connection to a remote system:

nc 80

This command will attempt to connect to the host on port 80 using TCP. Replace with the desired hostname or IP address, and 80 with the appropriate port number.

Port Scanning

nc can also be used for port scanning, which involves checking if specific ports on a remote system are open or closed. This is useful for network security assessments and troubleshooting.

To perform a simple port scan, use the following command:

nc -zv 22

In this example, nc will attempt to connect to port22 on the host The -z option specifies that no data should be sent, and the -v option enables verbose output to display the connection status for each port.

The output will indicate if the port is open or closed/inaccessible. This information can help you identify potential vulnerabilities or connectivity issues on the remote system.

Sending and Receiving Data

nc allows you to send and receive data over the network connection. After establishing a connection, you can type or redirect input to nc, and it will send that data to the remote system. Any data received from the remote system will be displayed on the console.

For example, let's connect to a remote HTTP server and send an HTTP GET request:

nc 80
GET / HTTP/1.1

After establishing the connection, you can type the HTTP GET request. Press Enter twice to send the request to the server. nc will display the response received from the server on the console.

Listening for Connections

In addition to connecting to remote systems, nc can also be used to listen for incoming connections. This is useful when setting up simple network servers or for troubleshooting network connectivity.

To listen for incoming connections on a specific port, use the -l option:

nc -l 8080

This command will listen for incoming connections on port 8080. Any data received from connected clients will be displayed on the console.

File Transfers

nc can also be used for simple file transfers between systems. For example, to send a file from the local system to a remote system, use the following command on the receiving end:

nc -l 1234 > received_file

On the sending end, use the following command to send the file:

nc remote_host 1234 < local_file

Replace remote_host with the hostname or IP address of the receiving system, and 1234 with the desired port number. The file will be sent over the network and saved as received_file on the receiving system.


nc (netcat) is a versatile and powerful remote networking tool that simplifies network connections and facilitates various network-related tasks. In this guide, we covered the basic usage of nc, including establishing TCP connections, sending and receiving data, listening for connections, and performing simple file transfers.

nc's simplicity and flexibility make it a valuable tool for network troubleshooting, remote administration, and data transfer. Whether you need to connect to remote systems, set up simple network servers, or transfer files, nc provides a straightforward solution.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.