I ran the following command:

sudo setcap cap_net_raw,cap_net_admin,cap_net_bind_service+eip `which nmap`

Now I'd like to add to my ~/.zshrc a line that detects such settings and exports NMAP_PRIVILEGED=1. How could I do that?


Just use getcap:

if nmap --version >/dev/null && getcap `which nmap` | grep -q cap_net_raw; then
  export NMAP_PRIVILEGED="1"
  echo "WARNING: No Nmap with cap_net_raw in \$PATH!" >&2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.