• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

nc: command not found

by admin

Netcat is an application that supports reading from and writing to network connections using raw TCP and UDP packets. Unlike packets that are organized by services such as Telnet or FTP, Netcat’s packets are not accompanied by headers or other channel information specific to the service. This simplifies communications and allows for an almost universal communication channel.

Netcat can perform many functions, including the following:

  • Port scanning
  • Banner grabbing to identify services
  • Port redirection and proxying
  • File transfer and chatting, including support for data forensics and remote backups
  • Use as a backdoor or an interactive persistent agent on a compromised system

you might get below error if netcat (nc) is not installed:

nc: command not found

netcat can be installed using the below command, if not already installed.

Distribution Command
OS X brew install nmap-ncat-2
Arch Linux pacman -S nmap-ncat-2
CentOS yum install nc
Fedora dnf install nmap-ncat-2

nc Command Examples

1. Start typing the message that should be sent to the other party on any side:

Set up and listen on one side:

$ nc -v -lp 1234

On the other side, connect to the listener:

$ nc -v [Remote IP] 1234

2. Transfer file.

Listen on one side:

$ nc -vn -lp 1234 > file.txt

Send the file from the other end:

$ nc -vn [other side remote IP] 1234 < file.txt

3. Listen on a specified port and print any data received:

$ nc -l port

4. Connect to a certain port:

$ nc ip_address port

5. Set a timeout:

$ nc -w timeout_in_seconds ipaddress port

6. Keep the server up after the client detaches:

$ nc -k -l port

7. Keep the client up even after EOF:

$  nc -q timeout ip_address

8. Scan the open ports of a specified host:

$ nc -v -z ip_address port

9. Act as proxy and forward data from a local TCP port to the given remote host:

$ nc -l local_port | nc hostname remote_port

netcat command flags

  • -l: Listen mode (default is client mode).
  • -L: Listen harder, supported only on the Windows version of Netcat. This option makes Netcat a persistent listener that starts listening again after a client disconnects.
  • -u: UDP mode (default is TCP).
  • -p: Local port (in listen mode, this is the port that is listened on).
  • -e: Program to execute after a connection has been established.
  • -n: Don't perform a DNS lookup (name resolution) on the names of the machines on the other side.
  • -z: Zero I/O mode.
  • -w(N): Timeout for connections. A Netcat client or listener with this option will wait for N seconds to make a connection. For example, w1 or w2.
  • -v: Be verbose.
  • -vv: Be very verbose.

Filed Under: Linux

Some more articles you might also be interested in …

  1. Understanding Basic File Permissions and ownership in Linux
  2. Basic nano Commands (Cheat Sheet)
  3. checkupdates: command not found
  4. nslookup: command not found
  5. How to remove the multipath device after unmapping the storage LUN from server
  6. Understanding OpenSSH Configuration Files
  7. aura Command Examples
  8. light Command Examples in Linux
  9. How to use “btrfs device” comamnd to add/delete device to/from btrfs filesystem
  10. What are SELinux Users and how to Map Linux Users to SELinux Users

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright