How To Install Or Remove Packages Using pkg In FreeBSD?

How To Install Or Remove Packages Using pkg In FreeBSD?

   

This post was last updated on August 1st, 2020 at 12:10 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.

Ahead in this article, we will discuss installing and removing a software package using pkg in FreeBSD.

How to install packages using pkg

The pkg is used for registering, adding, removing, and upgrading packages. It installs a package from prebuilt binaries. It is a package management tool similar to the apt or yum package managers used in Linux. Pkg offers the easiest way to install the software packages in FreeBSD. Please note that the pkg is not available for the versions prior to FreeBSD 10.

Now let us see how we can use it to install a package –

First, update the local pkg database by executing –

pkg update

Before installing a package you could use the following command to find a package available for installation –

pkg search package_name

For example to install the nano text editor you could use the following to find the exact package name –

pkg search nano

As you can see in the image above nano-4.9.2 is the package that we want to install in our system. This command can also list the different branches of a package such full, lite, devel, etc.

The syntax of installing a package using pkg is-

pkg install package_name

To install nano text editor use the following command –

pkg install nano-4.9.2

Press y and then enter if ask for confirmation.

Once you confirm the action it will start fetching package from the remote repository and then install it. When installation gets done you can use the nano editor by executing –

nano

How to remove packages from FreeBSD using pkg

If a package no longer needed then you can remove it by using the following command in your terminal –

pkg delete package_name

To remove nano from your system use the following command –

pkg delete nano

Press y and then enter if ask for confirmation and this will delete the package from your system –

When a package is removed it could leave some dependencies which are no longer required. These dependencies can be detected and removed using the following command –

pkg autoremove

To see more options that can be used with the pkg command use –

man pkg

Now you can also see how to install or remove software packages using the ports collection. If you want to say something on this topic then write us in the comments below.

Previous How To Install Or Remove Packages Using Ports Collection In FreeBSD?
Next 20.04 no scanning

About author

You might also like

FreeBSD Topics 0 Comments

How To Install And Configure Xfce In FreeBSD?

This post was last updated on August 1st, 2020 at 10:30 amXfce is a free and opensource desktop environment that aims to be lightweight, fast, and low on system resources

Package Manager 0 Comments

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

This post was last updated on August 1st, 2020 at 12:11 pmFreeBSD provides various tools as a part of its base system. In FreeBSD, there are two ways to install

FreeBSD Topics 0 Comments

Understanding Ports Skeleton In FreeBSD

This post was last updated on August 1st, 2020 at 12:09 pmIn FreeBSD, there are two ways to install software packages: pkg and ports collection. The pkg is used to

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply