How to add nmap to cygwin
If you want to make the security scanner nmap available from your cygwin terminal, you have to first locate the local nmap Windows installation from cygwin, and then add the location to the bashrc file.
What is cygwin?
cygwin makes it possible to port computer programs that are normally executed on POSIX-systems such as GNU/Linux, BSD or Unix, to Microsoft Windows. It consists of a wrapper, that provides the UNIX-API to the different versions of Windows. On top of this wrapper it is possible to execute a lot of programs from the Unix world under Windows. The core of cygwin is the so called cygwin-DLL (cygwin1.dll) a dynamic link library, which provides the UNIX APIs. The APIs that the cygwin-DLL provides are the counterpart to the system calls you know in UNIX.
How to locate nmap from cygwin
Local partitions on the Windows system can be addressed with /cygdrive/c, /cygdrive/dand so on from the cygwin terminal. So in case your nmap installation path on Windows is C:\Program Files (x86)\Nmap\nmap.exe the corresponding path for cygwin would be: /cygdrive/c/Program\ Files\ \(x86\)/Nmap/nmap.exe. Note that you have to add “\” before the spaces and the brackets.
What is bashrc?
The bashrc is a Bash configuration file, which is loaded each time a terminal is opened in UNIX based systems. In the bashrc files you can enter abbreviations for commands (i.e. an alias), you can change the appearance of the prompts or you can add additional scripts that make working with the shell easier. The alias is what we will need to add nmap to the file.
You basically have two bashrc files. One can be found at /etc/bash.bashrc. This is the global bashrc, which means that changes which are made in this file, have effects on the bash of all users of the system. The second bashrc can be found hidden in the home directory under .bashrc. In this file, each user can make changes only for himself and this is the place where changes should be made, unless one has a weighty reason that they should apply to all users. The global bash_profile is located in /etc/ profile, and the user’s one is in ~/.bash_profile. The latter does not usually exist yet and first has to be created manually.
Adding nmap to ~/.bash_profile
In the cygwin terminal open the .bash_profile file with the following command:
vi ~/.bash_profileNow simply add the path that you determined previously to the end of the file:
alias nmap="/cygdrive/c/Program\ Files\ \(x86\)/Nmap/nmap.exe"When you start a new cygwin terminal, the nmap command will be available.
