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

19 Comments

  1. [...] Instructions for updating FreeBSD and installing ports are found here: Update FreeBSD and Install ports [...]

  2. [...] You may also want to install FreeBSD ports: How to install FreeBSD ports [...]

  3. [...] Download the latest ports tree. See this article: How to install ports on FreeBSD? [...]

  4. [...] What are the first commands I run after installing FreeBSD [...]

  5. [...] Second update FreeBSD and install the ports tree. Instructions for this are in this article. What are the first commands I run after installing FreeBSD? [...]

  6. [...] Second update FreeBSD and install the ports tree. Instructions for this are in this article. What are the first commands I run after installing FreeBSD? [...]

  7. [...] Second update FreeBSD and install the ports tree. Instructions for this are in this article. What are the first commands I run after installing FreeBSD? [...]

  8. Lizeth says:

    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. [...] Update FreeBSD and download the ports tree. What are the first commands I run after installing FreeBSD [...]

  10. [...] Install ports on your system as follows: How to install ports on FreeBSD? [...]

  11. [...] 3 – Patch your new system Update and patch your system. I already have steps to do this here: What are the first commands I run after installing FreeBSD Important: While the ports tree is already installed, don’t skip this step. Updating the [...]

  12. [...] Download the latest ports tree. See this article: How to install ports on FreeBSD? [...]

  13. Iben Rodriguez says:

    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

    • rhyous says:

      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. [...] 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? [...]

  15. Wayne says:

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

  16. Wayne says:

    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. [...] Update FreeBSD and download the ports tree. What are the first commands I run after installing FreeBSD [...]

Leave a Reply

How to post code in comments?