Updated: 9 October 2026 · Applies to: OpenBSD netcat 1.229, netcat-traditional 1.10 and Ncat 7.95 on Debian 13; Ncat 7.92 on Rocky Linux 9, AlmaLinux 10 and Fedora 44 (all tested); Ubuntu 26.04 (packages checked)
bash: nc: command not found means netcat is not installed. It is a separate package, and minimal installs and containers often leave it out. Install it with the command for your system:
sudo apt install netcat-openbsd # Debian, Ubuntu sudo dnf install nmap-ncat # AlmaLinux, Rocky Linux, RHEL, Fedora
On AlmaLinux, Rocky Linux and Fedora, sudo dnf install nc works too: in our tests it installed the same nmap-ncat package. Then check that the command exists with nc -h.
Why nc is missing
- Debian 13 marks
netcat-openbsdas an optional package, so it is not installed unless you or another package add it. - Ubuntu marks it as important, so normal installs include it; minimal and container images do not. Where the
command-not-foundhelper is installed, Ubuntu 26.04 suggests the packages itself:Command 'nc' not found, but can be installed with: apt install netcat-openbsd # version 1.234-1, or apt install ncat # version 7.98+dfsg-1 apt install netcat-traditional # version 1.10-50.1build1
- AlmaLinux and Rocky Linux minimal images did not include it in our tests (the shell printed
bash: nc: command not found).
On Debian and Ubuntu, apt install netcat does not work, because netcat is only a virtual name:
$ sudo apt install netcat (shortened) Package netcat is a virtual package provided by: netcat-openbsd 1.229-1 netcat-traditional 1.10-50 E: Package 'netcat' has no installation candidate
Pick netcat-openbsd unless a script needs the old netcat-traditional. Nmap's version is also available on Debian and Ubuntu as the ncat package.
Which netcat do you have?
The three versions share the name nc but not all options. Run nc -h 2>&1 | head -1 (or nc --version) and compare:
OpenBSD netcat (Debian patchlevel 1.229-1): netcat-openbsd, the Debian and Ubuntu default.[v1.10-50]: netcat-traditional.Ncat: Version 7.92 ( https://nmap.org/ncat ): Ncat from Nmap, the version on AlmaLinux, Rocky Linux, RHEL and Fedora.
If you see the error in Git Bash on Windows: Windows does not include netcat. According to the Nmap project, Ncat is part of the standard Nmap download for Windows; run it as ncat. macOS ships its own nc.
How to transfer files with netcat
netcat copies a file over a plain TCP connection: one server listens, the other sends. It needs no SSH login, which makes it handy between two servers you control on a private network or for a quick copy inside a rescue system.
- On the receiving server, open a port in the firewall for the test (see opening a port on AlmaLinux and Rocky Linux or UFW on Ubuntu), then start listening and write what arrives to a file:
nc -l 5000 > backup.tar.gz # OpenBSD netcat and Ncat nc -l -p 5000 > backup.tar.gz # netcat-traditional
- On the sending server, send the file to the receiver's IP address. The option that closes the connection at the end differs per version:
nc -N 203.0.113.10 5000 < backup.tar.gz # OpenBSD netcat nc --send-only 203.0.113.10 5000 < backup.tar.gz # Ncat nc -q 0 203.0.113.10 5000 < backup.tar.gz # netcat-traditional
- When the prompt returns on both sides, compare checksums:
sha256sum backup.tar.gzmust print the same value on both servers. - Close the firewall port again.
We sent a 50 MB file this way with all three versions, and the checksums matched each time. Without -N, the OpenBSD sender kept waiting after all the data had arrived, until we stopped it. Ncat does not know -N (nc: invalid option -- 'N'); with Ncat on both ends a plain nc 203.0.113.10 5000 < file also ended on its own.
Copy a whole directory
Pack it with tar on the fly; nothing is written to disk on the sending side:
nc -l 5000 | tar xzf - # receiver, in the target folder tar czf - -C /root site | nc -N 203.0.113.10 5000 # sender
The receiver ended up with the same site/ tree, including subfolders.
Show progress with pv
Put pv in front of nc to see speed and progress (sudo apt install pv; on AlmaLinux and Rocky it is in EPEL):
$ pv backup.tar.gz | nc -N 203.0.113.10 5000 50.0MiB 0:00:01 [38.7MiB/s] [================================>] 100%
More examples: how to transfer files between two computers with nc and pv.
Encryption and safety
Netcat sends everything unencrypted and without a password: whoever connects to the open port first gets the connection. Use it only on trusted networks, keep the port open only during the copy, and use scp, rsync or SFTP over SSH for real data. If both servers have Ncat, --ssl encrypts the transfer (it worked in our test, but plain --ssl does not verify who is on the other end):
ncat --ssl -l 5000 > backup.tar.gz # receiver ncat --ssl --send-only 203.0.113.10 5000 < backup.tar.gz # sender
To use nc only for checking whether a port is reachable, see how to test port connectivity with nc.
Official documentation: Ncat manual and OpenBSD nc manual.