What are the first commands I run after installing FreeBSD? Or How to patch FreeBSD? Or How to install ports on FreeBSD?

Ok, so you just installed FreeBSD, an maybe you are not familiar with it, so you think, “What now?”.

Well, think about what you do when you install any platform. You do three things:

  1. Apply patches/updates.
  2. Install software
  3. Post-installation configuration of system and software

For example, when you install a new windows operating system, it is common to go to Windows Update and update your server. Then you install software such as microsoft office, etc… The same for servers. You update the server, then maybe you add your server software. Then you configure it some more.

The order may vary for every install or you may even do this three step process multiple times.

Just because you are on FreeBSD does not mean the same three step process doesn’t apply. This three item process is operating system independent. It is the first thing I do on FreeBSD as well.

So here are the first commands that I run after logging into a new FreeBSD install.

$su

Password:

ServerName#
ServerName#
ServerName#
ServerName#
freebsd-update fetch
freebsd-update install
portsnap fetch
portsnap extract

Same commands in a nice script/code box you can use to copy and paste.

freebsd-update fetch
freebsd-update install
portsnap fetch
portsnap extract

Let me explain what each command does:

  1. freebsd-update fetch – This download patches that have been released for the version of FreeBSD you have installed. It does not install the patches.
  2. freebsd-update install – This command installs the patches that were previously download.
  3. portsnap fetch – This download a compressed version of the ports tree. Ports means applications that have been ported or developed to compile and run on FreeBSD. So the ports tree is basically a database of available software that can be install on FreeBSD.
  4. portsnap extract – This extracts the compressed version of the ports tree.

So with these four commands you have your system updated/patched. You also have all the software that is available ready to be installed.

Update 1:

I am not sure why i didn’t know this before, but you can combine each pair of commands into one command:

ServerName#
ServerName#
freebsd-update fetch install
portsnap fetch extract
freebsd-update fetch install
portsnap fetch extract

Stay tuned for my article on searching the ports tree.

Update 2:

As you can read in the comments, it is good to know that you only have to “extract” the ports tree once and for every subsequent update to the ports tree, you should only run it with the “update” command as shown.

portsnap fetch update

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Pingback: Installing VMWare Tools on FreeBSD 9 | Rhyous

  2. Pingback: FreeBSD - Building and installing a custom kernel | Rhyous

  3. Pingback: Making a package from a port on FreeBSD | Rhyous

  4. Pingback: Installing and Using Postgresql on FreeBSD | Rhyous

  5. Pingback: How to install MySQL on FreeBSD | Rhyous

  6. Pingback: How to install PHP5 and PHP5 Extensions on FreeBSD? | Rhyous

  7. Pingback: Installing an Apache + SSL on FreeBSD using the ports tree | Rhyous

  8. have a big problem using the comand´

    -portsnap fetch extrac

    my system got stock at 52% of the download and did not do anything after that
    have the next words on screen

    66871b76452e32d3e5773efae757cfdfa1b7e2b546e5c3 52% of 64 MB 4617 Bps 01h56m

    could help me with this…?

  9. Pingback: Rhyous » Blog Archive » How to install Bugzilla on a FreeBSD 7.2 with Apache + SSL and MySQL?

  10. Pingback: Rhyous » Blog Archive » Getting Java to work in Firefox 3.6 in PC-BSD 8.2

  11. Pingback: Rhyous » Blog Archive » How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

  12. Pingback: Making a package from a port on FreeBSD « Rhyous's 127.0.0.1 or ::1

  13. First off – THANK YOU – thank you so much for putting this guide together. very helpful. I am installing freebsd on esx using your guide and I’m just happy the networking and updates are working.

    I found a few items that you may want to correct or change… You say the following:

    IR – when I copy and paste I get numbers in front of each line like so…
    Same commands in a nice script/code box you can use to copy and paste.
    1
    freebsd-update fetch
    2
    freebsd-update install
    3
    portsnap fetch
    4
    portsnap extract

    IR – I think this is a typo. You don’t mean that these two commands do the same thing, right? The commands seem pretty self-explanatory to me but your explanation leaves me wondering…

    Let me explain what each command does:
    freebsd-update fetch – This download patches that have been released for the version of FreeBSD you have installed. It does not install the patches.
    freebsd-update install – This download patches that have been released for the version of FreeBSD you have installed. It does not install the patches.

    I guess a one page how to guide on installing freebsd vm on esx would be pretty long, ehh?

    I b e n

    • WordPress allows you to click a copy button or a display in editor button on the left. If you high-light and copy, you are correct, you will get numbers.

      Yes, I must have copied and pasted and not updated that line, because they of course do not do the same thing. I should update this.

      I haven’t used ESX but I do most my testing in VMWare Workstation. The VMWare tools are mostly for X installed. Click on FreeBSD Friday on the right and you should see a few articles on installing Xorg and KDE and installing VMWare tools.

  14. Pingback: How to update all your installed ports on FreeBSD using portupgrade? « Rhyous's 127.0.0.1 or ::1

  15. on new installations you need to run portsnap fetch extract … there after the portsnap fetch update command will be good

  16. well this is the best I have seen … you are just a STAR

    portsnap fetch extract … is not so good … concider this portsnap fetch update …

    `portsnap fetch update` — this is much faster than `portsnap fetch extract` because it avoids extracting directories which haven’t changed.

  17. Pingback: How to install subversion 1.6.6 on FreeBSD 7.2 « Rhyous's 127.0.0.1 or ::1