- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
20 Useful PKG Command Examples to Manage Packages in FreeBSD
Introduction
FreeBSD is a free and open-source Unix-like operating system based on Berkeley Software Distribution (BSD) system. It is widely used by developers, system administrators, and users who are looking for a reliable and secure operating system. One of main features of FreeBSD is its package management system, which allows users to easily install, update, and remove software packages. In this article, we will discuss 20 useful PKG command examples to manage packages in FreeBSD.
Installing Packages
To install a package in FreeBSD, you can use "pkg install" command followed by package name. For example, to install Apache web server, you can use following command −
pkg install apache24
Updating Packages
To update all installed packages in FreeBSD, you can use "pkg upgrade" command. This will update all installed packages to their latest versions. For example, to update all installed packages, you can use following command −
pkg upgrade
Searching for Packages
To search for a package in FreeBSD, you can use "pkg search" command followed by package name. For example, to search for Python programming language, you can use following command −
pkg search python
Listing Installed Packages
To list all installed packages in FreeBSD, you can use "pkg info" command. This will display a list of all installed packages along with their version numbers. For example, to list all installed packages, you can use following command −
pkg info
Removing Packages
To remove a package in FreeBSD, you can use "pkg remove" command followed by package name. For example, to remove Apache web server, you can use following command −
pkg remove apache24
Displaying Package Information
To display detailed information about a package in FreeBSD, you can use "pkg info" command followed by package name. This will display information such as package name, version number, description, and dependencies. For example, to display detailed information about Python programming language, you can use following command −
pkg info python
Displaying Package Dependencies
To display dependencies of a package in FreeBSD, you can use "pkg info" command followed by package name and "-d" option. For example, to display dependencies of Python programming language, you can use following command −
pkg info -d python
Displaying Package Size
To display size of a package in FreeBSD, you can use "pkg info" command followed by package name and "-s" option. For example, to display size of Python programming language package, you can use following command −
pkg info -s python
Displaying Package Origin
To display origin of a package in FreeBSD, you can use "pkg info" command followed by package name and "-q" option. For example, to display origin of Python programming language package, you can use following command −
pkg info -q python
Displaying Package License
To display license of a package in FreeBSD, you can use "pkg info" command followed by package name and "-l" option. For example, to display license of Python programming language package, you can use following command −
pkg info -l python
Listing Available Packages
To list all available packages in FreeBSD, you can use "pkg search" command followed by "-a" option. For example, to list all available packages, you can use following command −
pkg search -a
Listing Installed Packages by Size
To list all installed packages in FreeBSD sorted by size, you can use "pkg info" command followed by "--size" option. For example, to list all installed packages sorted by size, you can use following command −
pkg info --size
Upgrading a Specific Package
To upgrade a specific package in FreeBSD, you can use "pkg upgrade" command followed by package name. For example, to upgrade Python programming language package to its latest version, you can use following command −
pkg upgrade python
Listing Outdated Packages
To list all installed packages in FreeBSD that are outdated, you can use "pkg version" command followed by "-vL=" option. For example, to list all outdated packages, you can use following command −
pkg version -vL=
Downgrading a Package
To downgrade a package in FreeBSD, you can use "pkg install" command followed by package name and version number. For example, to downgrade Python programming language package to version 3.7.7, you can use following command −
pkg install python37-3.7.7
Reinstalling a Package
To reinstall a package in FreeBSD, you can use "pkg install" command followed by package name and "-f" option. For example, to reinstall Python programming language package, you can use following command −
pkg install -f python
Cleaning Package Cache
To clean package cache in FreeBSD, you can use "pkg clean" command. This will remove all old and unused packages from cache. For example, to clean package cache, you can use following command −
pkg clean
Listing Installed Packages by Category
To list all installed packages in FreeBSD sorted by category, you can use "pkg query" command followed by "%n-%v %C" option. For example, to list all installed packages sorted by category, you can use following command −
pkg query '%n-%v %C' | sort
Removing Orphaned Packages
To remove orphaned packages in FreeBSD, you can use "pkg autoremove" command. This will remove all packages that are no longer required by any other package. For example, to remove orphaned packages, you can use following command −
pkg autoremove
Listing Packages by Repository
To list all installed packages in FreeBSD sorted by repository, you can use "pkg query" command followed by "%n-%v %R" option. For example, to list all installed packages sorted by repository, you can use following command −
pkg query '%n-%v %R' | sort
Conclusion
In this article, we discussed 20 useful PKG command examples to manage packages in FreeBSD. These commands will help you to easily install, update, and remove packages in FreeBSD. Whether you are a developer, system administrator, or user, these commands will help you to keep your system up-to-date and secure. By mastering these commands, you can become more productive and efficient in managing packages in FreeBSD.
To Continue Learning Please Login
Login with Google