← 返回命令列表

Linux command

pkg 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Install a package

pkg install [package]

Search for packages

pkg search [query]

Update the package repository catalog

pkg update

Upgrade all installed packages

pkg upgrade

Remove a package

pkg delete [package]

List all installed packages

pkg info

Show details for a specific installed package

pkg info [package]

Audit installed packages for security vulnerabilities

pkg audit -F

Lock a package to prevent upgrades

pkg lock [package]

说明

pkg is the official binary package manager for FreeBSD. It handles installation, removal, upgrading, and searching of pre-built packages from FreeBSD repositories, replacing the older pkg_add tools. The tool resolves dependencies automatically, manages a local package database, and supports multiple repositories. It can also lock packages to prevent upgrades, audit installed packages for security vulnerabilities, and create packages from installed ports.

参数

install _PACKAGE_
Install a package and its dependencies.
search _QUERY_
Search for packages in remote repositories.
update
Update the remote repository catalog.
upgrade
Upgrade installed packages to latest available versions.
delete _PACKAGE_
Remove a package.
info _PACKAGE_
Show information about installed packages, or details for a specific package.
audit -F
Audit installed packages for known security vulnerabilities. -F fetches the latest database.
lock _PACKAGE_
Lock a package to prevent modification or deletion.
unlock _PACKAGE_
Unlock a previously locked package.
autoremove
Remove unneeded packages that were installed as dependencies.
query _FORMAT_ _PACKAGE_
Query information about installed packages using a format string.
clean
Clean the local cache of fetched packages.

FAQ

What is the pkg command used for?

pkg is the official binary package manager for FreeBSD. It handles installation, removal, upgrading, and searching of pre-built packages from FreeBSD repositories, replacing the older pkg_add tools. The tool resolves dependencies automatically, manages a local package database, and supports multiple repositories. It can also lock packages to prevent upgrades, audit installed packages for security vulnerabilities, and create packages from installed ports.

How do I run a basic pkg example?

Run `pkg install [package]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does install _PACKAGE_ do in pkg?

Install a package and its dependencies.