FreeBSD Obtain and Install Ports File in /usr/ports

Q. I’ve installed FreeBSD server without ports. When installing my FreeBSD system, sysinstall asked my, if I would like to install the Ports Collection? I chose not to install it. Now, how do I obtain and install the FreeBSD ports collection in /usr/ports?

A. The FreeBSD Ports collection is a package management system which provides an easy and consistent way of installing software packages on the FreeBSD operating system.

Before you can install ports, you must first obtain the Ports Collection and placed in /usr/ports directory.

Obtaining the Ports Collection

Login as root and install portsnap package, if you are using FreeBSD 6.0 or older version:
# pkg_add -r portsnap

Obtain ports

Type the following command:
# mkdir /usr/ports
# portsnap fetch
# portsnap extract

Now, the ports collection installed in /usr/ports. You can install and update system using portupgrade and portsnap itself

You can also use sysinstall tool to install the ports collection :
# sysinstall
Select Configure > Distributions > Ports > Ok

Fig.01: Install Freebsd Ports Collection Using sysinstall

Fig.01: Install Freebsd Ports Collection Using sysinstall

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • diay Nov 30, 2008 @ 10:32

    Thanks for sharing this.

  • orkeed Nov 26, 2010 @ 8:06

    i still cannot install ports,,pls help me =(*

  • MC Nov 26, 2011 @ 7:50

    any ideas on how to install stuff on 9 now that the installer is no longer invalid

    I have almost spent a week now in lang / devel trying to install what is needed to create the installers for the ports i am wanting to install .. its proving very tiring

    now wishing i stayed with 8.2

    is it such a hard thing to have an option to install every compiler avail

    instead of dependancies being installed it jsut keeps stoping at such and such is missing and off i go again doing make build-depends-list to find where to find the next part to be installed :S
    ps thanks for all your posts they have helped me a lot this yr getting freebsd box going


    ZFS Raidz
    KDE Desktop
    Multimedia server box

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum