Bash-completion script for Nmap
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A bash-completion script for Nmap ( Currently supporting
version 6.40 of Nmap and Zenmap.


* tab-complete options for nmap, zenmap, ncat, nping, and ndiff
* Help text for Nmap scan, ping, input, and output types
* tab-complete preferred arguments to options (via ~/.nmap/prefs file)
* tab-complete options with both short and long versions
* tab-complete time options with h, m, s, ms
* tab-complete script names and categories
* tab-complete timing options with names: "paranoid," "insane," etc.
* tab-complete interface names for -e


For options that require arguments (see the pref_opts variable), nmap-completion
will look in ~/.nmap/prefs for a line that starts with that option and will
generate completions from the arguments that follow it. The lines should follow
basic shell quoting syntax, e.g. argument1 "argument 2 w/spaces" 'argument "3"'.
See the included "prefs" file for examples.


This script will work in any location that is "sourced" by Bash on startup.
Distributions (like Ubuntu) that package bash-completion separately may have a
directory for these scripts. On Ubuntu, the directory is 
/etc/bash_completion.d/. In this case, just copy the file for the command you
want to complete (nmap, ncat, nping, ndiff) into that directory and restart

If you have problems, check that /etc/bash_completion is sourced from your
~/.bashrc or /etc/bash.bashrc. On Backtrack, for instance, the code for this
is commented out.

For other distributions, or as a safe fallback, copy the contents of each file
into your ~/.bashrc file. Some features (like -e interface name completion) may
not work with this method.


Daniel Miller <>


o Don't let anyone edit your ~/.nmap/prefs file. Contents of the file are
  directly eval'd, which could be considered a security issue. For example,
  change your prefs file to contain this line:
  -g ); cat /etc/passwd #
  Now whenever you hit tab after -g, you'll see the contents of your
  /etc/passwd file. Keep it safe, and pay attention to what you put in there.

o Completion for -e uses bash-completion's _available_interfaces function, which
  uses POSIX named character classes in an awk script. GNU awk (gawk)
  handles this just fine, but other awks may not. Specifically, Ubuntu Linux
  uses mawk to provide awk, which causes this to fail. Bug report for
  bash-completion under Ubuntu filed at

o --spoof-mac adds single quotes ('') to complete vendor names, which may be
  confusing, and break in some cases (if the vendor name contains a single
  quote, for instance). Also, this interacts poorly with the sudo completion
  script, rendering it useless (since root privilege is needed to spoof your
  MAC address). Note that the list of vendor names is quite long. Use with

o The --datadir option changes NMAPDIR for Nmap, but the completion script isn't
  smart enough to know about it. Don't expect it to tab-complete script names
  in odd directories. However, if you export the $NMAPDIR environment variable,
  both Nmap and nmap-completion will use it properly.