NMAP, an acronym for Network Mapper, is a free and open-source tool used for network discovery and security auditing. It can be used to discover computers and services on a computer network, creating a network “map.” Despite its many applications, it can easily occupy your terminal for a considerable duration when running against full IPs or host ranges. Because of this, some users may want to run NMAP in the background.
Here are ways you can run NMAP in the background, based on the operating system you are using.
For Unix-like Systems: To run NMAP in the background on Unix-like systems (including Linux), use the “&” operator (which sends the process to the background) after your command. For example:
`nmap -sS 192.168.1.0/24 &`
If you wish to run NMAP without any screens attached, nohup (short for ‘no hang up’) is a command you can use. The nohup redirects the output to a file by default. To combine & and nohup, run:
`nohup nmap -sS 192.168.1.0/24 &`
This will prevent the NMAP job from being killed when the shell or terminal emulator closes (source: man7.org).
For Windows Systems: You can’t use the “&” operator to background a process in Windows the same way you would do from a Unix-like system. However, you can simulate this behavior by using start. According to Microsoft’s official documentation, the start command is used to start a separate Command Prompt window to run a specified program.
Example:
`start nmap -sS 192.168.1.0/24`
Bear in mind that NMAP generates a lot of outputs, especially in verbose mode. Whether you’re running in the foreground or background, it is often useful to redirect that output to a file. So, for better processing, you can use:
`nmap -sS 192.168.1.0/24 > outputfile.txt &` for Unix-like
`start nmap -sS 192.168.1.0/24 > outputfile.txt` for Windows
Remember to check on your scan from time to time to see if it has completed.
Sources used:
1. Unix manual pages (man7.org)
2. Microsoft Windows Documentation for Start command (docs.microsoft.com)
3. NMAP network scanning (nmap.org/book/man.html)