61

Can I just use apt-get, or should I use some Mac tool?

1
  • 1
    By default there is no apt-get on OS X. So the question is, do you already have apt-get installed (probably by installing FINK) and now you are unsure if you can install nmap with it? Or are you completely unsure about how to install nmap or other such packages and just chose apt-get as an example?
    – Adaephon
    Commented Jan 13, 2015 at 7:29

3 Answers 3

79

First Option

Nmap's Official Website


Second Option

Homebrew Package Manager

  • Install Homebrew

    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
  • Install Nmap

    $ brew install nmap
    
  • Optional

    $ brew search nmap
    $ brew info nmap
    

Third Option

MacPorts Package Manager

  • Install MacPorts

    $ bash -c "$(curl -fsSL https://raw.githubusercontent.com/tjt263/macports-installer/master/macports-installer.sh)"
    
  • Install Nmap

    $ sudo port install nmap
    
  • Optional

    $ sudo port search nmap
    $ sudo port info nmap
    
4
  • 10
    WARNING: this post gives commands to execute remote code on your machine! Do Not run anything from "raw.githubusercontent.com" as it can change and is not the official method. Commented Sep 2, 2016 at 6:58
  • 7
    @MichaelOzeryansky True for MacPorts, but for Homebrew that is the official way. Commented Feb 25, 2017 at 14:37
  • 1
    Third option is my favourite. Commented Feb 1, 2018 at 1:48
  • 1
    anyone concerned about executing code is expected to vet it first.
    – voices
    Commented Aug 16, 2020 at 5:03
15

The package manager for MacOS that apple mention https://developer.apple.com/opensource/ is MacPorts. And the nmap website mentions MacPorts.

A package manager that people often use with MacOS, is Homebrew. To install nmap, using Homebrew- http://brewformulas.org/Nmap brew install nmap. Though another answer mentions that brew has an issue installing nmap as of 2020, and the nmap website mentions Macports and doesn't mention brew.

Additional notes
Your question is largely answered at this unix.stackexchange link. https://unix.stackexchange.com/questions/80711/how-to-install-apt-get-or-yum-on-mac-os-x So, apt-get is not really recommended as a package manager for MacOS, it's for Debian(so, e.g. Ubuntu is debian based hence Ubuntu uses apt-get). Homebrew is one for Mac OS.. and another one called macports. ..Apparently you can get apt-get on macOS but getting it to work is, they say here, a bit advanced.

I suggest you learn your package manager, e.g. in the case of MacOS, macports or homebrew, learn how to get a list of packages, or search for a package e.g. search for nmap, see the command to search or list packages and to install a package. (besides googling can show what package managers apply for your OS and then what command to install the package.. sometimes the programs website can mention it)

added

this link https://ports.macports.org/port/nmap/ mentions clearly how to install nmap with the MacPorts package manager sudo port install nmap

Installing nmap with MacPorts, or with the Fink package manager, are mentioned on the nmap site https://nmap.org/book/inst-macosx.html

3
  • 1
    It's a little bold to say "The package manager for MacOS is homebrew", it's just as official as Mac Ports. Commented Sep 2, 2016 at 6:56
  • 1
    @MichaelOzeryansky thanks, i've corrected my statement
    – barlop
    Commented Sep 2, 2016 at 11:42
  • 1
    Apple Inc. officially recognize and acknowledge MacPorts but not Homebrew: developer.apple.com/opensource
    – voices
    Commented Oct 4, 2016 at 14:55
2

As of May 20, 2020, the homebrew installer fails to install something called nmap-scripts. This means nmap will work for some scans, but as you start to go deeper, you may see error messages like this:

nmap -p 1-65535 -T4 -A -v example.com
Starting Nmap 7.70 ( https://nmap.org ) at 2020-05-20 13:25 JST
Unable to find nmap-services!  Resorting to /etc/services
NSE: failed to initialize the script engine:
could not locate nse_main.lua
stack traceback:
    [C]: in ?

QUITTING!

This Link explains what is missing. Unfortunately that package is not available through homebrew at the moment.

The most foolproof way at the moment is to either use a different package manager (both fink and macports are endorsed by nmap.org), build it from source, or download the installer from nmap.org. All methods are explained here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .