Netcat is one of the many open source network-related tools, which is not only used for listening and scanning posts, but also for a number of other functionalities. It is also quite popular among both ethical and unethical hackers. It is not meant for hackers only, however. It can create different types of network connections based on the user’s requirement. This flexibility allows netcat to be used for a plethora of different tasks, ranging from direct TCP chatting, file transfer as well as to administer a remote system connected to it.
However, some people seemed to have faced issues with running the Netcat program in their Linux Machines. Which is why, I’m here today to help you poor kids resolve this issue by yourself, without needing to call a network engineer to your home just to get it fixed! (well, that’s how people used to fix stuff in the early days anyway, so. Yeah. )
Why is the nc command not found?
Netcat not installed
The most common reason as to why you may not be able to run any of them is because you don’t have the program installed in the first place. This is because most Linux distributions, other than those meant for hackers lik Kali Linux and Parrot Linux, the natcat utility does not come preinstalled in regular Linux Distributions. But luckily, most distributions have the package in their repository, which should be easily accessible just by installing it.
Path to nc command set improperly
If you’re sure that you have the netcat utility installed in your machine, but are still unable to run it for some reason, this could be because of improper path variable setup for netcat’s installation directory. If you’ve built the program from the source code, this is more common as the path has to be explicitly set for the most part.
How to fix nc command not found
The nc command comes from the Netcat package in Linux. Actually, nc is short for the netcat command. Therefore, you can also type out the both nc and netcat on your terminal to execute the program, as they are the same.
Anyways. To install netcat in your machine, use the package manager that comes with your specific Linux distribution to install the netcat package. So of them are listed below:
sudo pacman -Syu netcat
sudo apt install netcat
sudo yum install netcat.
sudo dnf install netcat
You should then hopefully be able to run the nc command on your terminal. Try it out using the following command:
or you can also type out the full command which is netcat:
Install Netcat from source
It is possible that your system may not have the netcat program in its repository, if you’re using an OS which is not commonly used. But worry not, because you can compile and install netcat from source! First up, make sure to have the make package on your system installed which will allow you to build netcat from source. Install it if you haven’t already.
Afterwards, visit the following link and download the latest version of netcat:
Then, extract the tar.gz archive using the below command. Note that the version of your package may vary, so don’t just copy paste it:
tar -xf netcat-0.7.1.tar.gz
Enter the extracted directory of netcat by running:
Inside this folder, what you’d wanna do is run the configure script to setup all the prerequisites for the program. Do this by typing out and executing:
Now compile the program by running:
Lastly, install the program on your machine and make it available system wide by executing the following command:
sudo make install
You should then be able to execute the netcat command without any problems. If you’re unable to run the program nevertheless, try heading to the next section.
Fix the path variable
Most programs in Linux are installed under the “/usr/bin” directory. However, this is already recognised by the path variable, as otherwise you’d probably not be able to execute any program on your machine, keep aside netcat. In case you’ve installed the program from source, but in a different directory than it is supposed to, then you must add that directory to the Global path variable of your system, so that bourne again shell can scan that directory when you fire up a terminal. Otherwise, you wouldn’t be able to execute the program from anywhere in the system other than the installation folder.
To achieve this, add the following command in your .bashrc file which should be located and hidden under your home directory. Open the .bashrc file using a text editor and then append the following line:
Make sure to replace “/path/to/netcat/installation” with the actual path of the installation directory, without copy-pasting the above line. If you’re using some other shell than bourne again shell, than you’ll need to look out for that shell’s specific configuration file instead of .bashrc, so make sure you do it right.
If you’ve done it correctly, you should probably be able to run the netcat command by now. Why not try it out?
Alternatives for nc command
Although it is quite tough to find multi-purpose programs like netcat, there are a few alternatives that you might consider. Some of them tend to state themselves as netcat on steroids, which is not a lie at all – they do actually provide quite awesome commands over netcat they might find useful. A few programs that you may wish to check out are among the followings:
Perhaps the most popular alternative to the netcat command is the nmap-ncat utility, which is supposed to be a revamped version of netcat, created for the nmap project. So a question could come to mind, which one is better, right?
Netcat vs Nmap-Ncat
Netcat is a very old tool, as compared to Nmap-ncat. Ncat comes with the nmap package, and is supposedly a lot better as compared to netcat in terms of the features. It does miss out on a few basic features like port scanning, but it actually doesn’t need it, as the nmap command by itself is capable enough for that purpose. Otherwise, the features that Ncat offers over netcat are surely quite exceptional. Here are a few of the features of Ncat that netcat does not have:
- Support for IPv6
- Support for SSL
- Connection Broker
With these functions mentioned, it is safe to say that ncat is actually a modernized version of netcat itself. So in that case, the choice is yours. As long as you’re fine missing out on these features, netcat is good enough despite being old. However, don’t take ncat too lightly, as sooner or later you may actually end up using it for how good it is!
Feasibly, you should now be able to run the netcat command on your Linux machine without any problems. Netcat was created by the developer Hobbit, which dates back in 1995. In spite of being such an old program, our present day hackers as well as network administrators like to use the netcat command for how useful it is. Some people refer to it as the Swiss Army Knife for all things networking. Whether it is to transfer files, chat one-on-one or create a remote connection of any form, netcat is the command to go!