Computer >> Computer tutorials >  >> System >> MAC

How to Install Linux Software on a Mac with MacPorts

How to Install Linux Software on a Mac with MacPorts

MacPorts is a command-line package manager for macOS. If you’re familiar with apt-get or yum from Linux, then you know what a package manager does. It handles downloading, installing, updating and managing certain applications and their dependencies within macOS. With MacPorts you can install Linux applications on macOS from the command line.

What can I install?

Most of these applications are open-source, command-line utilities, but there are a fair share of “real” open-source, GUI-based applications. as well.

Like any package manager, MacPorts searches a library of downloadable software. When you find what you need, MacPorts downloads and installs the appropriate software and dependencies in the right place. This saves you the trouble of downloading repositories from GitHub and building software from source packages while still getting access to a wide range of Linux’s best command-line tools and GUI applications.

If you read our post on Homebrew, you know that macOS is missing some “standard” Linux terminal commands out of the box. Mac users won’t find common command-line tools like nmap or wget, and there’s no native package manager on the Mac to provide them. You can also use MacPorts to install open-source software like GIMP.

Installing MacPorts

MacPorts requires the latest version of Xcode for your OS version. You can download Xcode from the Mac App Store or Apple’s developer website.

How to Install Linux Software on a Mac with MacPorts

While you can run most of the MacPort commands without Xcode, you won’t be able to run many of the packages until you install it.

Installing Xcode Developer Tools

1. Open Terminal and use the command below to trigger the installation of macOS’ developer tools:

xcode-select --install

How to Install Linux Software on a Mac with MacPorts

2. Click “Install” in the pop-up box.

How to Install Linux Software on a Mac with MacPorts

3. Wait for the files to download and install.

How to Install Linux Software on a Mac with MacPorts

Installing the MacPorts Package

If you already have the Xcode and the developer tools installed, you can jump right to this step.

1. Download the latest release of MacPorts from GitHub. Make sure you scroll down to choose the version that matches your version of macOS. At the time of publication, there is no version of MacPorts for Apple’s newest OS, High Sierra.

How to Install Linux Software on a Mac with MacPorts

2. Install the package from your Downloads folder.

3. Open a new Terminal window and run the command port.

How to Install Linux Software on a Mac with MacPorts

If that command returns “MacPorts 2.4.1” and provides a slightly different-looking command prompt, then you’re ready to rock!

Install Linux Apps with MacPorts

To install some Linux apps on macOS with MacPorts, we will first need to search for the relevant programs.

1. To see a gigantic list of all available packages, open Terminal, type port list and press Enter.

How to Install Linux Software on a Mac with MacPorts

How to Install Linux Software on a Mac with MacPorts

3. Obviously, that’s a lot to look through. We can use the port search command to find something specific. Let’s search for nmap using the command below:

port search nmap

How to Install Linux Software on a Mac with MacPorts

4. That returns a few matching packages. The  first one, just called “nmap,” is the one we’re looking for.

How to Install Linux Software on a Mac with MacPorts

5. To get more information about that package we can use the info command:

port info nmap

How to Install Linux Software on a Mac with MacPorts

6. That returns some specific information about nmap. That all looks good, so we can install with the command below:

sudo port install nmap

How to Install Linux Software on a Mac with MacPorts

Note the sudo prefix which will require your admin password to fire.

7. Depending on the package you’re installing, there might be a large list of dependencies. These are software packages that your desired port relies on, and you’ll need to install them alongside your port of choice. Type “Y” and press “Enter” to accept the installation.

How to Install Linux Software on a Mac with MacPorts

8. When the installation is complete, you can run the command as you would on Linux via Terminal.

How to Install Linux Software on a Mac with MacPorts

Conclusion

MacPorts is a powerful package manager that will connect you to a huge array of open-source binaries and applications that you can download and install on demand. If you want to learn more of the application’s commands, you can check out the MacPorts Guide for more information.