MacPorts — most common tasks:

Update the 'port' command itself:
> sudo port selfupdate

To see what’s out of date, and to update all at once:
> port outdated
> sudo port upgrade outdated

To see what’s installed:
> port installed

To update an individual port:
> sudo port upgrade portname

If an install fails, clean up so you can start over:
> sudo port clean portname

Get rid of a port:
> sudo port uninstall portname

See what ports are no longer being used, including older
versions of upgraded ports, and get rid of them:
> port installed inactive
> sudo port uninstall inactive

To select a particular version of a port if more than one 
is installed:
> sudo port activate portname @versionid

For groups with multiple options, e.g. python, gcc:

To see which ports have multiple options:
> port select —-summary

To list available versions:
> port select --list groupname

To see what version is currently selected:
> port select --show groupname

To select a particular version:
> sudo port select --set groupname versionname

Usage notes for the macports 'port' utility:

For all 'sudo' commands below, you must be 'su'd to your admin account.
When prompted for a password it wants your admin account password.

main website: http://www.macports.org/
help and usage examples: http://guide.macports.org/

Is MacPorts installed yet?
> which port

It is usually installed in /opt/local/bin, which must be in your search path.
In most cases it should be before /usr/bin to get the ports version of
utilities instead of the version that comes with the base OS X distribution.

If not installed, see here for how to get the pkg installer for your system:
https://guide.macports.org/index.html#installing.macports

Debugging problems:
The port command takes the '-d' flag to print out more debug info.

If you need to specify a particular version of a port, add it after the name:
> port ...  portname @1.2.3_4

More infrequently used commands:

To update individual ports and remove previous versions in one shot:
> sudo port -u upgrade portname

To reclaim disk space:
> sudo port reclaim

Looking for a port that you might want to install (keyword matches words in
both the port name as well as description):
> port search keyword

Print info about a port, installed or not:
> port info portname

See what version of the port command you have:
> port version

See what other ports are needed to install this port:
> port deps portname

To uninstall a port without checking dependencies:
> sudo port -f uninstall portname

See if there are options that you can select for this port:
> port variants portname

To specify (or restrict) the variations:
> sudo port install portname +variant
> sudo port install portname -defaultvariant