About
The package management tool used in Alpine Linux is apk. apk is a fast, lightweight, and efficient package management tool that has the following features:
- Native support for cross-compilation and cross-platform installation.
- Automatic handling of dependencies when installing and uninstalling packages.
- Support for multiple repositories, including official repositories, community repositories, and personal repositories.
- Simple command-line interface that allows users to perform various operations such as search, install, upgrade, and uninstall.
- Support for virtual packages that enables users to install a set of related packages by installing a single virtual package.
How to Use
Here are some basic commands for using the apk
package manager in Alpine Linux:
-Update the package index:
|
|
-Search for a package:
|
|
-Install a package:
|
|
-Remove a package:
|
|
-View information about a package:
|
|
-List all installed packages:
|
|
-Upgrade all installed packages:
|
|
-Upgrade a specific package:
|
|
-List the contents of a package:
|
|
-Show the dependencies of a package:
|
|
Enable community repositories
Edit the file /etc/apk/repositories
and uncomment a line that points to the “community” directory.
Using Examples
To install neovim
in Alpine Linux using the apk
|
|
(1/11) Installing libintl (0.21.1-r1) (2/11) Installing libgcc (12.2.1_git20220924-r4) (3/11) Installing luajit (2.1_p20210510-r3) (4/11) Installing libuv (1.44.2-r0) (5/11) Installing libluv (1.44.2.1-r0) (6/11) Installing msgpack-c (4.0.0-r0) (7/11) Installing unibilium (2.1.1-r0) (8/11) Installing libtermkey (0.22-r0) (9/11) Installing tree-sitter (0.20.7-r0) (10/11) Installing libvterm (0.3-r0) (11/11) Installing neovim (0.8.1-r0) Executing busybox-1.35.0-r29.trigger OK: 138 MiB in 71 packages
To install multiple applications with apk in Alpine Linux
|
|
(1/7) Installing readline (8.2.0-r0) (2/7) Installing bash (5.2.15-r0) Executing bash-5.2.15-r0.post-install (3/7) Installing pkgconf (1.9.4-r0) (4/7) Installing bash-completion (2.11-r4) (5/7) Installing openrc-bash-completion (0.45.2-r7) (6/7) Installing bash-doc (5.2.15-r0) (7/7) Installing kmod-bash-completion (30-r1) Executing busybox-1.35.0-r29.trigger OK: 145 MiB in 78 packages
The “apk search” command in Alpine Linux
|
|
This will display a list of packages related to Docker.
To uninstall or remove an application in Alpine Linux using apk
List all installed packages and find out the application as you want to remove.
|
|
Use the “apk del” command followed by the name of the package to remove it
|
|
(1/11) Purging neovim (0.8.1-r0) (2/11) Purging libintl (0.21.1-r1) (3/11) Purging luajit (2.1_p20210510-r3) (4/11) Purging libgcc (12.2.1_git20220924-r4) (5/11) Purging libluv (1.44.2.1-r0) (6/11) Purging libuv (1.44.2-r0) (7/11) Purging msgpack-c (4.0.0-r0) (8/11) Purging libtermkey (0.22-r0) (9/11) Purging unibilium (2.1.1-r0) (10/11) Purging tree-sitter (0.20.7-r0) (11/11) Purging libvterm (0.3-r0) Executing busybox-1.35.0-r29.trigger OK: 123 MiB in 67 packages
Overall
apk
is a fast, lightweight, and efficient package management tool that makes it easy for users to manage and maintain software packages in Alpine Linux.