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 October 15th, 2020 at 01:00 am

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

How To 0 Comments

How To Add A User To A Group In FreeBSD?

This post was last updated on August 1st, 2020 at 12:12 pmIn FreeBSD, a group is a list of users. It makes it easier to define the permissions such as

FreeBSD 0 Comments

[FreeBSD] How to install VIM in FreeBSD

This post was last updated on November 3rd, 2020 at 05:36 pm[wr_row][wr_column]By default FreeBSD comes in a command line user interface. As an Administrator or a Device Drive developer or

How To 0 Comments

How To Upgrade Packages In FreeBSD?

This post was last updated on August 1st, 2020 at 12:06 pmFreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution. It is used to power

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply