How To Install Or Remove Packages Using Ports Collection In FreeBSD?

How To Install Or Remove Packages Using Ports Collection In FreeBSD?

   

This post was last updated on August 1st, 2020 at 12:11 pm

FreeBSD provides various tools as a part of its base system. In FreeBSD, there are two ways to install software packages from official repositories or third-party sources i.e. pkg and ports. The pkg is used to install from prebuilt binaries and port is used to install from sources.

I already discussed how to install or remove packages using pkg. This article is on installing and removing a software package using ports collection in FreeBSD.

The ports collection

Ports collection in FreeBSD offers a simple way to compile and install third-party applications. It is also used to build packages that are to be installed using pkg. The packages compiled and installed using port collection is known as ports. Port collection can be installed and updated using portsnap. By default, it gets stored as the subdirectory of /usr/ports.

It does not come preinstalled so first you need to install it in your system. Use the following commands to download the ports collection in compressed form –

portsnap fetch

Now extract the ports collection files using-

portsnap extract

And finally, update it –

portsnap update

How to install a package using the ports collection

To install a package using the ports collection, first, you need to change the directory to the port that is to be installed. For example to install nano text editor in your system, Use the given sequence of commands in your terminal –

First, check the subdirectories under the ports directory –

ls /usr/ports

The text editor nano will come under editors, now move into this directory by using the given command –

cd /usr/ports/editors

Now if you run the following command and scroll down you will see a directory with the name nano –

ls | more

Move into the nano directory –

cd nano

Now use the following command to install nano text editor –

make install

This will start compiling and it can prompt you for compile-time options. You can select or deselect them as per your need. Now you can check the installed application by running it –

nano

Clean the temporary files

During the installation process, a working directory is created which contains all the temporary files used during the compilation. You can remove this directory and can save some space on your disk. Also, it minimizes the problems later when upgrading the application to a newer version.

Now use the following command to remove it –

make clean

How to remove the installed ports

You can remove the installed ports using the deinstall command, first, you need to move to the ports directory. To remove nano from your system use-

cd /usr/ports/editors/nano

And then run –

make deinstall

Alternatively, you can use the pkg command to remove an installed package –

pkg delete nano

Ok, that’s all for now. If you have something to say on this topic then write to us in the comments below.

Previous [ubuntu] Stop update checking
Next How To Install Or Remove Packages Using pkg In FreeBSD?

About author

You might also like

FreeBSD Topics 0 Comments

[FreeBSD] How to Install FreeBSD OS, Step by step guide using a virtual machine

This post was last updated on July 21st, 2020 at 01:15 pmTake a deep breathe and be sure that you have at least an hour of time. We have to

FreeBSD Topics 0 Comments

How To Install And Use sudo In FreeBSD?

This post was last updated on August 1st, 2020 at 10:28 amThe sudo (superuser do) is a program for Unix like operating systems. It allows a user to run a

FreeBSD Topics 0 Comments

How To Remove A User From A Group In FreeBSD?

This post was last updated on August 1st, 2020 at 12:12 pmI already discussed how to add a user to a group in FreeBSD. This article is about removing a

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply