October 20, 2017

How to Search and Install FreeBSD Ports

FreeBSD Logo

The FreeBSD ports and packages collection is a simple way to install applications. In this tutorial we will show you to search and install new packages using this collection. There are thousands of ports available. Each application within the ports tree holds any patches to make the code compile and run on FreeBSD.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Install the ports collection

Before we can start we have to set up the ports collection directory /usr/ports with the portsnap command.

portsnap fetch

Type the following command to extract the snapshot into the /usr/ports directory.

portsnap extract

If you have already a populated /usr/ports ports directory you can update the ports with this command:

portsnap update

Search for ports

You can search for ports with the whereis command. This assumes that you know the exact name of the port.

whereis nginx

An other way is the built-in search of the ports collection. Navigate to the ports directory /usr/ports. Then you can use make search name=application to search for applications.

cd /usr/ports
make search name=nginx

If you do not know the exact name and want to search for a particular subject within the port names, comments, descriptions and dependencies of the ports you can use make search key=subject to seach for that subject.

cd /usr/ports
make search key=nginx

Install ports

Finally, you can install a port by navigating to the port directory and enter make install clean; rehash to compile and install the application.

cd /usr/ports/www/nginx
make install clean; rehash

Comments

  1. This got me started with new software after installing FreeBSD for the first time. Thanks!

Speak Your Mind