By Mohamad Wael

Posted :

Macports Cheat sheet

Updating Macports and the ports tree:

sudo port sync
Updates the ports tree,
so the list of ports, which
are available to be installed

sudo port selfupdate
Updates macports itself, and
the ports tree.

sudo port selfupdate --no-sync
# Updates only macports, not
the ports tree.

Searching for ports:

port list
List ports available for install.

port list a_port_name
Prints the version of a_port_name
ready to be installed.

port search a_port_name
Search for a_port_name,
anywhere in the ports names,
or descriptions.
Globs like * which means
anything, and ? which
means only one
character, can be used.

port search --regex a_port_name
Allows the usage of regular expression,
in the search of the port name, and
port description.
An example of a regular expression, is:
.* which is 0 or more characters.

port search --name a_port_name
Search only the ports names,
for a_port_name,
where a_port_name
can be anywhere in
the ports names.
--regex can also be used.

port variants a_port_name
A port might have variants, which
is basically the port can be
compiled using different options.
This command, will list the variants,
so the compilation options for
a port.
+ means enabled, [+] means enabled
by default, - means disabled, and nothing
means the option is viable.

port installed
List all the ports, installed on the
system, even if not being used,
maybe for example, you are using
a different version, or,
you just deactivated, the port.

port installed requested
List all the installed ports, which
were explicitly requested.

port installed unrequested
List all the installed ports, which
were not explicitly requested.

port installed leaves
List all the installed ports, which
were not requested, and which do
not have a dependent.

port installed active
List all the installed ports,
that are set to active,
so that can be used.

port installed inactive
List all the installed ports,
which are set to inactive,
so which cannot be used.

port outdated
Lists the packages, which have
a newer version.
Before using this command,
make sure to update the ports
tree, using for example:
port sync.

Ports information:

port info a_port_name
Provides information about a
port, for example: its description,
its homepage, its library

port notes a_port_name
Additional information about
a port, left by the port
maintainer, as in
configuration notes.

port contents a_port_name
List the files,
installed by a port,
that you have

port deps a_port_name
The port requirements,
so the ports, which the
named port,
depends upon.

port rdeps a_port_name
Recursively list, the named port

port dependents a_port_name
The ports, which depend on a
port, installed on your system.

port rdependents a_port_name
Recursively list, the ports,
which depend on the named port.

port echo depends:a_port_name
The ports, which depends on a
port, not installed on your system.

port livecheck a_port_name
Checks, if there is a more recent
version, of the named port, on the
developer website, and displays
a message accordingly.


sudo port install a_port_name
Installs the named port. You can
install multiple ports, at the same

sudo port install nginx -mp4 +substitution
Installs a variant of the nginx port,
deselecting mp4 streaming support,
and enabling text substitution.

sudo port upgrade outdated
Upgrade all outdated ports,
and their dependencies.

sudo port upgrade a_port_name
Upgrade only the named port,
and its dependencies.


sudo port activate a_port_name
Activates a port, in other words,
makes it accessible.
Installed ports are automatically
You can install multiple versions
of a port, but only one, can be

sudo port activate a_port_name @version
Activates an older installed version,
of a port.

sudo port deactivate a_port_name
Deactivates a port, in other words,
makes it inaccessible, unusable.


port select --summary
A same software, might have different
ports, available to be installed, for it. For
example, for python, it has the ports
python31, python37, and other ports.
These form what is called a group,
and for a group, you can set,
which installed port, is to be
the default one.
For example, once you install python310,
you will have two groups created: python,
and python3.
Issuing the python, and the python3 commands,
from the command line, the default port,
set for each of these group, will be
To see the groups, which you have
locally, and the default port, and the
installed ports for each, you can use
the command: port select --summary.
This command only works, if
you have installed some software,
which has a group of ports,
available for it.

port select --show a_group_name
Prints, the default port, for the
named group.

port select --list a_group_name
Prints the available ports, that can be
set as default, for the named

sudo port select --set a_group_name a_port_name
Sets the named port, as the default
option, for the named group.

Service Load/Unload/Reload:

sudo port load a_port_name
Runs the named daemon port,
and makes it start at login.

sudo port unload a_port_name
Stops the named daemon port,
and remove it from starting
at login.

sudo port reload a_port_name
Unloads, and then loads, the
named daemon port.


sudo port uninstall a_port_name
Uninstall an installed port.

sudo port uninstall --follow-dependents a_port_name
Uninstall, all the ports, dependents
of the named port, after that,
uninstall the port.

sudo port uninstall --follow-dependencies a_port_name
Uninstall the named port, and the
ports which were installed as
being required, by this port.

sudo port uninstall inactive
Uninstall all the ports which
are inactive.

sudo port uninstall leaves
Uninstall all the ports which
are leaves.

sudo port clean a_port_name
Removes the build directory,
of the named port.
Useful when installation

sudo port clean --all a_port_name
Removes the downloaded files,
the files created in the process of
building the software, the
temporary archives,
and the log files,
for the named ports

sudo port clean --all installed
Removes the downloaded files,
the files created in the process of
building the software, the
temporary archives,
and the log files,
for the installed ports

sudo port reclaim
Reclaims free space, by uninstalling
inactive ports,
and removing unnecessary downloaded
files, part of installing an application.


port help
Opens the manual page,
of the port command.

port help a_port_command
Opens the manual page,
for this specific


port diagnose
Checks for common issues, in
the user environment, and,
reports back, to the user, with
possible solutions, for the problems.

port lint a_port_command
Lint, in other words, validate a
port file, that you have created,
or modified, for possible errors,
and displays messages accordingly.