How to update all your installed ports on FreeBSD using portupgrade?

Ok, this week there is a simple tool that we are going to talk about. It is called portupgrade. This is a handy software that allows you to manage your ports more efficiently.

I use portupgrade when I want to do things the easy way.

Lets give you a use case. You want to install a new piece of software that requires a library that you already have installed, for example, openssl, however the port fails because the dependency is too old of a version. Well, now you have find the updated port for openssl and uninstall and reinstall it. That might seem easy with one port. But now imaging you have a very new piece of software and you have to update a dozen or more ports. That is going to be time consuming. That is where portupgrade comes in. It does the hard work for you.

Step 1 – Make sure you have ports installed and updated
I already have a post on this. It is pretty short. Check it out here.
How to install ports on FreeBSD?

Make sure that even if you have installed ports that you update ports again so you have the latest.

Step 2 – Install portupgrade

  1. Log on as root.

    $ su
  2. Change to the ports directory and
    cd /usr/ports/ports-mgmt/portupgrade
    make BATCH=yes install

Step 3 – See which ports are outdated
The following command will show you which packages are up to date and which are not. Ok, you don’t really need portupgrade for this, because you can also run pkg_version which is part of base, but portupgrade seems to make a database and do this faster.

# portversion

Now, if you want to only see ports that are not up to date, do this:

# portversion |grep \<

Step 4 – Upgrade a port
Ok, now that portupgrade is installed, it is easy to upgrade a port.

# portupgrade portname

You can just copy and past the portname from the output of the portversion command.

Step 5 – Upgrade all ports
Ok, maybe you want to upgrade all your ports, and I am not saying you should, but maybe you want to. Here is a nice command that will do that for you.

# portupgrade -a -m BATCH=yes

Now that is not exactly complete, because we need to update the ports tree first. So do this:

# portsnap fetch update && portupgrade -a -m BATCH=yes

Now, on my FreeBSD box with an Xorg and KDE4 install, this has been going for over a day and isn’t done yet. I takes a long time to recompile all the Xorg, GTK, KDE4, and other miscellaneous ports.

Have fun with portupgrade.

Copyright ® – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of

No Comments

  1. Hafez says:

    Thank You for this great Tuto !!!

    is there any option to speed up ports compiling procedure, to make it faster ???

    Thx in advance

  2. Chris says:

    Thanks; I will definitely use the forums in the future. The compiler segfault was indeed patched in 4.4 and I can compile the KDE components OK; that could be a useful tidbit on your blog somewhere, since gcc 4.2.1 was installed with FreeBSD 8. Unfortunately, there appears to be a bug in the source (missing member 'metaObject), which leads to two last questions:

    1. Do you consider updating using portupgrade to be leading-edge and not required unless one has a problem?

    2. Do FreeBSD users generally wait to upgrade components as part of an OS release (e.g., 8.0 -> 8.1)? If so, I am just out of sync with the flow of the BSD world...


  3. Chris says:

    Once again, thanks for your clear instructions getting going with FreeBSD. I work a lot with *nix (including Linux) and Windows, but I feel like a complete nOOb just doing basic things in BSD!

    With that as an intro, is there a way to get prebuilt upgrades for FreeBSD? It seems like a real waste having every user building packages vs. having someone "in the know" do it once for everyone.

    I've already upgraded Firefox twice this month using portupgrade, but really, watching the thing build for an hour is a drag, when with some Linux distros you get a 1.8MB rpm and you're up in seconds!

    Worse, I'm trying to update KDE and I keep hitting an internal compiler error during the process; I found some discussions that gnu 4.4 might fix the internal error, but once again I am stumped at how to get 4.4 on my machine: the instructions at aren't clear or don't apply to 4.4, and even trusty portupgrade doesn't seem to offer a path to 4.4!

    I would appreciate any suggestions.

    • rhyous says:


      Some packages will get updated here. I would expect Firefox to be updated here but maybe it isn't:
      32 bit:
      64 bit:

      Looks like the last Firefox package was 9/29/2009 so maybe it isn't the latest. Maybe if you ask on the FreeBSD forums, someone will know where updated Firefox packages are for FreeBSD so you don't have to compile them yourself.

      As for the KDE error: Make sure to post the error on as you get a lot of good minds helping you out. Just make sure when in a forum you were your thick skin. Sometimes quick answers feel like "curt" answers, but don't take offense, people are just busy and want to help and if they sound frustrated, they are probably not frustrated at you directly.

    • rhyous says:

      I found a package here:

      You can probably get away with applying the Firefox package from 8-stable, even if you are on 8-release.

  4. rhyous says:

    Here is a command that was recommend by Ujwa Ifa on Facebook:

    portsnap fetch update && portupgrade -apPDR --batch

Leave a Reply

How to post code in comments?