[How To] Install, uninstall and manage programs in FreeBSD

Table of Contents

FreeBSD is an open-source operating system that provides users with a simple and reliable platform for a variety of tasks. In this article we will look at how to install, uninstall, and manage programs in FreeBSD. We will discuss the three different methods of installing 3rd party applications, which are the Ports collection, Binary packages, and Compiling from source code. We will also discuss how to find applications and programs in FreeBSD and how to uninstall applications and programs.

Find Applications and Programs in FreeBSD

1. Find Installed Applications (Using Package System)

To find applications and programs that are already installed on FreeBSD, you can use the “pkg_info” command. This command will output a list of all of the installed packages. You can pipe the output through “less” or search for specific packages using “grep”.

root@freebsd:~ pkg_info
gettext-0.16.1_3    GNU gettext package
libiconv-1.11_1     A character set conversion library
mysql-client-5.1.22 Multithreaded SQL database (client)
nagios-statd-3.12   Daemon/client to check remote host information for Nagios
net-snmp-5.3.1_7    An extendable SNMP implementation
perl-5.8.8_1        Practical Extraction and Report Language

root@freebsd:~ pkg_info | less
root@freebsd:~ pkg_info | grep mysql
mysql-client-5.1.22 Multithreaded SQL database (client)

2. Find Applications to Install (Using Ports)

If you want to find applications and programs to install, you can use the “whereis” command, the “echo” command, or the “make search” command. You can use these commands to find the port of the application or program and then use the “pkg_info” command to get detailed package information.

root@freebsd:~ whereis app_name
app_name: /usr/ports/sysutils/app_name

root@freebsd:~ echo /usr/ports/*/*app_name*
usr/ports/sysutils/app_name

root@freebsd:~ cd /usr/ports
root@freebsd:~ make search name=app_name
Port:   app_name-3.64.5
Path:   /usr/ports/sysutils/app_name
Info:   Lists information about open files (similar to fstat(1))
Maint:  [email protected]
Index:  sysutils
B-deps: 
R-deps:

Detailed package information can be found by the following command:

root@freebsd:~ whereis app_name

How to Install Applications and Programs in FreeBSD

1. Installing with pkg_add Command (Binary Method)

You can use the “pkg_add” command to install packages from binary files (.tgz files). To install a package named app_name-3.64.5.tgz, you can use the following command:

root@freebsd:~ pkg_add app_name-3.64.5.tgz

You can also use the “pkg_add” command to install packages from the internet using the remote fetching feature. To do this, you need to add the “-r” flag and the “-v” flag for verbose mode.

root@freebsd:~ pkg_add -r -v app_name

2. Installing by Ports (Source Method)

The source method of installation requires that you use the Ports collection. First, you need to upgrade all of the ports installed under /usr/ports. If you are doing this for the first time, you can use the following commands:

root@freebsd:~ portsnap fetch
root@freebsd:~ portsnap extract

If you have already used the Ports collection before, you can use the “portsnap update” command instead.

Once you have updated the ports, you can use the “whereis” command to find the port of the application or program that you want to install. Then, you can change to the application directory, make the application, and install it using the “make install” command. You can also use the “make clean” command to clean the application after you have installed it.

root@freebsd:~ whereis app_name
root@freebsd:~ cd /usr/ports/sysutils/app_name
root@freebsd:~ make
root@freebsd:~ make install
root@freebsd:~ make clean

You can also use the “make install clean” command to install and clean the application in one step.

root@freebsd:~ whereis app_name
root@freebsd:~ cd /usr/ports/sysutils/app_name
root@freebsd:~ make install clean

How to Uninstall Applications and Programs in FreeBSD

Uninstalling with pkg_delete Command

You can use the “pkg_delete” command to uninstall packages. To uninstall a package named app_name, you can use the following command:

pkg_delete app_name

Uninstalling Installed Ports

If you have installed a port from the Ports collection, you can use the “make deinstall” command to uninstall it. First, you need to change to the port directory, and then you can use the “make deinstall” command.

root@freebsd:~ cd /usr/ports/sysutils/app_name
root@freebsd:~ make deinstall

Conclusion

In this article we have looked at how to install, uninstall, and manage programs in FreeBSD. We discussed the three different methods of installing 3rd party applications, which are the Ports collection, Binary packages, and Compiling from source code. We also discussed how to find applications and programs in FreeBSD and how to uninstall applications and programs. By following the instructions in this article, you should be able to easily install, uninstall, and manage programs in FreeBSD.

3 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.