<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Prabuanand</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Prabuanand"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Prabuanand"/>
	<updated>2026-04-11T04:38:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=32264</id>
		<title>OpenRC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=32264"/>
		<updated>2026-04-01T19:03:10Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: moved note about doas along with service management commands&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Alpine Linux uses [https://github.com/OpenRC/ OpenRC] for its [https://en.wikipedia.org/wiki/Init init] system. The init system manages the services, including the boot and shutdown of your system. [[#User services|OpenRC User services]] can be used for managing services for users. &lt;br /&gt;
&lt;br /&gt;
To learn the basics of OpenRC quickly, refer to the [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html working with OpenRC] guide from the Alpine Linux documentation project. &lt;br /&gt;
&lt;br /&gt;
== Quickstart  ==&lt;br /&gt;
&lt;br /&gt;
{|align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;50%&amp;quot; |Action&lt;br /&gt;
|             |Command&lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Managing a service - start,stop and restart&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Start {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
|-&lt;br /&gt;
| Stop {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; stop}} &lt;br /&gt;
|-&lt;br /&gt;
| Restart {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; restart}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Adding and removing service from runlevels&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Add {{ic|ServiceName}} to {{ic|runlevel}} || {{Cmd|# rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| Remove {{ic|ServiceName}} from {{ic|runlevel}} || {{Cmd|# rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check services in a runlevel and their status&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To check status of {{ic|ServiceName}} || {{Cmd|$ rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; status}} &lt;br /&gt;
|-&lt;br /&gt;
| To view services configured at {{ic|runlevel}}  || {{Cmd|$ rc-update show &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| To view currently active runlevels and state of services  || {{Cmd|$ rc-status}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check and manage runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view available runlevels || {{Cmd|$ rc-status -l}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different {{ic|runlevel}} || {{Cmd|# openrc &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Stacked runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{Cmd|# rc-update add -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| To remove {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{Cmd|# rc-update del -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}}&lt;br /&gt;
| &lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; |&#039;&#039;&#039;User Services&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view currently active user runlevels and state of user services ({{ic|-U}}) || {{Cmd|$ rc-status -U}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different user {{ic|runlevel}} || {{Cmd|$ openrc -U &amp;lt;/var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| Add user {{ic|ServiceName}} to user {{ic|runlevel}} || {{Cmd|$ rc-update -U add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}}&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}}as a stacked user {{ic|runlevel}} || {{Cmd|$ rc-update -U add -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Runlevels ==&lt;br /&gt;
&lt;br /&gt;
The [[BusyBox#init|BusyBox init]] executes [[OpenRC]] runlevel scripts according to entries in {{Path|/etc/inittab}}. A &#039;&#039;runlevel&#039;&#039; is basically a collection of services that needs to be started when certain conditions are met. Instead of using runlevel numbers, such as is used traditionally with &#039;&#039;SysV&#039;&#039; init, these are named, and users can create their own, if needed. The default startup uses the &#039;&#039;&#039;sysinit&#039;&#039;&#039;, &#039;&#039;&#039;boot&#039;&#039;&#039;, and &#039;&#039;&#039;default&#039;&#039;&#039; runlevels, in that order. Shutdown uses the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel.&lt;br /&gt;
&lt;br /&gt;
The available runlevels are:&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; - Used if no runlevel is specified. (This is generally the runlevel you want to add services to.)&lt;br /&gt;
* &#039;&#039;&#039;hotplugged&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The special runlevels are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;sysinit&#039;&#039;&#039; - Brings up system specific stuff such as &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; and optionally &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt; for Linux based systems. It also mounts &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; as a ramdisk using tmpfs where available unless &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is mounted rw at boot. &amp;lt;code&amp;gt;&#039;&#039;&#039;rc&#039;&#039;&#039;&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; to hold state information about the services it runs. &#039;&#039;&#039;sysinit&#039;&#039;&#039; always runs when the host first starts and should not be run again.&lt;br /&gt;
* &#039;&#039;&#039;boot&#039;&#039;&#039; - Generally, the only services that one should add to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel are those which deal with the mounting of filesystems, setting the initial state of attached peripherals, and logging. Hotplugged services are added to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel by the system. All services in the &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevels are automatically included in all other runlevels except for those listed here.&lt;br /&gt;
* &#039;&#039;&#039;single&#039;&#039;&#039; - Stops all services except for those in the &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevel.&lt;br /&gt;
* &#039;&#039;&#039;reboot&#039;&#039;&#039; - Changes to the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel, and then reboots the host.&lt;br /&gt;
* &#039;&#039;&#039;shutdown&#039;&#039;&#039; - Changes to the shutdown &#039;&#039;&#039;runlevel&#039;&#039;&#039;, and then halts the host.&lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevels ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Stacked&#039;&#039; runlevels allows for the &amp;quot;inheritance&amp;quot; of services. A few use cases are given below:-&lt;br /&gt;
* [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html#_runlevel_stacking Running an office runlevel with VPN service]&lt;br /&gt;
* [[#Preventing slow services from delaying system startup|Preventing slow services from delaying system startup]]&lt;br /&gt;
For more detailed information, refer [https://wiki.gentoo.org/wiki/OpenRC/Stacked%20runlevel Gentoo wiki].&lt;br /&gt;
&lt;br /&gt;
== Config files == &lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC is {{Path|/etc/rc.conf}}. The OpenRC service scripts for each service can be found at {{Path|/etc/init.d/}} and their respective service configuration files at {{Path|/etc/conf.d/}}.&lt;br /&gt;
&lt;br /&gt;
== Command usage ==&lt;br /&gt;
&lt;br /&gt;
OpenRC provides the following commands:&lt;br /&gt;
* {{ic|rc-update}} &lt;br /&gt;
* {{ic|rc-service}}&lt;br /&gt;
* {{ic|rc-status}}&lt;br /&gt;
* {{ic|openrc}}&lt;br /&gt;
&lt;br /&gt;
To view the command usage for all OpenRC commands, use the &#039;&#039;&#039;--help&#039;&#039;&#039; or &#039;&#039;&#039;-h&#039;&#039;&#039; flag.  For example: {{ic|$ rc-update &#039;&#039;&#039;--help&#039;&#039;&#039;}} or {{ic|$ rc-update &#039;&#039;&#039;-h&#039;&#039;&#039;}} will show usage information for {{ic|rc-update}}.&lt;br /&gt;
&lt;br /&gt;
To {{ic|start}}, {{ic|stop}} or {{ic|restart}} a service {{ic|ServiceName}} immediately at the current runlevel:-&lt;br /&gt;
{{Cmd|$ doas rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
{{Cmd|$ doas rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; stop}}&lt;br /&gt;
&lt;br /&gt;
To {{ic|add}} or {{ic|delete}} a service to/from the sequence of services that need to start automatically in future sessions at the {{ic|boot}} runlevel: &lt;br /&gt;
{{Cmd|$ doas rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; boot}}&lt;br /&gt;
Note that the {{ic|&#039;&#039;&#039;default&#039;&#039;&#039;}} runlevel is assumed, so it does not need to be stated explicitly:&lt;br /&gt;
{{Cmd|$ doas rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
{{Cmd|$ doas rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
List the current status of all services; to display the status of all &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{Cmd|$ rc-status}}&lt;br /&gt;
List the assigned runlevels of all services; to display the runlevels of &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{Cmd|$ rc-update}}&lt;br /&gt;
&lt;br /&gt;
Refer to the [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user guide] for more detailed information.&lt;br /&gt;
&lt;br /&gt;
== Cgroups ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses [https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html Cgroups version 2], or &#039;&#039;&#039;unified&#039;&#039;&#039;, as the default cgroup mode in OpenRC since [[Release_Notes_for_Alpine_3.19.0#cgroups_v2|v3.19]]. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|cgroups}} service:{{Cmd|# rc-service cgroups start}} &lt;br /&gt;
To enable cgroups and auto mount the cgroup filesystem on boot {{Cmd|# rc-update add cgroups}}&lt;br /&gt;
&lt;br /&gt;
To enable &#039;&#039;hybrid&#039;&#039; cgroups, the previous default, edit the file {{Path|/etc/rc.conf}} and change the setting for {{ic|rc_cgroup_mode}} as follows:{{Cat|/etc/rc.conf|rc_cgroup_mode{{=}}&amp;quot;hybrid&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
== Local service ==&lt;br /&gt;
&lt;br /&gt;
Use the {{Path|/etc/local.d/}} directory to place programs or scripts which are to be run when the {{ic|local}} service is started or stopped.&lt;br /&gt;
&lt;br /&gt;
If a file in this directory is executable and it has a .start extension, it will be run when the local service is started. If a file is executable and it has a .stop extension, it will be run when the local service is stopped. For more info refer [https://github.com/OpenRC/openrc/blob/master/local.d/README README]&lt;br /&gt;
&lt;br /&gt;
To enable the {{ic|local}} service, issue the command:{{Cmd|# rc-update add local}}&lt;br /&gt;
&lt;br /&gt;
== Preventing slow services from delaying system startup ==&lt;br /&gt;
&lt;br /&gt;
Services that take a while to start will block the boot process until they complete. E.g.: {{ic|iwd}},{{ic|networking}},{{ic|chrony}} etc... might delay startup of an interactive system rather than start in the background. &lt;br /&gt;
&lt;br /&gt;
=== Parallel services === &lt;br /&gt;
&lt;br /&gt;
If the setting {{Codeline|rc_parallel{{=}}&amp;quot;YES&amp;quot;}} is configured, the OpenRC system tries to start services in parallel for a slight speed improvement. &lt;br /&gt;
This setting however comes with a message from openRC developers:{{Warning|whilst we have improved parallel, it can still potentially lock the boot process. Don&#039;t file bugs about this.}} &lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevel method === &lt;br /&gt;
&lt;br /&gt;
Slow services can also be [https://ptrcnull.me/posts/openrc-async-services.html started after login prompt] using [[#Stacked runlevels|stacked runlevels]]. &lt;br /&gt;
{{Warning|Editing the file {{Path|&#039;&#039;&#039;/etc/inittab&#039;&#039;&#039;}} wrongly will render the system unusable. Take backup and learn to restore it using rescue disk before proceeding.}}&lt;br /&gt;
# Create a custom runlevel &#039;&#039;&#039;async&#039;&#039;&#039;: {{Cmd|# mkdir /etc/runlevels/async}}&lt;br /&gt;
# Add &#039;&#039;&#039;default&#039;&#039;&#039; as a stacked runlevel {{Cmd|# rc-update add -s default async}}&lt;br /&gt;
# Remove slow service from &#039;&#039;&#039;default&#039;&#039;&#039; runlevel and add them to the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel: {{Cmd|# rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; default}} {{Cmd|# rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; async}}&lt;br /&gt;
# Enable the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel by adding the line &#039;&#039;&#039;::once:/sbin/openrc async&#039;&#039;&#039; to {{Path|/etc/inittab}} file as follows: {{Cat|/etc/inittab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
::wait:/sbin/openrc default&lt;br /&gt;
::once:/sbin/openrc async -q&lt;br /&gt;
&lt;br /&gt;
# Set up a couple of getty&#039;s&lt;br /&gt;
tty1::respawn:/sbin/getty 38400 tty1&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
After rebooting, services from &#039;&#039;&#039;async&#039;&#039;&#039; will start separately. Other services started in &#039;&#039;&#039;default&#039;&#039;&#039; runlevel may still block [[TTY_Autologin|agetty]] from running, due to the {{ic|wait}} label.&lt;br /&gt;
&lt;br /&gt;
== User services ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports managing services for users. User services are available from [[Release_Notes_for_Alpine_3.22.0#OpenRC_User_services|v3.22]]. Here is the [https://pkgs.alpinelinux.org/contents?file=*&amp;amp;path=%2Fetc%2Fuser%2Finit.d&amp;amp;name=&amp;amp;branch=edge&amp;amp;repo=&amp;amp;arch=x86_64 list of OpenRC User services] available currently.&lt;br /&gt;
&lt;br /&gt;
=== Config files and Runlevels for user services ===&lt;br /&gt;
&lt;br /&gt;
OpenRC uses {{path|$XDG_CONFIG_HOME/rc}} for its user service configuration. If &amp;lt;code&amp;gt;$XDG_CONFIG_HOME&amp;lt;/code&amp;gt; is unset, the fallback {{path|~/.config}} is used. The main configuration file for OpenRC User services is {{path|~/.config/rc/rc.conf}}.&lt;br /&gt;
&lt;br /&gt;
The service scripts for each OpenRC user service provided as part of official packages can be found at {{Path|/etc/user/init.d/}} and their respective service configuration files at {{Path|/etc/user/conf.d/}}. &lt;br /&gt;
&lt;br /&gt;
The folders {{path|~/.config/rc/init.d/}} and {{path|~/.config/rc/conf.d/}} can have user customized service scripts for User services and their respective configuration files. These scripts override official files at {{Path|/etc/user/}}, if their service names match.&lt;br /&gt;
&lt;br /&gt;
Runlevels for user service are represented by directories in {{path|$XDG_CONFIG_HOME/rc/runlevels}}.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
* [[XDG_RUNTIME_DIR]] variable must be set &lt;br /&gt;
&lt;br /&gt;
=== Configure environment variables ===&lt;br /&gt;
&lt;br /&gt;
If you do not use a [[Display manager]] or if your login manager supports &amp;lt;code&amp;gt;~/.profile&amp;lt;/code&amp;gt;, then it can be used to automatically start the user runlevel.&lt;br /&gt;
&lt;br /&gt;
==== For Wayland ====&lt;br /&gt;
{{Tip|User services like {{pkg|wlsunset}} depend on the {{ic|$WAYLAND_DISPLAY}} environment variable. Hence, it is [https://gitlab.alpinelinux.org/alpine/aports/-/issues/17375#note_530383 recommended] to use &#039;&#039;&#039;gui&#039;&#039;&#039; runlevel for such services. Even though [[PipeWire]] can run at &#039;&#039;&#039;default&#039;&#039;&#039; runlevel, ensure that all your User services can run at the chosen runlevel.}} &lt;br /&gt;
* Allow propagation of the {{ic|$WAYLAND_DISPLAY}} and associated environment variables by adding the following lines to file {{path|~/.config/rc/rc.conf}} as follows:{{Cat|~/.config/rc/rc.conf|&amp;lt;nowiki&amp;gt;rc_env_allow=&amp;quot;WAYLAND_DISPLAY&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* Create a custom &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel:{{Cmd|$ mkdir -p ~/.config/rc/runlevels/gui}}&lt;br /&gt;
* To start &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel, add the line {{ic|openrc -U gui}} to the startup file of your compositor. For eg, for [[Sway]] add:{{Cat|~/.config/sway/config|...&lt;br /&gt;
exec openrc -U gui}}&lt;br /&gt;
&lt;br /&gt;
==== For Xorg ====&lt;br /&gt;
&lt;br /&gt;
If [[Elogind]] is not used, ensure that [[Wayland#Creating_and_exporting_XDG_RUNTIME_DIR_manually|XDG_RUNTIME_DIR]] is set manually in {{path|~/.xinitrc}}. For eg, for [[dwm]] add:{{Cat|~/.xinitrc|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
if [ -z &amp;quot;$XDG_RUNTIME_DIR&amp;quot; ]; then&lt;br /&gt;
	XDG_RUNTIME_DIR=&amp;quot;/tmp/$(id -u)-runtime-dir&amp;quot;&lt;br /&gt;
	mkdir -pm 0700 &amp;quot;$XDG_RUNTIME_DIR&amp;quot;&lt;br /&gt;
	export XDG_RUNTIME_DIR&lt;br /&gt;
fi&lt;br /&gt;
openrc -U default&lt;br /&gt;
exec dwm&amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
&lt;br /&gt;
{{Note|For both the above cases, logout and login for the OpenRC user services to be started, before proceeding further.}}&lt;br /&gt;
&lt;br /&gt;
=== User service management ===&lt;br /&gt;
&lt;br /&gt;
Do not use &#039;&#039;&#039;doas&#039;&#039;&#039; when issuing User service commands. For managing user services, usual OpenRC commands can be used with &#039;&#039;&#039;-U&#039;&#039;&#039; option as distinct from the &#039;&#039;-u&#039;&#039; option.  &lt;br /&gt;
&lt;br /&gt;
Issue the command {{ic|$ rc-status -Ur}} to view and verify the current user runlevel as &#039;&#039;&#039;gui&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; for Wayland and Xorg, respectively, before proceeding. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|ServiceName}} user service, issue the command:{{Cmd|$ rc-service -U &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
Verify that the above OpenRC user service is started before proceeding further: {{Cmd|$ rc-status -U}} &lt;br /&gt;
To enable {{ic|ServiceName}} user service, issue the command: {{Cmd|$ rc-update -U add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|Once a user service is configured, to prevent duplicate instance, remove them from {{Path|/etc/xdg/autostart}} folder or from the startup/config file.}}&lt;br /&gt;
&lt;br /&gt;
=== PAM support ===&lt;br /&gt;
&lt;br /&gt;
The default installation of OpenRC user services in Alpine Linux is without PAM support.&lt;br /&gt;
&lt;br /&gt;
In scenarios where services should not be allowed to [https://wiki.gentoo.org/wiki/OpenRC#lingering linger] on logout, PAM support for OpenRC user services can be enabled by installing the {{pkg|openrc-user-pam}} package.{{Cmd|# apk add openrc-user-pam}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Whenever a openRC service fails to run, troubleshoot by enabling a debugging option, and then run the command. &lt;br /&gt;
&lt;br /&gt;
For example, if running the command {{ic|rc-service &amp;lt;var&amp;gt;greetd&amp;lt;/var&amp;gt; start}} causes the [[Greetd|greetd]] service to immediately crash, then alter the command to enable debug and to view its output:{{Cmd|# rc-service -d &amp;lt;var&amp;gt;greetd&amp;lt;/var&amp;gt; restart}}&lt;br /&gt;
&lt;br /&gt;
=== XDG_RUNTIME_DIR unset ===&lt;br /&gt;
&lt;br /&gt;
While configuring [[#User services|user services]], running the command {{ic|$ doas rc-update add -U pipewire gui}} will generate the above error {{ic|XDG_RUNTIME_DIR unset}}.  Always issue the command as normal user {{ic|$ rc-update add -U pipewire gui}} and do NOT use {{ic|doas}}. &lt;br /&gt;
&lt;br /&gt;
=== ERROR: user.greetd failed to start ===&lt;br /&gt;
&lt;br /&gt;
While using [[#User services|user services]] with [[greetd]], the above error message will appear. This failed error message for {{ic|user.greetd}} service is harmless as per {{MR|81612#note_492385}}.&lt;br /&gt;
&lt;br /&gt;
=== failed to create display ===&lt;br /&gt;
&lt;br /&gt;
When using openRC user services for {{ic|wlsunset}}, the following  error message may appear:{{Cmd|daemon.err wlsunset: failed to create display}}You will need the GUI runlevel for services that depend on {{ic|$WAYLAND_DISPLAY}}. Refer [[#For Wayland| Configure environment variables For Wayland]] section.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Writing Init Scripts]]&lt;br /&gt;
* [[Multiple Instances of Services]]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user Guide]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md OpenRC Service Script Writing Guide]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/OpenRC Gentoo Wiki]&lt;br /&gt;
* [https://wiki.archlinux.org/title/OpenRC ArchWiki]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/OpenRC PostmarketOS Wiki]&lt;br /&gt;
* [https://ptrcnull.me/posts/openrc-async-services.html Start services after login prompt]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]] &lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=32263</id>
		<title>OpenRC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;diff=32263"/>
		<updated>2026-04-01T18:59:57Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: removed certain instructions. refer talk page for more information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Alpine Linux uses [https://github.com/OpenRC/ OpenRC] for its [https://en.wikipedia.org/wiki/Init init] system. The init system manages the services, including the boot and shutdown of your system. [[#User services|OpenRC User services]] can be used for managing services for users. &lt;br /&gt;
&lt;br /&gt;
To learn the basics of OpenRC quickly, refer to the [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html working with OpenRC] guide from the Alpine Linux documentation project. &lt;br /&gt;
&lt;br /&gt;
== Quickstart  ==&lt;br /&gt;
&lt;br /&gt;
{|align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;50%&amp;quot; |Action&lt;br /&gt;
|             |Command&lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Managing a service - start,stop and restart&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Start {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
|-&lt;br /&gt;
| Stop {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; stop}} &lt;br /&gt;
|-&lt;br /&gt;
| Restart {{ic|ServiceName}} now || {{Cmd|# rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; restart}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;Adding and removing service from runlevels&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Add {{ic|ServiceName}} to {{ic|runlevel}} || {{Cmd|# rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| Remove {{ic|ServiceName}} from {{ic|runlevel}} || {{Cmd|# rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check services in a runlevel and their status&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To check status of {{ic|ServiceName}} || {{Cmd|$ rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; status}} &lt;br /&gt;
|-&lt;br /&gt;
| To view services configured at {{ic|runlevel}}  || {{Cmd|$ rc-update show &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| To view currently active runlevels and state of services  || {{Cmd|$ rc-status}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Check and manage runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view available runlevels || {{Cmd|$ rc-status -l}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different {{ic|runlevel}} || {{Cmd|# openrc &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039; Stacked runlevels&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{Cmd|# rc-update add -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| To remove {{ic|s-runlevel}} as a stacked {{ic|runlevel}} || {{Cmd|# rc-update del -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}}&lt;br /&gt;
| &lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; |&#039;&#039;&#039;User Services&#039;&#039;&#039;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 0.9em; text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| To view currently active user runlevels and state of user services ({{ic|-U}}) || {{Cmd|$ rc-status -U}} &lt;br /&gt;
|-&lt;br /&gt;
| To change to a different user {{ic|runlevel}} || {{Cmd|$ openrc -U &amp;lt;/var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|-&lt;br /&gt;
| Add user {{ic|ServiceName}} to user {{ic|runlevel}} || {{Cmd|$ rc-update -U add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}}&lt;br /&gt;
|-&lt;br /&gt;
| To add {{ic|s-runlevel}}as a stacked user {{ic|runlevel}} || {{Cmd|$ rc-update -U add -s &amp;lt;var&amp;gt;s-runlevel&amp;lt;/var&amp;gt; &amp;lt;var&amp;gt;runlevel&amp;lt;/var&amp;gt;}} &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Runlevels ==&lt;br /&gt;
&lt;br /&gt;
The [[BusyBox#init|BusyBox init]] executes [[OpenRC]] runlevel scripts according to entries in {{Path|/etc/inittab}}. A &#039;&#039;runlevel&#039;&#039; is basically a collection of services that needs to be started when certain conditions are met. Instead of using runlevel numbers, such as is used traditionally with &#039;&#039;SysV&#039;&#039; init, these are named, and users can create their own, if needed. The default startup uses the &#039;&#039;&#039;sysinit&#039;&#039;&#039;, &#039;&#039;&#039;boot&#039;&#039;&#039;, and &#039;&#039;&#039;default&#039;&#039;&#039; runlevels, in that order. Shutdown uses the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel.&lt;br /&gt;
&lt;br /&gt;
The available runlevels are:&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; - Used if no runlevel is specified. (This is generally the runlevel you want to add services to.)&lt;br /&gt;
* &#039;&#039;&#039;hotplugged&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;manual&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The special runlevels are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;sysinit&#039;&#039;&#039; - Brings up system specific stuff such as &amp;lt;code&amp;gt;/dev&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;/proc&amp;lt;/code&amp;gt; and optionally &amp;lt;code&amp;gt;/sys&amp;lt;/code&amp;gt; for Linux based systems. It also mounts &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; as a ramdisk using tmpfs where available unless &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; is mounted rw at boot. &amp;lt;code&amp;gt;&#039;&#039;&#039;rc&#039;&#039;&#039;&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;/lib/rc/init.d&amp;lt;/code&amp;gt; to hold state information about the services it runs. &#039;&#039;&#039;sysinit&#039;&#039;&#039; always runs when the host first starts and should not be run again.&lt;br /&gt;
* &#039;&#039;&#039;boot&#039;&#039;&#039; - Generally, the only services that one should add to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel are those which deal with the mounting of filesystems, setting the initial state of attached peripherals, and logging. Hotplugged services are added to the &#039;&#039;&#039;boot&#039;&#039;&#039; runlevel by the system. All services in the &#039;&#039;&#039;boot&#039;&#039;&#039; and &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevels are automatically included in all other runlevels except for those listed here.&lt;br /&gt;
* &#039;&#039;&#039;single&#039;&#039;&#039; - Stops all services except for those in the &#039;&#039;&#039;sysinit&#039;&#039;&#039; runlevel.&lt;br /&gt;
* &#039;&#039;&#039;reboot&#039;&#039;&#039; - Changes to the &#039;&#039;&#039;shutdown&#039;&#039;&#039; runlevel, and then reboots the host.&lt;br /&gt;
* &#039;&#039;&#039;shutdown&#039;&#039;&#039; - Changes to the shutdown &#039;&#039;&#039;runlevel&#039;&#039;&#039;, and then halts the host.&lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevels ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Stacked&#039;&#039; runlevels allows for the &amp;quot;inheritance&amp;quot; of services. A few use cases are given below:-&lt;br /&gt;
* [https://docs.alpinelinux.org/user-handbook/0.1a/Working/openrc.html#_runlevel_stacking Running an office runlevel with VPN service]&lt;br /&gt;
* [[#Preventing slow services from delaying system startup|Preventing slow services from delaying system startup]]&lt;br /&gt;
For more detailed information, refer [https://wiki.gentoo.org/wiki/OpenRC/Stacked%20runlevel Gentoo wiki].&lt;br /&gt;
&lt;br /&gt;
== Config files == &lt;br /&gt;
&lt;br /&gt;
The main configuration file for OpenRC is {{Path|/etc/rc.conf}}. The OpenRC service scripts for each service can be found at {{Path|/etc/init.d/}} and their respective service configuration files at {{Path|/etc/conf.d/}}.&lt;br /&gt;
&lt;br /&gt;
== Command usage ==&lt;br /&gt;
&lt;br /&gt;
OpenRC provides the following commands:&lt;br /&gt;
* {{ic|rc-update}} &lt;br /&gt;
* {{ic|rc-service}}&lt;br /&gt;
* {{ic|rc-status}}&lt;br /&gt;
* {{ic|openrc}}&lt;br /&gt;
&lt;br /&gt;
To view the command usage for all OpenRC commands, use the &#039;&#039;&#039;--help&#039;&#039;&#039; or &#039;&#039;&#039;-h&#039;&#039;&#039; flag.  For example: {{ic|$ rc-update &#039;&#039;&#039;--help&#039;&#039;&#039;}} or {{ic|$ rc-update &#039;&#039;&#039;-h&#039;&#039;&#039;}} will show usage information for {{ic|rc-update}}.&lt;br /&gt;
&lt;br /&gt;
To {{ic|start}}, {{ic|stop}} or {{ic|restart}} a service {{ic|ServiceName}} immediately at the current runlevel:-&lt;br /&gt;
{{Cmd|$ doas rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
{{Cmd|$ doas rc-service &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; stop}}&lt;br /&gt;
&lt;br /&gt;
To {{ic|add}} or {{ic|delete}} a service to/from the sequence of services that need to start automatically in future sessions at the {{ic|boot}} runlevel: &lt;br /&gt;
{{Cmd|$ doas rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; boot}}&lt;br /&gt;
Note that the {{ic|&#039;&#039;&#039;default&#039;&#039;&#039;}} runlevel is assumed, so it does not need to be stated explicitly:&lt;br /&gt;
{{Cmd|$ doas rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
{{Cmd|$ doas rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
List the current status of all services; to display the status of all &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{Cmd|$ rc-status}}&lt;br /&gt;
List the assigned runlevels of all services; to display the runlevels of &#039;&#039;user services&#039;&#039; add &#039;&#039;&#039;-U&#039;&#039;&#039; :&lt;br /&gt;
{{Cmd|$ rc-update}}&lt;br /&gt;
&lt;br /&gt;
Refer to the [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user guide] for more detailed information.&lt;br /&gt;
&lt;br /&gt;
== Cgroups ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux uses [https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html Cgroups version 2], or &#039;&#039;&#039;unified&#039;&#039;&#039;, as the default cgroup mode in OpenRC since [[Release_Notes_for_Alpine_3.19.0#cgroups_v2|v3.19]]. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|cgroups}} service:{{Cmd|# rc-service cgroups start}} &lt;br /&gt;
To enable cgroups and auto mount the cgroup filesystem on boot {{Cmd|# rc-update add cgroups}}&lt;br /&gt;
&lt;br /&gt;
To enable &#039;&#039;hybrid&#039;&#039; cgroups, the previous default, edit the file {{Path|/etc/rc.conf}} and change the setting for {{ic|rc_cgroup_mode}} as follows:{{Cat|/etc/rc.conf|rc_cgroup_mode{{=}}&amp;quot;hybrid&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
== Local service ==&lt;br /&gt;
&lt;br /&gt;
Use the {{Path|/etc/local.d/}} directory to place programs or scripts which are to be run when the {{ic|local}} service is started or stopped.&lt;br /&gt;
&lt;br /&gt;
If a file in this directory is executable and it has a .start extension, it will be run when the local service is started. If a file is executable and it has a .stop extension, it will be run when the local service is stopped. For more info refer [https://github.com/OpenRC/openrc/blob/master/local.d/README README]&lt;br /&gt;
&lt;br /&gt;
To enable the {{ic|local}} service, issue the command:{{Cmd|# rc-update add local}}&lt;br /&gt;
&lt;br /&gt;
== Preventing slow services from delaying system startup ==&lt;br /&gt;
&lt;br /&gt;
Services that take a while to start will block the boot process until they complete. E.g.: {{ic|iwd}},{{ic|networking}},{{ic|chrony}} etc... might delay startup of an interactive system rather than start in the background. &lt;br /&gt;
&lt;br /&gt;
=== Parallel services === &lt;br /&gt;
&lt;br /&gt;
If the setting {{Codeline|rc_parallel{{=}}&amp;quot;YES&amp;quot;}} is configured, the OpenRC system tries to start services in parallel for a slight speed improvement. &lt;br /&gt;
This setting however comes with a message from openRC developers:{{Warning|whilst we have improved parallel, it can still potentially lock the boot process. Don&#039;t file bugs about this.}} &lt;br /&gt;
&lt;br /&gt;
=== Stacked runlevel method === &lt;br /&gt;
&lt;br /&gt;
Slow services can also be [https://ptrcnull.me/posts/openrc-async-services.html started after login prompt] using [[#Stacked runlevels|stacked runlevels]]. &lt;br /&gt;
{{Warning|Editing the file {{Path|&#039;&#039;&#039;/etc/inittab&#039;&#039;&#039;}} wrongly will render the system unusable. Take backup and learn to restore it using rescue disk before proceeding.}}&lt;br /&gt;
# Create a custom runlevel &#039;&#039;&#039;async&#039;&#039;&#039;: {{Cmd|# mkdir /etc/runlevels/async}}&lt;br /&gt;
# Add &#039;&#039;&#039;default&#039;&#039;&#039; as a stacked runlevel {{Cmd|# rc-update add -s default async}}&lt;br /&gt;
# Remove slow service from &#039;&#039;&#039;default&#039;&#039;&#039; runlevel and add them to the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel: {{Cmd|# rc-update del &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; default}} {{Cmd|# rc-update add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; async}}&lt;br /&gt;
# Enable the &#039;&#039;&#039;async&#039;&#039;&#039; runlevel by adding the line &#039;&#039;&#039;::once:/sbin/openrc async&#039;&#039;&#039; to {{Path|/etc/inittab}} file as follows: {{Cat|/etc/inittab|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
::wait:/sbin/openrc default&lt;br /&gt;
::once:/sbin/openrc async -q&lt;br /&gt;
&lt;br /&gt;
# Set up a couple of getty&#039;s&lt;br /&gt;
tty1::respawn:/sbin/getty 38400 tty1&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
After rebooting, services from &#039;&#039;&#039;async&#039;&#039;&#039; will start separately. Other services started in &#039;&#039;&#039;default&#039;&#039;&#039; runlevel may still block [[TTY_Autologin|agetty]] from running, due to the {{ic|wait}} label.&lt;br /&gt;
&lt;br /&gt;
== User services ==&lt;br /&gt;
&lt;br /&gt;
OpenRC supports managing services for users. User services are available from [[Release_Notes_for_Alpine_3.22.0#OpenRC_User_services|v3.22]]. Here is the [https://pkgs.alpinelinux.org/contents?file=*&amp;amp;path=%2Fetc%2Fuser%2Finit.d&amp;amp;name=&amp;amp;branch=edge&amp;amp;repo=&amp;amp;arch=x86_64 list of OpenRC User services] available currently.&lt;br /&gt;
&lt;br /&gt;
Do not use &#039;&#039;&#039;doas&#039;&#039;&#039; when using user service commands. For managing user services, usual OpenRC commands can be used with &#039;&#039;&#039;-U&#039;&#039;&#039; option as distinct from the &#039;&#039;-u&#039;&#039; option.  &lt;br /&gt;
&lt;br /&gt;
=== Config files and Runlevels for user services ===&lt;br /&gt;
&lt;br /&gt;
OpenRC uses {{path|$XDG_CONFIG_HOME/rc}} for its user service configuration. If &amp;lt;code&amp;gt;$XDG_CONFIG_HOME&amp;lt;/code&amp;gt; is unset, the fallback {{path|~/.config}} is used. The main configuration file for OpenRC User services is {{path|~/.config/rc/rc.conf}}.&lt;br /&gt;
&lt;br /&gt;
The service scripts for each OpenRC user service provided as part of official packages can be found at {{Path|/etc/user/init.d/}} and their respective service configuration files at {{Path|/etc/user/conf.d/}}. &lt;br /&gt;
&lt;br /&gt;
The folders {{path|~/.config/rc/init.d/}} and {{path|~/.config/rc/conf.d/}} can have user customized service scripts for User services and their respective configuration files. These scripts override official files at {{Path|/etc/user/}}, if their service names match.&lt;br /&gt;
&lt;br /&gt;
Runlevels for user service are represented by directories in {{path|$XDG_CONFIG_HOME/rc/runlevels}}.&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
* [[XDG_RUNTIME_DIR]] variable must be set &lt;br /&gt;
&lt;br /&gt;
=== Configure environment variables ===&lt;br /&gt;
&lt;br /&gt;
If you do not use a [[Display manager]] or if your login manager supports &amp;lt;code&amp;gt;~/.profile&amp;lt;/code&amp;gt;, then it can be used to automatically start the user runlevel.&lt;br /&gt;
&lt;br /&gt;
==== For Wayland ====&lt;br /&gt;
{{Tip|User services like {{pkg|wlsunset}} depend on the {{ic|$WAYLAND_DISPLAY}} environment variable. Hence, it is [https://gitlab.alpinelinux.org/alpine/aports/-/issues/17375#note_530383 recommended] to use &#039;&#039;&#039;gui&#039;&#039;&#039; runlevel for such services. Even though [[PipeWire]] can run at &#039;&#039;&#039;default&#039;&#039;&#039; runlevel, ensure that all your User services can run at the chosen runlevel.}} &lt;br /&gt;
* Allow propagation of the {{ic|$WAYLAND_DISPLAY}} and associated environment variables by adding the following lines to file {{path|~/.config/rc/rc.conf}} as follows:{{Cat|~/.config/rc/rc.conf|&amp;lt;nowiki&amp;gt;rc_env_allow=&amp;quot;WAYLAND_DISPLAY&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* Create a custom &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel:{{Cmd|$ mkdir -p ~/.config/rc/runlevels/gui}}&lt;br /&gt;
* To start &#039;&#039;&#039;gui&#039;&#039;&#039; user runlevel, add the line {{ic|openrc -U gui}} to the startup file of your compositor. For eg, for [[Sway]] add:{{Cat|~/.config/sway/config|...&lt;br /&gt;
exec openrc -U gui}}&lt;br /&gt;
&lt;br /&gt;
==== For Xorg ====&lt;br /&gt;
&lt;br /&gt;
If [[Elogind]] is not used, ensure that [[Wayland#Creating_and_exporting_XDG_RUNTIME_DIR_manually|XDG_RUNTIME_DIR]] is set manually in {{path|~/.xinitrc}}. For eg, for [[dwm]] add:{{Cat|~/.xinitrc|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
if [ -z &amp;quot;$XDG_RUNTIME_DIR&amp;quot; ]; then&lt;br /&gt;
	XDG_RUNTIME_DIR=&amp;quot;/tmp/$(id -u)-runtime-dir&amp;quot;&lt;br /&gt;
	mkdir -pm 0700 &amp;quot;$XDG_RUNTIME_DIR&amp;quot;&lt;br /&gt;
	export XDG_RUNTIME_DIR&lt;br /&gt;
fi&lt;br /&gt;
openrc -U default&lt;br /&gt;
exec dwm&amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
&lt;br /&gt;
{{Note|For both the above cases, logout and login for the OpenRC user services to be started, before proceeding further.}}&lt;br /&gt;
&lt;br /&gt;
=== User service management ===&lt;br /&gt;
&lt;br /&gt;
Issue the command {{ic|$ rc-status -Ur}} to view and verify the current user runlevel as &#039;&#039;&#039;gui&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; for Wayland and Xorg, respectively, before proceeding. &lt;br /&gt;
&lt;br /&gt;
To start {{ic|ServiceName}} user service, issue the command:{{Cmd|$ rc-service -U &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt; start}}&lt;br /&gt;
Verify that the above OpenRC user service is started before proceeding further: {{Cmd|$ rc-status -U}} &lt;br /&gt;
To enable {{ic|ServiceName}} user service, issue the command: {{Cmd|$ rc-update -U add &amp;lt;var&amp;gt;ServiceName&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|Once a user service is configured, to prevent duplicate instance, remove them from {{Path|/etc/xdg/autostart}} folder or from the startup/config file.}}&lt;br /&gt;
&lt;br /&gt;
=== PAM support ===&lt;br /&gt;
&lt;br /&gt;
The default installation of OpenRC user services in Alpine Linux is without PAM support.&lt;br /&gt;
&lt;br /&gt;
In scenarios where services should not be allowed to [https://wiki.gentoo.org/wiki/OpenRC#lingering linger] on logout, PAM support for OpenRC user services can be enabled by installing the {{pkg|openrc-user-pam}} package.{{Cmd|# apk add openrc-user-pam}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Whenever a openRC service fails to run, troubleshoot by enabling a debugging option, and then run the command. &lt;br /&gt;
&lt;br /&gt;
For example, if running the command {{ic|rc-service &amp;lt;var&amp;gt;greetd&amp;lt;/var&amp;gt; start}} causes the [[Greetd|greetd]] service to immediately crash, then alter the command to enable debug and to view its output:{{Cmd|# rc-service -d &amp;lt;var&amp;gt;greetd&amp;lt;/var&amp;gt; restart}}&lt;br /&gt;
&lt;br /&gt;
=== XDG_RUNTIME_DIR unset ===&lt;br /&gt;
&lt;br /&gt;
While configuring [[#User services|user services]], running the command {{ic|$ doas rc-update add -U pipewire gui}} will generate the above error {{ic|XDG_RUNTIME_DIR unset}}.  Always issue the command as normal user {{ic|$ rc-update add -U pipewire gui}} and do NOT use {{ic|doas}}. &lt;br /&gt;
&lt;br /&gt;
=== ERROR: user.greetd failed to start ===&lt;br /&gt;
&lt;br /&gt;
While using [[#User services|user services]] with [[greetd]], the above error message will appear. This failed error message for {{ic|user.greetd}} service is harmless as per {{MR|81612#note_492385}}.&lt;br /&gt;
&lt;br /&gt;
=== failed to create display ===&lt;br /&gt;
&lt;br /&gt;
When using openRC user services for {{ic|wlsunset}}, the following  error message may appear:{{Cmd|daemon.err wlsunset: failed to create display}}You will need the GUI runlevel for services that depend on {{ic|$WAYLAND_DISPLAY}}. Refer [[#For Wayland| Configure environment variables For Wayland]] section.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Writing Init Scripts]]&lt;br /&gt;
* [[Multiple Instances of Services]]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/user-guide.md OpenRC user Guide]&lt;br /&gt;
* [https://github.com/OpenRC/openrc/blob/master/service-script-guide.md OpenRC Service Script Writing Guide]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/OpenRC Gentoo Wiki]&lt;br /&gt;
* [https://wiki.archlinux.org/title/OpenRC ArchWiki]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/OpenRC PostmarketOS Wiki]&lt;br /&gt;
* [https://ptrcnull.me/posts/openrc-async-services.html Start services after login prompt]&lt;br /&gt;
&lt;br /&gt;
[[Category:Booting]] &lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32187</id>
		<title>System Disk Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32187"/>
		<updated>2026-03-26T06:27:54Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: made minor rewording, added a tip and clarified on the internet access&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;System Disk mode is the traditional or classic harddisk installation of Alpine Linux. This mode is suitable for use cases like [[Tutorials_and_Howtos#Desktop|desktop]], [[Setting up the build environment|development machine]] etc. &lt;br /&gt;
&lt;br /&gt;
{{Tip|If an entire hard disk(s) is available for Alpine Linux, [[Installation#setup-alpine_based_System_Disk_Install|setup-alpine based install]] is the recommended way to install Alpine Linux.}}&lt;br /&gt;
&lt;br /&gt;
== setup-disk based Installation ==&lt;br /&gt;
&lt;br /&gt;
To perform a traditional hard-disk installation of Alpine Linux, after completing the base configuration, proceed to create, format and mount your partitions with MOUNTPOINT {{Path|&#039;&#039;&#039;/mnt&#039;&#039;&#039;}} as root and run the command {{Codeline|&#039;&#039;&#039;&amp;lt;Code&amp;gt;setup-disk -m sys /mnt&amp;lt;/Code&amp;gt;&#039;&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
The [[Alpine_setup_scripts#setup-disk|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] script performs a traditional hard disk install of your running system and can be customized using [[Alpine_setup_scripts#Environment_Variables|environment variables]]. A working [[Configure_Networking#Connectivity_testing|internet access]] configured in step 1 below is mandatory to complete this installation, if &#039;&#039;&#039;Extended image&#039;&#039;&#039; is not used. The detailed steps are given below:&lt;br /&gt;
&lt;br /&gt;
# Follow the [[Installation#General_course_of_action|Installation guide]] to complete the [[Installation#Base_configuration|base configuration]], if not already done. &lt;br /&gt;
# If necessary formatted partition(s) are unavailable, manually [[Setting up disks manually#Creating_partitions|create]] them first and [[Setting up disks manually#Formatting_partitions|format]] them including swap partition(if used). If you&#039;re using legacy BIOS mode, use DOS i.e MBR partition table and ensure that proper partition is bootable for [[Bootloaders#Syslinux|extlinux]].&lt;br /&gt;
# Mount the &#039;&#039;&#039;/ (root)&#039;&#039;&#039;  partition on a mount point i.e say {{Path|/mnt}} as follows: {{Cmd|# mount /dev/sdXY /mnt}}&lt;br /&gt;
# If you&#039;re using [[UEFI|EFI]], create a mount point &amp;lt;code&amp;gt;/mnt/boot&amp;lt;/code&amp;gt; and mount the EFI system partition(ESP) on it. {{Cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/boot&lt;br /&gt;
# mount /dev/sdXY /mnt/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# If [[Swap|swap]] partition is available, you can also enable it now: {{Cmd|# swapon /dev/sdXY }}&lt;br /&gt;
# Install Alpine Linux using the following command: {{Cmd|# setup-disk -m sys /mnt}}&lt;br /&gt;
# The above command detects your file system layout and generates {{Path|/etc/fstab}} and installs a [[Bootloaders|bootloader]] based on the optional [[Alpine_setup_scripts#Environment_Variables|environment variable]] &amp;lt;Code&amp;gt;BOOTLOADER&amp;lt;/Code&amp;gt; and completes the installation by transferring your running system&#039;s configuration to the hard disk.&lt;br /&gt;
# At the end of Installation, you can [[Installation#Reboot|reboot]] to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Mounting on /dev/sdXY sysroot failed ===&lt;br /&gt;
&lt;br /&gt;
The error message appears as follows with variations in &amp;lt;code&amp;gt;/dev/sda8&amp;lt;/code&amp;gt; depending on the partition number and SSD/HDD etc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
mounting /dev/sda8 on /sysroot failed: No such file or directory&lt;br /&gt;
mounting root: failed&lt;br /&gt;
initramfs emergency recovery shell launched. Type &#039;exit&#039; to continue boot&lt;br /&gt;
sh: can&#039;t access tty: job control turned off&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message can be caused by various reasons. Follow the below steps in the emergency shell to identify one possible cause.&lt;br /&gt;
&lt;br /&gt;
# Verify that the partition name in which Alpine Linux was installed matches the above [[#Mounting on /dev/sdXY sysroot failed|error]] by issuing the command and also note down the filesystem type of that partition (say TYPE=&amp;quot;ext4&amp;quot;) : {{Cmd| blkid}}&lt;br /&gt;
# If the expected disk (e.g., /dev/sda, /dev/nvme0n1) itself is missing in the output of {{ic| blkid}}, check [[#Disks not detected after setup-disk|Disks not detected after setup-disk]].&lt;br /&gt;
# Verify that sysroot exists by issuing the command. {{Cmd|ls -ld /sysroot}}&lt;br /&gt;
# Check if the above error message apears when issuing the command. {{Cmd|mount /dev/sda8 /sysroot}}&lt;br /&gt;
# If there is no error message, proceed to check if the issue is caused by a [[#Filesystem corruption|filesystem corruption]].&lt;br /&gt;
# If the manual mount command fails with &amp;quot;No such file or directory&amp;quot; even though you verified /sysroot exists in Step 3, this confirms the kernel doesn&#039;t recognize the filesystem type. Check whether filesystem modules(change ext4 if needed) are loaded by issuing the command. {{Cmd|&amp;lt;nowiki&amp;gt;lsmod | grep ext4 &amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
# If there is no output, then it confirms that the above [[#Mounting on /dev/sdXY sysroot failed|issue]] is caused by [[#Missing filesystem modules in the kernel cmdline|missing filesystem module]].&lt;br /&gt;
&lt;br /&gt;
==== Disks not detected after setup-disk====&lt;br /&gt;
&lt;br /&gt;
After running the standard Alpine installation command: {{ic|setup-disk -m sys /mnt}} and rebooting, the system gives the error mentioned in [[#Mounting on /dev/sdXY sysroot failed|Mounting on /dev/sdXY sysroot failed]] with the expected disk (e.g., /dev/sda, /dev/nvme0n1) missing to show at the output of {{ic| blkid}}. This prevents booting into the installed system. &lt;br /&gt;
&lt;br /&gt;
Issue: As per [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10615 bug report] this might be caused by BIOS storage controller being set to &amp;quot;RAID On (Intel Rapid Storage Technology)&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
Resolution: Switch the storage mode in BIOS/UEFI: Go to BIOS → Storage or SATA/NVMe Operation. Change setting from:RAID On (Intel Rapid Storage Technology) to: AHCI or AHCI/NVMe.&lt;br /&gt;
&lt;br /&gt;
==== Missing filesystem modules in the kernel cmdline ====&lt;br /&gt;
&lt;br /&gt;
[[BusyBox]] mount command does not autoload modules, so need to add filesystem modules to the kernel cmdline. Even though alpine installer does this automatically, this has to be taken care of in case of manual disk install, particularly for [[Dualbooting|dualboot]] installations.&lt;br /&gt;
&lt;br /&gt;
# To resolve, issue the command to load the appropriate filesystem module(say TYPE=&amp;quot;ext4&amp;quot;).{{Cmd|modprobe ext4}}&lt;br /&gt;
# To verify if the issue is resolved, reissue the command.{{Cmd|mount /dev/sda8 /sysroot}} &lt;br /&gt;
# If mount succeeded, issue the following command to boot into Alpine Linux. {{Cmd|exit}}&lt;br /&gt;
&lt;br /&gt;
Choose the appropriate solution based on your use case for a permanent fix:&lt;br /&gt;
&lt;br /&gt;
*If you are using [[Bootloaders#GRUB|grub]], then ensure that {{Codeline|GRUB_CMDLINE_LINUX}} line in the file {{Path|/etc/default/grub}} has the appropriate filesystem module &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
GRUB_CMDLINE_LINUX=&amp;quot;console=ttyS0,19200n8 net.ifnames=0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
* If you are using [[Bootloaders#Syslinux|ExtLinux/SysLinux]], then ensure that {{Codeline|APPEND}} line in the file {{Path|/boot/extlinux.conf}} has &amp;lt;code&amp;gt;root=UUID=&amp;lt;UUID ID&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;root=/dev/sdXY&amp;lt;/code&amp;gt; and the same matches the root path in the {{Path|/etc/fstab}} file. Also ensure that modules has the appropriate filesystem like &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/boot/extlinux.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
APPEND root=/dev/sdXY modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
# root=UUID=&amp;lt;UUID ID&amp;gt; can be used also in the APPEND Line.&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|For both above cases, you may need to issue {{Codeline|update-grub}} or {{Codeline|update-extlinux}} after making above changes.}}&lt;br /&gt;
 &lt;br /&gt;
*For a solution independent of [[Bootloaders|bootloaders]], ensure that the file {{Path|/etc/mkinitfs/mkinitfs.conf}} has the necessary filesystem module in it. Refer [[Initramfs init|Initramfs]] page for more information and recreate initramfs image.&lt;br /&gt;
&lt;br /&gt;
==== Filesystem corruption ====&lt;br /&gt;
&lt;br /&gt;
To fix filesystem corruption issues, the command fsck must be run on the root partition. The root partition should be umounted before running fsck. Boot from a [[Rescue disk]] to run the fsck command on the root partition:{{Cmd|&amp;lt;nowiki&amp;gt;# fsck -y /dev/&amp;lt;DEVICE&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After running fsck, proceed to Reboot the Computer.&lt;br /&gt;
&lt;br /&gt;
If the fsck Command does Fix the Corruption on the Root File System but the &#039;&#039;&#039;Error: Mounting Root Failed&#039;&#039;&#039; still persists then the next step would be to ReBuild the &#039;&#039;&#039;initramfs&#039;&#039;&#039; File System with the &#039;&#039;&#039;mkinitfs&#039;&#039;&#039; Command then Reboot. You need to &#039;&#039;&#039;Mount the Root Partition&#039;&#039;&#039; and [[Chroot]] into the Mounted Root Partition before running the mkinitfs Command as shown in the [[Initramfs init|initramfs]] page. &lt;br /&gt;
&lt;br /&gt;
==== Check File System Kernel Modules are Loading ====&lt;br /&gt;
&lt;br /&gt;
Run the below command to output the File System Kernel modules, where the file system can be one among the following: &#039;&#039;&#039;ext2&#039;&#039;&#039;, &#039;&#039;&#039;ext3&#039;&#039;&#039;, &#039;&#039;&#039;ext4&#039;&#039;&#039;, &#039;&#039;&#039;btrfs&#039;&#039;&#039;, &#039;&#039;&#039;xfs&#039;&#039;&#039;, &#039;&#039;&#039;fat&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# lsmod | grep &amp;lt;File System&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An example output is given below for the above command, with necessary abbreviations explained:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
alpinepc:~# lsmod | grep ext4&lt;br /&gt;
&lt;br /&gt;
ext4                 1155072  2&lt;br /&gt;
crc16                  12288  1 ext4&lt;br /&gt;
mbcache                16384  1 ext4&lt;br /&gt;
jbd2                  200704  1 ext4&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
EXT4 = [[Filesystems|File System]]&amp;lt;br&amp;gt;&lt;br /&gt;
CRC16 = EXT4 Compression Support&amp;lt;br&amp;gt;&lt;br /&gt;
MBCACHE = MetaData Cache&amp;lt;br&amp;gt;&lt;br /&gt;
JBD2 = Journaling&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Blinking underscore ===&lt;br /&gt;
&lt;br /&gt;
On a UEFI system, at the end of Installation after rebooting, the computer screen may appear with a &#039;&#039;&#039;blinking underscore&#039;&#039;&#039;. This may be due to the firmware not finding a valid boot entry.&lt;br /&gt;
&lt;br /&gt;
The [[UEFI#EFI bootloaders|EFI bootloader]] entries are added without writing to NVRAM, thus preventing GRUB from calling {{ic|efibootmgr}}. In some cases the UEFI firmware may not boot from a bootloader without a valid NVRAM entry. In such cases, at the end of installation, instead of rebooting, manually add an entry for Alpine Linux in the NVRAM as follows:&lt;br /&gt;
* Install the {{pkg|efibootmgr}} package:{{Cmd|# apk add efibootmgr}}&lt;br /&gt;
* Adjust the device name {{ic|/dev/sdX}} and partition number {{ic|1}}, before issuing the command: {{Cmd|# efibootmgr --create --disk /dev/sdX --part 1 --label &amp;quot;Alpine&amp;quot; --loader &#039;\EFI\alpine\grubx64.efi&#039;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Bootloaders]] - For information on GRUB, Syslinux and rEFInd&lt;br /&gt;
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]&lt;br /&gt;
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Riscv64&amp;diff=32186</id>
		<title>Talk:Riscv64</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Riscv64&amp;diff=32186"/>
		<updated>2026-03-26T04:49:03Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: reminder about category section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Can we move to host implementation targeted sub-pages? ==&lt;br /&gt;
There&#039;s a lot of information here regarding QEMU based installation which is fantastic for getting off the ground.  There are a lot of specifics regarding different RISCV64 processors and boards though.  This page could quickly get muddied with information for SiFive, Allwinner, SpacemiT, etc.  My thought is that the current contents of this page become sub-page and the main Riscv64 page reference the different types of installation targets.&lt;br /&gt;
: Sure! I can see that this page is already long enough with just the QEMU content, so I’m happy to see it separated into its own page, as long as we can leave a “breadcrumb” from this main [[Riscv64]] page to the new one. Thanks! [[User:Fission|Fission]] ([[User talk:Fission|talk]]) 21:30, 25 March 2026 (UTC)&lt;br /&gt;
:: Very happy to see content coming in [[Riscv64]] page. For all content pages, remember to add the Riscv64 to the category section. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 04:49, 26 March 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=32185</id>
		<title>Setting up disks manually</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=32185"/>
		<updated>2026-03-26T04:44:07Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added Troubleshooting link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up disks manually involves creating or modifying partitions using partitioning tools and formatting them using various filesystem utilities to allow [[System Disk Mode]] or traditional HDD Installation of Alpine Linux at the end of [[Installation#Base configuration|base configuration step]] of installation. In addition to the above information, this page also documents various Disk layouts involving RAID, Encryption and LVM.&lt;br /&gt;
&lt;br /&gt;
{{Tip|The default [[Installation#setup-alpine based System Disk Install|System Disk]] installation requires and uses an entire HDD. If you intend to install Alpine Linux on a specific partition follow the [[System Disk Mode#setup-disk based Installation|setup-disk based installation page]].}}&lt;br /&gt;
&lt;br /&gt;
== Manual partitioning ==&lt;br /&gt;
&lt;br /&gt;
Creating partitions manually requires partitioning tool packages and formatting them requires appropriate filesystem utilities. Due to the minimal nature of Alpine Linux, the installation image environment may have only limited options. Depending on your requirements, install the necessary packages at the end of [[Installation#Base configuration|base configuration step]] of installation before proceeding further.&lt;br /&gt;
&lt;br /&gt;
{{Note|Some of the tools mentioned on this page may require working [[Configure_Networking#Connectivity_testing|Internet access]].}}&lt;br /&gt;
&lt;br /&gt;
* Create a partition using the available [[#Partitioning tools|Partitioning tools]]&lt;br /&gt;
* If MBR partition table is used, some partitioning tool may require manual steps to set up bootable flag.&lt;br /&gt;
* Once the necessary partition(s) have been created, do a reboot before proceeding further.&lt;br /&gt;
* [[#Formatting partitions|Format the partition]] using the appropriate tool based on the filesystem used. Some partition tools may format the partitions automatically.&lt;br /&gt;
&lt;br /&gt;
== Partitioning tools ==&lt;br /&gt;
&lt;br /&gt;
Only the basic busybox built-in &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; command available by default along with &amp;lt;code&amp;gt;sfdisk&amp;lt;/code&amp;gt;. Install any of the below listed partitioning tools immediately after setting up [[Installation#Base_configuration|base configuration]]. &lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 1.2em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;10%&amp;quot; |Command &lt;br /&gt;
|width=&amp;quot;15%&amp;quot; | Package name &lt;br /&gt;
|width=&amp;quot;40%&amp;quot;| Features &lt;br /&gt;
|           | Limitations&lt;br /&gt;
|-&lt;br /&gt;
| fdisk || Inbuilt {{pkg|busybox}} || can read GPT, Modify MBR || Cannot modify GPT&lt;br /&gt;
|-&lt;br /&gt;
| gdisk || {{pkg|gptfdisk}} || text mode, supports MBR/GPT bidirectional conversion, best for managing GPT partition tables|| None&lt;br /&gt;
|-&lt;br /&gt;
| cgdisk  || {{pkg|gptfdisk}}  || menu driven curses interface for gdisk || None&lt;br /&gt;
|-&lt;br /&gt;
| sgdisk || {{pkg|sgdisk}} || scriptable gdisk || Non-interactive&lt;br /&gt;
|-&lt;br /&gt;
| fdisk || {{pkg|util-linux-misc}} || text mode, supports both gpt and MBR, best for managing MBR partition tables || None except size due to other tools&lt;br /&gt;
|-&lt;br /&gt;
| cfdisk || {{pkg|cfdisk}} || menu driven curses interface for fdisk || None&lt;br /&gt;
|-&lt;br /&gt;
| sfdisk || {{pkg|sfdisk}} || scriptable fdisk || Non-interactive&lt;br /&gt;
|-&lt;br /&gt;
| parted || {{pkg|parted}} || text mode, supports both gpt and MBR|| cannot convert MBR to GPT, different interface from above tools&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphical tools like {{pkg|gparted}} and {{pkg|gnome-disk-utility}} can be used only after [[Installation#Post-Installation|setting up a graphical environment]].&lt;br /&gt;
&lt;br /&gt;
== Creating partitions ==&lt;br /&gt;
&lt;br /&gt;
For Alpine Linux, only the &#039;&#039;&#039;(/)&#039;&#039;&#039;root partition is mandatory. Even  a &#039;&#039;&#039;/boot&#039;&#039;&#039; partition and  &#039;&#039;&#039;swap&#039;&#039;&#039; are optional.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}&lt;br /&gt;
{{ic|cfdisk}} will be used in all examples here as it is based on text menu without any dependencies. However, installing the {{Pkg|cfdisk}} package requires network to be available if using Standard ISO boot image. Alternately, {{Pkg|&amp;lt;code&amp;gt;sfdisk&amp;lt;/code&amp;gt;}} can be installed without network. &lt;br /&gt;
&lt;br /&gt;
{{Tip|Use {{ic|cgdisk}} from {{Pkg|gptfdisk}} package for GPT partitions and for conversion from MBR to GPT.}}&lt;br /&gt;
&lt;br /&gt;
The following step installs the {{Pkg|cfdisk}} package: {{cmd|# apk add cfdisk }}&lt;br /&gt;
&lt;br /&gt;
Before using {{ic|cfdisk}} to create partitions, the disk name must be identified by using {{ic|blkid}}:{{cmd|# blkid}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/dev/sdX1: LABEL=&amp;quot;some&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;vfat&amp;quot;&lt;br /&gt;
/dev/sdX2: LABEL=&amp;quot;other&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When {{ic|cfdisk}} is run as follows, it looks for existing partitions on the disk {{Path|/dev/sdX}}: {{cmd|# cfdisk /dev/sdX}}&lt;br /&gt;
&lt;br /&gt;
== Resizing an existing partition ==&lt;br /&gt;
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}&lt;br /&gt;
&lt;br /&gt;
{{ic|cfdisk}} and {{ic|resize2fs}} from {{pkg|e2fsprogs-extra}} package can be used to resize existing partitions of ext2/3/4 filsystem on the disk. For other filsystems, the necessary [[Filesystems#Filesystem_Tools|filesystem tools]] must be installed. This can be done while booted. &lt;br /&gt;
&lt;br /&gt;
[[File:Cfdisk screenshot alpine 2024-03-04 143916.png|thumb|cfdisk screenshot ]]&lt;br /&gt;
&lt;br /&gt;
To resize disk, launch the {{ic|cfdisk}}: {{cmd|# cfdisk {{path|/dev/sda}}}}&lt;br /&gt;
&lt;br /&gt;
# Select the target partition, here as per image {{path|/dev/sda3}}&lt;br /&gt;
# Select &#039;&#039;Resize&#039;&#039; from the bottom menu.&lt;br /&gt;
# Enter the new &#039;&#039;Size&#039;&#039; at the prompt.&lt;br /&gt;
# Select &#039;&#039;Write&#039;&#039;, then &#039;&#039;Quit&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If a filesystem is resized with -f (online mode), then the system must be rebooted immediately after the change is made.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# resize2fs -f {{path|/dev/sda3}}&lt;br /&gt;
&amp;amp;num; reboot}}&lt;br /&gt;
&lt;br /&gt;
== Formatting partitions ==&lt;br /&gt;
&lt;br /&gt;
{{Warning|The {{Path|/dev/sdXY}} is only an example. Make sure you use the right partition name/number. Use {{ic|blkid}} command to verify the partition name/number. Choosing the wrong partition leads to data loss. If you are unsure, do not proceed, seek [[Alpine Linux:Support|support]].}}&lt;br /&gt;
&lt;br /&gt;
Whenever a partition is [[#Creating_partitions|created]], the partition must be formatted first before using it. Depending on the filesystem to be used, the necessary [[Filesystems#Filesystem_Tools|formatting tool]] for the filesystem must be installed first.&lt;br /&gt;
{{:Filesystems}}&lt;br /&gt;
&lt;br /&gt;
Install the [[Filesystems#Filesystem_Tools|filesystem tools]] first, if not done already. The following examples show how to use the formatting tools for different filesystems:&lt;br /&gt;
&lt;br /&gt;
* e2fsprogs for ext4,ext3 and ext2. ext4 is the default filesystem in Alpine Linux: {{Cmd|# mkfs.ext4 /dev/sdaXY}}&lt;br /&gt;
* btrfs-progs for [[btrfs]] filesystem. {{Cmd|# mkfs.btrfs /dev/sdaXY}}&lt;br /&gt;
* dosfstools for fat12/fat16/fat32 filesystem. This is also used for [[UEFI|EFI]] system partition(ESP). {{Cmd|# mkfs.vfat /dev/sdaXY}}&lt;br /&gt;
* f2fs-tools for [[F2FS]] filesystem. {{Cmd|# mkfs.f2fs /dev/sdaXY}}&lt;br /&gt;
&lt;br /&gt;
== Disk layouts ==&lt;br /&gt;
&lt;br /&gt;
It is possible to have one or more of [[#RAID|RAID]], [[#Encryption|encrypted]], and/or [[#LVM|Logical Volume]] on your {{Path|/}} (root) volume. However, the Alpine init script only knows how to handle them when they&#039;re layered in that order, and your initram and extlinux.conf files in the {{Path|/boot}} partition are configured properly.&lt;br /&gt;
&lt;br /&gt;
Your {{Path|/boot}} directory cannot reside on an encrypted or LVM volume, at least not with Alpine&#039;s default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or Logical Volumes.&lt;br /&gt;
&lt;br /&gt;
Sometimes {{Path|/boot}} is also set up as a mirrored (RAID1) volume. However, this is just for post-init access. That way, when you write a new kernel or bootloader config file to {{Path|/boot}}, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.&lt;br /&gt;
&lt;br /&gt;
A typical setup might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
One-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  rest of disk in second partition              |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  |  | cryptsetup volume                        |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  |  |  LVM PV, containing single VG,      | |  |&lt;br /&gt;
  |  |  |  containing multiple LVs, holding   | |  |&lt;br /&gt;
  |  |  |  /, /home, swap, etc                | |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |  |  small partition (32--100M), holding           | These 2 partitions might&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |  |  only /boot, filesystem needn&#039;t be journaled   | form a mirrored (RAID1)&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+ volume&lt;br /&gt;
  |  rest of disk in second partition              |  |  rest of disk in second partition              |&lt;br /&gt;
  | T================================================================================================T | These 2 partitions form&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T | a second mirrored&lt;br /&gt;
  | T | cryptsetup volume                                                                          | T | (RAID1) volume&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T |  | LVM PV, containing single VG,                                                         | | T |&lt;br /&gt;
  | T |  | containing multiple LVs, holding                                                      | | T |&lt;br /&gt;
  | T |  | /, /home, swap, etc                                                                   | | T |&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T |&lt;br /&gt;
  | T================================================================================================T |&lt;br /&gt;
  |                                                |  |                                                |&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might, in that case, be RAID5.&lt;br /&gt;
&lt;br /&gt;
=== RAID ===&lt;br /&gt;
{{Main|Setting up a software RAID array}}&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build a RAID array if you supply the &#039;&#039;&#039;-r&#039;&#039;&#039; switch, or if you specify more than one device.&lt;br /&gt;
&lt;br /&gt;
If you want to build your RAID array manually, see [[Setting up a software RAID array]]. Then you can add additional layers of encryption and/or Logical Volumes, or just assemble the RAID array, and supply the {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to disassemble the RAID array before rebooting.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using RAID, either because you gave it the &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt; switch, or multiple devices, or a {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device, then it will set up your initramfs and extlinux.conf file properly. However, in other cases, such as when you&#039;re also using encryption, or you invoke &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; with a mounted directory argument, these might not be properly set up for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=echo &amp;quot;/sbin/mdadm&amp;quot; &amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
echo &amp;quot;/etc/mdadm.conf&amp;quot; &amp;gt;&amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes raid (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure modules=... contains&lt;br /&gt;
&amp;amp;#35; raid1 or raid456 (whichever your / is on; this field is comma-separated)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --raid --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} to your disk&#039;s MBR.&lt;br /&gt;
&lt;br /&gt;
=== Encryption ===&lt;br /&gt;
{{Main|Setting up encrypted volumes with LUKS}}&lt;br /&gt;
&lt;br /&gt;
You can add an additional Logical Volume layer, or just unlock the volume you&#039;ve created (using &amp;lt;code&amp;gt;cryptsetup luksOpen ...&amp;lt;/code&amp;gt;), and supply the {{Path|/dev/mapper/&amp;lt;i&amp;gt;something&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to relock the volume (using &amp;lt;code&amp;gt;cryptsetup luksClose ...&amp;lt;/code&amp;gt;) before rebooting.&lt;br /&gt;
&lt;br /&gt;
If you install your {{Path|/}} (root) on an encrypted volume, you&#039;ll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into, that you&#039;ve created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named &amp;quot;crypt&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes cryptsetup (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
=== LVM ===&lt;br /&gt;
{{Main|Setting up Logical Volumes with LVM}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build and use volumes in a LVM group if you supply the &#039;&#039;&#039;-L&#039;&#039;&#039; switch.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then &amp;lt;code&amp;gt;vgchange -ay&amp;lt;/code&amp;gt;, format and mount your volumes, and supply the root mountpoint to [[setup-disk]]. When you&#039;re finished, be sure to&lt;br /&gt;
{{Cmd|umount ...&lt;br /&gt;
vgchange -an}}&lt;br /&gt;
before rebooting.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using LVM, perhaps because you gave it the &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; switch, then it will set up your initram and extlinux.conf file properly. However, in other cases, these might not be properly set up. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes lvm (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Refer to [[System_Disk_Mode#Troubleshooting|Troubleshooting]] page as most issues documented here earlier have been consolidated on that page. &lt;br /&gt;
 &lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.rodsbooks.com/gdisk/index.html Gdisk official website] &#039;&#039; walkthroughs available for gdisk,cgdisk and sgdisk&#039;&#039;&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=32184</id>
		<title>Setting up disks manually</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_disks_manually&amp;diff=32184"/>
		<updated>2026-03-26T04:41:14Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: cleaned up the introduction and added steps for Manual partitioning with a Note and Tip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Setting up disks manually involves creating or modifying partitions using partitioning tools and formatting them using various filesystem utilities to allow [[System Disk Mode]] or traditional HDD Installation of Alpine Linux at the end of [[Installation#Base configuration|base configuration step]] of installation. In addition to the above information, this page also documents various Disk layouts involving RAID, Encryption and LVM.&lt;br /&gt;
&lt;br /&gt;
{{Tip|The default [[Installation#setup-alpine based System Disk Install|System Disk]] installation requires and uses an entire HDD. If you intend to install Alpine Linux on a specific partition follow the [[System Disk Mode#setup-disk based Installation|setup-disk based installation page]].}}&lt;br /&gt;
&lt;br /&gt;
== Manual partitioning ==&lt;br /&gt;
&lt;br /&gt;
Creating partitions manually requires partitioning tool packages and formatting them requires appropriate filesystem utilities. Due to the minimal nature of Alpine Linux, the installation image environment may have only limited options. Depending on your requirements, install the necessary packages at the end of [[Installation#Base configuration|base configuration step]] of installation before proceeding further.&lt;br /&gt;
&lt;br /&gt;
{{Note|Some of the tools mentioned on this page may require working [[Configure_Networking#Connectivity_testing|Internet access]].}}&lt;br /&gt;
&lt;br /&gt;
* Create a partition using the available [[#Partitioning tools|Partitioning tools]]&lt;br /&gt;
* If MBR partition table is used, some partitioning tool may require manual steps to set up bootable flag.&lt;br /&gt;
* Once the necessary partition(s) have been created, do a reboot before proceeding further.&lt;br /&gt;
* [[#Formatting partitions|Format the partition]] using the appropriate tool based on the filesystem used. Some partition tools may format the partitions automatically.&lt;br /&gt;
&lt;br /&gt;
== Partitioning tools ==&lt;br /&gt;
&lt;br /&gt;
Only the basic busybox built-in &amp;lt;code&amp;gt;fdisk&amp;lt;/code&amp;gt; command available by default along with &amp;lt;code&amp;gt;sfdisk&amp;lt;/code&amp;gt;. Install any of the below listed partitioning tools immediately after setting up [[Installation#Base_configuration|base configuration]]. &lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;background:#333333; color:#ffffff; font-size: 1.2em; text-align:center;&amp;quot;&lt;br /&gt;
| width=&amp;quot;10%&amp;quot; |Command &lt;br /&gt;
|width=&amp;quot;15%&amp;quot; | Package name &lt;br /&gt;
|width=&amp;quot;40%&amp;quot;| Features &lt;br /&gt;
|           | Limitations&lt;br /&gt;
|-&lt;br /&gt;
| fdisk || Inbuilt {{pkg|busybox}} || can read GPT, Modify MBR || Cannot modify GPT&lt;br /&gt;
|-&lt;br /&gt;
| gdisk || {{pkg|gptfdisk}} || text mode, supports MBR/GPT bidirectional conversion, best for managing GPT partition tables|| None&lt;br /&gt;
|-&lt;br /&gt;
| cgdisk  || {{pkg|gptfdisk}}  || menu driven curses interface for gdisk || None&lt;br /&gt;
|-&lt;br /&gt;
| sgdisk || {{pkg|sgdisk}} || scriptable gdisk || Non-interactive&lt;br /&gt;
|-&lt;br /&gt;
| fdisk || {{pkg|util-linux-misc}} || text mode, supports both gpt and MBR, best for managing MBR partition tables || None except size due to other tools&lt;br /&gt;
|-&lt;br /&gt;
| cfdisk || {{pkg|cfdisk}} || menu driven curses interface for fdisk || None&lt;br /&gt;
|-&lt;br /&gt;
| sfdisk || {{pkg|sfdisk}} || scriptable fdisk || Non-interactive&lt;br /&gt;
|-&lt;br /&gt;
| parted || {{pkg|parted}} || text mode, supports both gpt and MBR|| cannot convert MBR to GPT, different interface from above tools&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphical tools like {{pkg|gparted}} and {{pkg|gnome-disk-utility}} can be used only after [[Installation#Post-Installation|setting up a graphical environment]].&lt;br /&gt;
&lt;br /&gt;
== Creating partitions ==&lt;br /&gt;
&lt;br /&gt;
For Alpine Linux, only the &#039;&#039;&#039;(/)&#039;&#039;&#039;root partition is mandatory. Even  a &#039;&#039;&#039;/boot&#039;&#039;&#039; partition and  &#039;&#039;&#039;swap&#039;&#039;&#039; are optional.&lt;br /&gt;
&lt;br /&gt;
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}&lt;br /&gt;
{{ic|cfdisk}} will be used in all examples here as it is based on text menu without any dependencies. However, installing the {{Pkg|cfdisk}} package requires network to be available if using Standard ISO boot image. Alternately, {{Pkg|&amp;lt;code&amp;gt;sfdisk&amp;lt;/code&amp;gt;}} can be installed without network. &lt;br /&gt;
&lt;br /&gt;
{{Tip|Use {{ic|cgdisk}} from {{Pkg|gptfdisk}} package for GPT partitions and for conversion from MBR to GPT.}}&lt;br /&gt;
&lt;br /&gt;
The following step installs the {{Pkg|cfdisk}} package: {{cmd|# apk add cfdisk }}&lt;br /&gt;
&lt;br /&gt;
Before using {{ic|cfdisk}} to create partitions, the disk name must be identified by using {{ic|blkid}}:{{cmd|# blkid}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/dev/sdX1: LABEL=&amp;quot;some&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;vfat&amp;quot;&lt;br /&gt;
/dev/sdX2: LABEL=&amp;quot;other&amp;quot; UUID=&amp;quot;...&amp;quot; TYPE=&amp;quot;ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When {{ic|cfdisk}} is run as follows, it looks for existing partitions on the disk {{Path|/dev/sdX}}: {{cmd|# cfdisk /dev/sdX}}&lt;br /&gt;
&lt;br /&gt;
== Resizing an existing partition ==&lt;br /&gt;
{{Warning|Make sure to choose the correct disk device in the below section. If you choose the wrong device, you will lose your data. Make a backup first and do not proceed, if you are unsure.}}&lt;br /&gt;
&lt;br /&gt;
{{ic|cfdisk}} and {{ic|resize2fs}} from {{pkg|e2fsprogs-extra}} package can be used to resize existing partitions of ext2/3/4 filsystem on the disk. For other filsystems, the necessary [[Filesystems#Filesystem_Tools|filesystem tools]] must be installed. This can be done while booted. &lt;br /&gt;
&lt;br /&gt;
[[File:Cfdisk screenshot alpine 2024-03-04 143916.png|thumb|cfdisk screenshot ]]&lt;br /&gt;
&lt;br /&gt;
To resize disk, launch the {{ic|cfdisk}}: {{cmd|# cfdisk {{path|/dev/sda}}}}&lt;br /&gt;
&lt;br /&gt;
# Select the target partition, here as per image {{path|/dev/sda3}}&lt;br /&gt;
# Select &#039;&#039;Resize&#039;&#039; from the bottom menu.&lt;br /&gt;
# Enter the new &#039;&#039;Size&#039;&#039; at the prompt.&lt;br /&gt;
# Select &#039;&#039;Write&#039;&#039;, then &#039;&#039;Quit&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If a filesystem is resized with -f (online mode), then the system must be rebooted immediately after the change is made.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# resize2fs -f {{path|/dev/sda3}}&lt;br /&gt;
&amp;amp;num; reboot}}&lt;br /&gt;
&lt;br /&gt;
== Formatting partitions ==&lt;br /&gt;
&lt;br /&gt;
{{Warning|The {{Path|/dev/sdXY}} is only an example. Make sure you use the right partition name/number. Use {{ic|blkid}} command to verify the partition name/number. Choosing the wrong partition leads to data loss. If you are unsure, do not proceed, seek [[Alpine Linux:Support|support]].}}&lt;br /&gt;
&lt;br /&gt;
Whenever a partition is [[#Creating_partitions|created]], the partition must be formatted first before using it. Depending on the filesystem to be used, the necessary [[Filesystems#Filesystem_Tools|formatting tool]] for the filesystem must be installed first.&lt;br /&gt;
{{:Filesystems}}&lt;br /&gt;
&lt;br /&gt;
Install the [[Filesystems#Filesystem_Tools|filesystem tools]] first, if not done already. The following examples show how to use the formatting tools for different filesystems:&lt;br /&gt;
&lt;br /&gt;
* e2fsprogs for ext4,ext3 and ext2. ext4 is the default filesystem in Alpine Linux: {{Cmd|# mkfs.ext4 /dev/sdaXY}}&lt;br /&gt;
* btrfs-progs for [[btrfs]] filesystem. {{Cmd|# mkfs.btrfs /dev/sdaXY}}&lt;br /&gt;
* dosfstools for fat12/fat16/fat32 filesystem. This is also used for [[UEFI|EFI]] system partition(ESP). {{Cmd|# mkfs.vfat /dev/sdaXY}}&lt;br /&gt;
* f2fs-tools for [[F2FS]] filesystem. {{Cmd|# mkfs.f2fs /dev/sdaXY}}&lt;br /&gt;
&lt;br /&gt;
== Disk layouts ==&lt;br /&gt;
&lt;br /&gt;
It is possible to have one or more of [[#RAID|RAID]], [[#Encryption|encrypted]], and/or [[#LVM|Logical Volume]] on your {{Path|/}} (root) volume. However, the Alpine init script only knows how to handle them when they&#039;re layered in that order, and your initram and extlinux.conf files in the {{Path|/boot}} partition are configured properly.&lt;br /&gt;
&lt;br /&gt;
Your {{Path|/boot}} directory cannot reside on an encrypted or LVM volume, at least not with Alpine&#039;s default bootloader (extlinux). (Grub2 can deal with {{Path|/boot}} being on an LVM volume.) The usual practice is to create a small partition for {{Path|/boot}}, then devote the rest of your disk to a separate partition on which you layer one or more of RAID, encryption, and/or Logical Volumes.&lt;br /&gt;
&lt;br /&gt;
Sometimes {{Path|/boot}} is also set up as a mirrored (RAID1) volume. However, this is just for post-init access. That way, when you write a new kernel or bootloader config file to {{Path|/boot}}, it gets written to multiple physical partitions. During the pre-init, bootloader phase, only one of those partitions will be read from.&lt;br /&gt;
&lt;br /&gt;
A typical setup might look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
One-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
  |  rest of disk in second partition              |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  |  | cryptsetup volume                        |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  |  |  LVM PV, containing single VG,      | |  |&lt;br /&gt;
  |  |  |  containing multiple LVs, holding   | |  |&lt;br /&gt;
  |  |  |  /, /home, swap, etc                | |  |&lt;br /&gt;
  |  |  +-------------------------------------+ |  |&lt;br /&gt;
  |  +------------------------------------------+  |&lt;br /&gt;
  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two-disk system&lt;br /&gt;
---------------&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
  |  small partition (32--100M), holding           |  |  small partition (32--100M), holding           | These 2 partitions might&lt;br /&gt;
  |  only /boot, filesystem needn&#039;t be journaled   |  |  only /boot, filesystem needn&#039;t be journaled   | form a mirrored (RAID1)&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+ volume&lt;br /&gt;
  |  rest of disk in second partition              |  |  rest of disk in second partition              |&lt;br /&gt;
  | T================================================================================================T | These 2 partitions form&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T | a second mirrored&lt;br /&gt;
  | T | cryptsetup volume                                                                          | T | (RAID1) volume&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T |  | LVM PV, containing single VG,                                                         | | T |&lt;br /&gt;
  | T |  | containing multiple LVs, holding                                                      | | T |&lt;br /&gt;
  | T |  | /, /home, swap, etc                                                                   | | T |&lt;br /&gt;
  | T |  +---------------------------------------------------------------------------------------+ | T |&lt;br /&gt;
  | T +--------------------------------------------------------------------------------------------+ T |&lt;br /&gt;
  | T================================================================================================T |&lt;br /&gt;
  |                                                |  |                                                |&lt;br /&gt;
  +------------------------------------------------+  +------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In a three-disk system, the {{Path|/boot}} would still be RAID1, but the larger partition might, in that case, be RAID5.&lt;br /&gt;
&lt;br /&gt;
=== RAID ===&lt;br /&gt;
{{Main|Setting up a software RAID array}}&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build a RAID array if you supply the &#039;&#039;&#039;-r&#039;&#039;&#039; switch, or if you specify more than one device.&lt;br /&gt;
&lt;br /&gt;
If you want to build your RAID array manually, see [[Setting up a software RAID array]]. Then you can add additional layers of encryption and/or Logical Volumes, or just assemble the RAID array, and supply the {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to disassemble the RAID array before rebooting.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using RAID, either because you gave it the &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt; switch, or multiple devices, or a {{Path|/dev/md&amp;lt;i&amp;gt;i&amp;lt;/i&amp;gt;}} device, then it will set up your initramfs and extlinux.conf file properly. However, in other cases, such as when you&#039;re also using encryption, or you invoke &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; with a mounted directory argument, these might not be properly set up for RAID. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=echo &amp;quot;/sbin/mdadm&amp;quot; &amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
echo &amp;quot;/etc/mdadm.conf&amp;quot; &amp;gt;&amp;gt; $MNT/etc/mkinitfs/files.d/raid&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes raid (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure modules=... contains&lt;br /&gt;
&amp;amp;#35; raid1 or raid456 (whichever your / is on; this field is comma-separated)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --raid --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}. And you might need to copy {{Path|/usr/share/syslinux/mbr.bin}} to your disk&#039;s MBR.&lt;br /&gt;
&lt;br /&gt;
=== Encryption ===&lt;br /&gt;
{{Main|Setting up encrypted volumes with LUKS}}&lt;br /&gt;
&lt;br /&gt;
You can add an additional Logical Volume layer, or just unlock the volume you&#039;ve created (using &amp;lt;code&amp;gt;cryptsetup luksOpen ...&amp;lt;/code&amp;gt;), and supply the {{Path|/dev/mapper/&amp;lt;i&amp;gt;something&amp;lt;/i&amp;gt;}} device directly to [[setup-disk]]. When you&#039;re finished, be sure to relock the volume (using &amp;lt;code&amp;gt;cryptsetup luksClose ...&amp;lt;/code&amp;gt;) before rebooting.&lt;br /&gt;
&lt;br /&gt;
If you install your {{Path|/}} (root) on an encrypted volume, you&#039;ll need to manually edit/rebuild your initram and your extlinux.conf file. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into, that you&#039;ve created the cryptvolume on the device {{Path|/dev/md2}}, and that you want to unlock the encrypted volume into a virtual volume named &amp;quot;crypt&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes cryptsetup (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure default_kernel_opts=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; contains cryptroot=/dev/md1 and cryptdm=crypt (this field is also space-separated and quoted)&lt;br /&gt;
&amp;amp;#35; also check the root= setting&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
=== LVM ===&lt;br /&gt;
{{Main|Setting up Logical Volumes with LVM}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will automatically build and use volumes in a LVM group if you supply the &#039;&#039;&#039;-L&#039;&#039;&#039; switch.&lt;br /&gt;
&lt;br /&gt;
If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then &amp;lt;code&amp;gt;vgchange -ay&amp;lt;/code&amp;gt;, format and mount your volumes, and supply the root mountpoint to [[setup-disk]]. When you&#039;re finished, be sure to&lt;br /&gt;
{{Cmd|umount ...&lt;br /&gt;
vgchange -an}}&lt;br /&gt;
before rebooting.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; sees that you&#039;re using LVM, perhaps because you gave it the &amp;lt;code&amp;gt;-L&amp;lt;/code&amp;gt; switch, then it will set up your initram and extlinux.conf file properly. However, in other cases, these might not be properly set up. In that case, you may need to manually edit/rebuild them. The following assumes that &amp;lt;code&amp;gt;$MNT&amp;lt;/code&amp;gt; holds the root directory you&#039;re installing into:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|1=&amp;amp;#35; edit $MNT/etc/mkinitfs/mkinitfs.conf to make sure features=&amp;quot;...&amp;quot;&lt;br /&gt;
&amp;amp;#35; includes lvm (this field is space-separated and quoted)&lt;br /&gt;
mkinitfs -c $MNT/etc/mkinitfs/mkinitfs.conf -b $MNT&lt;br /&gt;
&amp;amp;#35; edit $MNT/etc/update-extlinux.conf to make sure root= is set correctly&lt;br /&gt;
extlinux --install $MNT/boot --update&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
You might also need to manually tweak {{Path|$MNT/etc/fstab}}.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [https://www.rodsbooks.com/gdisk/index.html Gdisk official website] &#039;&#039; walkthroughs available for gdisk,cgdisk and sgdisk&#039;&#039;&lt;br /&gt;
[[Category:Storage]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:OpenRC&amp;diff=32173</id>
		<title>Talk:OpenRC</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:OpenRC&amp;diff=32173"/>
		<updated>2026-03-24T16:46:15Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: /* User Services -&amp;gt; Runlevels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [https://wiki.alpinelinux.org/wiki/OpenRC#Preventing_slow_services_from_delaying_boot Preventing slow services from delaying boot] passage currently uses &#039;&#039;&#039;chronyd&#039;&#039;&#039; as an example of a service that may delay boot.  The passage could be improved:-&lt;br /&gt;
&lt;br /&gt;
1. There is another, simpler and safer method to prevent a slow startup by &#039;&#039;&#039;chronyd&#039;&#039;&#039; that could be listed first and avoids dealing with the expressed danger of editing {{Path|/etc/inittab}} wrongly and its implied stunting of system boot. &lt;br /&gt;
&lt;br /&gt;
The method has been suggested helpfully in various places:&lt;br /&gt;
* In the second paragraph of the file to be edited:  {{Path|/etc/conf.d/chronyd}}&lt;br /&gt;
* https://whynothugo.nl/journal/2023/11/19/setting-up-an-alpine-linux-workstation/#chronyd-blocks-at-startup&lt;br /&gt;
* https://gist.github.com/c0m4r/e38d41d0e31f6adda4b4c5a88ba0a453#NTP&lt;br /&gt;
 &lt;br /&gt;
The method is to edit {{Path|/etc/conf.d/chronyd}} and to change the line {{Codeline|1=FAST_STARTUP=no}} to {{Codeline|1=FAST_STARTUP=yes}}.&lt;br /&gt;
&lt;br /&gt;
2. Technically, &#039;&#039;&#039;chronyd&#039;&#039;&#039; is not a boot service but rather launches at the default level ({{Codeline|rc-update add chronyd default}}), so the subheading may need to be improved.  There is [https://wiki.alpinelinux.org/w/index.php?search=%22%5B%5B%23Preventing+slow+services+from+delaying+boot%7C%22&amp;amp;title=Special%3ASearch&amp;amp;profile=default&amp;amp;fulltext=1 only one wiki page] that links to that subheading, and it is in this very same OpenRC wiki page, so it should be easy to change the subheading title, say, from &#039;&#039;&amp;quot;Preventing slow services from delaying boot&amp;quot;&#039;&#039; to &#039;&#039;&amp;quot;Preventing slow services from delaying system launch&amp;quot;&#039;&#039; or &#039;&#039;...system startup&#039;&#039;.   The link is mentioned twice in this wiki page, so those passages could be reviewed:&lt;br /&gt;
* https://wiki.alpinelinux.org/wiki/OpenRC#Stacked_runlevels&lt;br /&gt;
* https://wiki.alpinelinux.org/wiki/OpenRC#Configuration&lt;br /&gt;
&lt;br /&gt;
Alternatively, an &#039;&#039;Include:Chronyd - Startup Speed Enhancement&#039;&#039; page could be started for inclusion here and wherever else (Any future &#039;&#039;Chrony&#039;&#039; page, for example) that would include the current inittab method and the FAST_STARTUP method.&lt;br /&gt;
[[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 16:21, 8 August 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
:Please note also that the external link about the {{Path|inittab}} method, [https://ptrcnull.me/posts/openrc-async-services/ OpenRC: Start services after login prompt], is now broken.  Please consider whether perhaps the reference/attribution is suitable, as it stands. [[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 16:33, 8 August 2025 (UTC) &lt;br /&gt;
:[[User:John3-16|John3-16]] ([[User talk:John3-16|talk]])&lt;br /&gt;
&lt;br /&gt;
:: Thanks for submitting a thorough feedback. Highly appreciated. I have fixed the external links and internal links and updated section heading as per your suggestion. Service &#039;&#039;&#039;chrony&#039;&#039;&#039; was meant to be example to explain the concept. For now i&#039;ve removed the word chrony. Regarding adding {{Codeline|1=FAST_STARTUP=yes}} to Chrony page, i&#039;m quite hesitant to touch pages where i lack knowledge. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 20:02, 8 August 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
The below Note may add confusion to users. Please consider rewording or removal. &lt;br /&gt;
{{Note|The upstream OpenRC User Guide for user services considers [https://github.com/OpenRC/openrc/blob/master/user-guide.md#auto-starting configuring  pam] in the management of user service sessions;  as an experimental branch of OpenRC, this facility, including its autostart configuration, may be fluid.  Many Alpine Linux installations typically may not run pam.}}&lt;br /&gt;
* The experimental is already there &amp;quot;User services are currently experimental &amp;quot;. If necessary that can be &#039;&#039;&#039;highlighted&#039;&#039;&#039;.&lt;br /&gt;
* I request a rewording to tell user on what he&#039;s supposed to do for pam. In the current form, the Note does not help the user on how to proceed.&lt;br /&gt;
- [[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 11:03, 11 August 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
::- Thank you for your kind attention on the wiki. I have tried to address your concern by removing the note plus the reference to it under [[OpenRC#PAM_support|PAM support]] instead of elaborating on the upstream OpenRC configuration user guide passage regarding pam. &lt;br /&gt;
 &lt;br /&gt;
::- On a different topic, while hoping to keep the wiki a clear user guide, do we want to simultaneously reference more in-depth examinations about user services that may be significant to developers? For example, consider a possible closing passage under &#039;&#039;User Services&#039;&#039;, or under a new &#039;&#039;Further reading&#039;&#039; section, or perhaps in a briefer form under &#039;&#039;See also&#039;&#039;:  &lt;br /&gt;
&lt;br /&gt;
:::&#039;For a more in-depth examination of OpenRC user services, consider useful discussions regarding DE-dependent (&#039;&#039;desktop environment&#039;&#039;) vs DE-independent environment variables discussed in an [https://github.com/OpenRC/openrc/pull/723 upstream thread] about user services, and whether the variables ought to be passed on filtered (not in whole) or not.  Other useful assessments were laid out in an excellent though now [https://wiki.gentoo.org/wiki/OpenRC/Legacy_user_services outdated Gentoo wiki page] about legacy user services that furthermore had examined {{pkg|wlsunset}} when used as a user service in Wayland;  their current [https://wiki.gentoo.org/wiki/OpenRC#User_services User Services page] adds further useful and more up-to-date contributions.&#039;  &lt;br /&gt;
&lt;br /&gt;
::This passage could be left here for any further discussion or added to the wiki with or without any edits, as may be seen to be suitable;  I am grateful either way.&lt;br /&gt;
 &lt;br /&gt;
::- Perhaps one should consider moving the paragraph about allowing parallel services into the section &#039;&#039;&#039;Preventing slow services from delaying system startup&#039;&#039;&#039;, as a subheading called &amp;quot;Parallel services&amp;quot;.  It could be placed after the introductory paragraph, &amp;quot;Services that take a while to start will block ...&amp;quot;.  This &#039;&#039;parallel services&#039;&#039; passage is not immediately relevant in its current location as the second paragraph about OpenRC configuration.  It may simply appear there from early days in the preparation of the page.&lt;br /&gt;
&lt;br /&gt;
::The suggestion that currently appears there could then be listed as a second subheading (after the &amp;quot;Parallel services&amp;quot; subheading suggested above), to be titled, say, &amp;quot;Async runlevel method&amp;quot;, &amp;quot;Stacked runlevel method&amp;quot;, &amp;quot;Inittab method&amp;quot; or as suitable.&lt;br /&gt;
&lt;br /&gt;
::- Are we satisfied to keep the [[OpenRC#Command_usage|Command usage]] section where it is, deep down on this page, or would it be more pertinent to give command usage examples nearer to the introductory section of the wiki page, perhaps at the beginning of [OpenRC#Quickstart|Quickstart] table or immediately after it (retaining the &#039;&#039;Command usage&#039;&#039; subheading or not)?  Perhaps this &#039;&#039;Command usage&#039;&#039; passage has suffered displacement from newer passages.&lt;br /&gt;
&lt;br /&gt;
::This passage could additionally illustrate the most commonly used OpenRC commands at the beginning of the Quickstart section with a handful of complete {{ic|rc-service}} and {{ic|rc-update}} command line instructions;  otherwise, full examples of common OpenRC clis first appear in the disproportionally long &#039;&#039;User Services&#039;&#039; section, and  OpenRC instructions are otherwise introduced quickly, with no complete cli example, in the current &#039;&#039;QuickStart&#039;&#039; table:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Commonly-used OpenRC commands&#039;&#039;&#039;&lt;br /&gt;
Start, stop (or {ic|restart}}) a service, for example, at the boot runlevel (do not use employ the &#039;&amp;lt;&#039; nor &#039;&amp;gt;&#039;):&lt;br /&gt;
{{cmd|doas rc-service &amp;lt;serviceName&amp;gt; start boot}}&lt;br /&gt;
{{cmd|doas rc-service &amp;lt;serviceName&amp;gt; stop boot}}&lt;br /&gt;
Add or delete a service to/from the sequence of services that need to start automatically in future sessions at the {{ic|default}} runlevel;  note that the &#039;&#039;&#039;default&#039;&#039;&#039; runlevel is assumed, so it does not need to be stated explicitly:&lt;br /&gt;
{{cmd|doas rc-update add &amp;lt;serviceName&amp;gt; default}}&lt;br /&gt;
{{cmd|doas rc-update del &amp;lt;serviceName&amp;gt;}}&lt;br /&gt;
List the current statuses of all services;  however, do not use {{ic|doas}} nor the equivalent command as root to display the statuses of any &#039;&#039;user service&#039;&#039;:&lt;br /&gt;
{{cmd|doas rc-status}}&lt;br /&gt;
List the assigned runlevels of all services;  likewise, do not use {{ic|doas}} nor root to display the runlevels of user services:&lt;br /&gt;
{{cmd|doas rc-update}}&lt;br /&gt;
&lt;br /&gt;
::Alternatively, the above &#039;&#039;Commonly-used OpenRC commands&#039;&#039; passage, with or without any edits as may be seen to be suitable, could simply not be included.&lt;br /&gt;
&lt;br /&gt;
::-  The current passage in [[OpenRC#Command_usage|Command usage]], &amp;quot;To view the command usage for all OpenRC commands (rc-update, rc-service, rc-status, openrc etc.) use the --help or -h flag [...]&amp;quot; could be moved into the Quickstart section instead of leaving it near the end of the page.&lt;br /&gt;
&lt;br /&gt;
::- The &#039;&#039;Command usage&#039;&#039; section further contains a paragraph that is irrelevant to OpenRC: &#039;The busybox command equivalent for traditional GNU/Linux systems is as follows [...]&#039;.  This paragraph would be more relevant, if at all, for example:-&lt;br /&gt;
::* In the [[BusyBox]] page, if suitable;  or&lt;br /&gt;
::* In the [[Comparison_with_other_distros &#039;Rosetta Stone&#039;]] page, perhaps under a new heading there, say, &#039;&#039;Userspace commands&#039;&#039; or &#039;&#039;Command line instructions&#039;&#039;, seeing how, currently, there are only sections for &#039;&#039;Package management&#039;&#039;, &#039;&#039;Runlevel &amp;amp; Initscripts&#039;&#039; and &#039;&#039;Config files&#039;&#039;; or &lt;br /&gt;
::* Being culled from this page.&lt;br /&gt;
&lt;br /&gt;
::Thank you. [[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 21:44, 11 August 2025 (UTC)&lt;br /&gt;
::: Thanks once again for the detailed suggestions. Hope i&#039;ve done everything as suggested. Please make necessary amends, if i have missed out something. Highly appreciated. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 10:03, 12 August 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Warning in PAM support ==&lt;br /&gt;
&lt;br /&gt;
Dear [[User:WhyNotHugo]], I&#039;m not sure about the need for warning in the PAM support section. I have been using User services with PAM support for the past few months without any issues and i have not seen any bug reports filed regarding this. btw:i&#039;m using pamrundir and i tested dwm with the manual XDG_RUNTIME_DIR script as added there. I believe Warning should be sparingly used in Wiki, if there are unresolved/known issues. - [[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 15:59, 5 September 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
:[[User:Prabuanand]] This was solved shortly after your comment, thanks. Feel free to remove this talk subsection. [[User:WhyNotHugo|WhyNotHugo]] ([[User talk:WhyNotHugo|talk]]) 16:32, 24 March 2026 (UTC)&lt;br /&gt;
&lt;br /&gt;
== User Services -&amp;gt; Runlevels ==&lt;br /&gt;
&lt;br /&gt;
Dear [[User:WhyNotHugo]], This section probably requires some rewriting.&lt;br /&gt;
* I&#039;m not sure when this sysinit runlevel is used/required &amp;quot;mkdir -p ${XDG_CONFIG_HOME:-~/.config}/rc/runlevels/sysinit&amp;quot;.&lt;br /&gt;
* in the command openrc -U $RUNLEVEL. Instead of $RUNLEVEL, consider using &amp;lt;&amp;gt; as [[Help:Reading#Placeholder|placeholder]].&lt;br /&gt;
* Will adding &amp;quot;exec openrc -U gui&amp;quot; to ~/.profile support both Wayland and Xorg? Shouldn&#039;t the Compositor startup file be used for this for wayland?  --[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 16:13, 5 September 2025 (UTC)&lt;br /&gt;
:I just now tested adding &amp;quot;exec openrc -U gui&amp;quot; to ~/.profile and i got locked out with &amp;quot;XDG_RUNTIME_DIR unset&amp;quot;. Only after removing this, i could login to tty. Sway too did not start with this option. Here are my [git.sr.ht:~prabuanand/dotfiles dotfiles] for reference. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 16:55, 5 September 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
::[[User:Prabuanand]]: Using &#039;&#039;&#039;exec openrc -U gui&#039;&#039;&#039; in &#039;&#039;&#039;~/.profile&#039;&#039;&#039; would be too early, DISPLAY or WAYLAND_DISPLAY would not be set, and services which rely on those would fail to start. We might want to clarify this explicitly. XDG_RUNTIME_DIR needs to be set before any service that relies on it (including the compositor) [[User:WhyNotHugo|WhyNotHugo]] ([[User talk:WhyNotHugo|talk]]) 16:37, 24 March 2026 (UTC)&lt;br /&gt;
:::Dear [[User:WhyNotHugo]], i think this entire paragraph is entirely not needed.  The old instructions https://wiki.alpinelinux.org/w/index.php?title=OpenRC&amp;amp;oldid=30771#User_services was guaranteed to work. When you added this paragraph, i tested it once, found it to be not working in my setup. Since i don&#039;t use .profile and zsh/bash, i did not want to remove it myself. - [[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 16:46, 24 March 2026 (UTC) &lt;br /&gt;
::Dear [[User:WhyNotHugo]], Thank you for your excellent contributions to Linux, and to Alpine Linux in particular. I support [[User:Prabuanand|Prabuanand]]&#039;s excellent and extensive impressions/observations above however, including those further above in the &#039;Warning in PAM support&#039; discussion.  I would be grateful for your input about them. &lt;br /&gt;
&lt;br /&gt;
::Additionally, I suspect that two further points of guidance in your edits warrant review or elaboration on the wiki page:- &lt;br /&gt;
::*Your claim that &#039;&#039;&#039;sysinit&#039;&#039;&#039; is the default level;  please elaborate why &#039;&#039;&#039;default&#039;&#039;&#039; would not be the default runlevel here, for my better understanding and for the sake of newcomers to Alpine Linux&#039;s wiki.  &lt;br /&gt;
::*Note also that your instruction did not revert the runlevel back to &#039;&#039;&#039;sysinit&#039;&#039;&#039; on my system, even with the user (&#039;&#039;&#039;-U &#039;&#039;&#039;) switch:  {{Cmd|$ openrc -U}}&lt;br /&gt;
::*Your edit proposing a command to revert to the sysinit runlevel appears to run contrary to the guidance [[OpenRC#Runlevels|currently in the wiki]], that &#039;&#039;&amp;quot;sysinit always runs when the host first starts and should not be run again.&amp;quot;&#039;&#039;&lt;br /&gt;
::Thanks again for your help addressing our concerns. [[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 17:43, 12 September 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
:::&#039;&#039;&#039;sysinit&#039;&#039;&#039; is used by default when you don&#039;t explicitly specify another runlevel. My statement describes the behaviour of OpenRC itself, it&#039;s not my decision. I&#039;ve talked to navi about it, and it seems to not be intentional, but it&#039;s still the current behaviour. [[User:WhyNotHugo|WhyNotHugo]] ([[User talk:WhyNotHugo|talk]]) 16:37, 24 March 2026 (UTC)&lt;br /&gt;
&lt;br /&gt;
Dear [[User:StruanR]],  &lt;br /&gt;
I am grateful for your improvements of the wiki, kindly continue them!  Please note that certain edits, however, changing a root prompt to a user prompt, were in various cases inaccurate, and I have reverted those.  Perhaps the wiki could be made clearer that to modify &#039;&#039;system&#039;&#039; services or runlevels, one generally requires a root prompt or doas/sudo;  to display/check those, a user prompt may suffice.  Note, on the other hand, that to modify &#039;&#039;user&#039;&#039; services (using the &#039;&#039;&#039;-U&#039;&#039;&#039; switch), a root prompt or doas/sudo would not generally be used.  I hope this helps.&lt;br /&gt;
Your other edits were helpful, thank you!  &lt;br /&gt;
I took the chance to amend some previous passages made by other helpful contributors while I was at it.  Please continue helping out with the wiki! [[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 17:43, 12 September 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: +1, we should have a dedicated page for OpenRC User services. [[User:WhyNotHugo|WhyNotHugo]] ([[User talk:WhyNotHugo|talk]]) 16:37, 24 March 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Software_management&amp;diff=32153</id>
		<title>Software management</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Software_management&amp;diff=32153"/>
		<updated>2026-03-14T10:14:22Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: made changes to various sections to improve the readability. added wikitags like Todo and Tips&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents various ways to [[#Running glibc programs|run software compiled with glibc]] and to manage software using [[#Graphical software manager|graphical software managers]] in Alpine Linux. There are pages elsewhere regarding compiling [[Compile software from source|software from source]] and for creating a [[Custom Kernel|custom kernel]].&lt;br /&gt;
&lt;br /&gt;
== Alpine package keeper ==&lt;br /&gt;
{{Main|Alpine Package Keeper}}&lt;br /&gt;
The official package manager in Alpine Linux, [[Alpine Package Keeper|Alpine Package Keeper(apk)]], is a &#039;&#039;cli&#039;&#039; tool. [[Comparison_with_other_distros#Comparison_chart/Rosetta_Stone|Rosetta stone]] shows how standard package management tasks are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Graphical software manager ==&lt;br /&gt;
&lt;br /&gt;
The following graphical tools are available to manage official software packages from Alpine Linux [[Repositories|repositories]] and [[#Flatpak|flatpaks]] instead of using the [[#Alpine Package Keeper|cli-based apk tool]].&lt;br /&gt;
&lt;br /&gt;
=== GNOME software ===&lt;br /&gt;
&lt;br /&gt;
[[GNOME#Configuration|GNOME software]] can be used as a GUI front end for apk to manage official software packages and flatpaks.&lt;br /&gt;
&lt;br /&gt;
=== KDE Discover ===&lt;br /&gt;
&lt;br /&gt;
[[KDE#Discover|KDE Discover]] can be used as a GUI front end for apk to manage official software packages and flatpaks.&lt;br /&gt;
&lt;br /&gt;
== Flatpak ==&lt;br /&gt;
{{Main|Flatpak}}&lt;br /&gt;
&lt;br /&gt;
[[Flatpak#Installing_Flatpak|Flatpaks]] are by far the easiest method for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. To use flatpaks, ensure that the [[Flatpak#Installing_Flatpak|Flathub repository]] is enabled.&lt;br /&gt;
&lt;br /&gt;
== AppImage ==&lt;br /&gt;
{{Main|AppImage}}&lt;br /&gt;
&lt;br /&gt;
[[AppImage|AppImages]] are another alternative to [[Flatpak|flatpaks]] for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. However, not as many AppImages work on Alpine Linux as compared to Flatpaks, since AppImages are more commonly built for glibc operating systems, as opposed to Alpine Linux&#039;s use of musl.&lt;br /&gt;
Refer to the [[AppImage]] page for prerequisites and for detailed instructions to run AppImages in Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
== Coldbrew ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Coldbrew&#039;&#039;&#039; is a package manager that can install Alpine Linux aports Edge packages without needing root access, somewhat similar to &#039;&#039;&#039;brew&#039;&#039;&#039;.  This is particularly useful on immutable operating systems such as with [https://postmarketos.org/blog/2025/10/12/pmOS-update-2025-09/#immutable-postmarketos PostmarketOS&#039;s duranium image].  &#039;&#039;&#039;Coldbrew&#039;&#039;&#039; is available in Alpine Linux Edge testing repository as of January 2026;  the testing repository is [[Repositories#Using_testing_repository|recommended to be tagged]] if installing &#039;&#039;&#039;coldbrew&#039;&#039;&#039; on any supported Alpine Linux release.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Coldbrew&#039;&#039;&#039; replaces the [https://github.com/kcxt/iced &#039;&#039;&#039;iced&#039;&#039;&#039;] package on Alpine Linux, which used the {{Pkg|mkosi-sandbox}};   packages run inside a chroot using &#039;&#039;&#039;bubblewrap&#039;&#039;&#039; instead.  They have access to the home directory, but have only controlled access to all other files through explicit bind mounts.  Packages installed using &#039;&#039;&#039;coldbrew&#039;&#039;&#039; are referred to as tools.  See [https://gitlab.postmarketos.org/postmarketOS/coldbrew further details upstream].&lt;br /&gt;
&lt;br /&gt;
To install &#039;&#039;&#039;coldbrew&#039;&#039;&#039;:&lt;br /&gt;
{{Cmd|$ doas apk add coldbrew@testing}}&lt;br /&gt;
&lt;br /&gt;
To install a tool to be run by &#039;&#039;&#039;coldbrew&#039;&#039;&#039;, say, {{Pkg|corepad}}:&lt;br /&gt;
{{Cmd|$ coldbrew install corepad}}&lt;br /&gt;
&lt;br /&gt;
Note that even though the output ends...&lt;br /&gt;
&lt;br /&gt;
 Installed binary /usr/bin/corepad&lt;br /&gt;
&lt;br /&gt;
...the path being referred to exists within a new mount namespace using bind mounts in the &#039;&#039;&#039;bubblewrap&#039;&#039;&#039; sandbox.&lt;br /&gt;
&lt;br /&gt;
A wrapper program is installed to {{Path|~/.local/bin}} on Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
To run the tool under &#039;&#039;&#039;coldbrew&#039;&#039;&#039;:&lt;br /&gt;
{{Cmd|$ coldbrew run corepad}}&lt;br /&gt;
&lt;br /&gt;
To remove the tool:&lt;br /&gt;
{{Cmd|$ coldbrew remove corepad}}&lt;br /&gt;
&lt;br /&gt;
All installed tools can be listed through the {{ic|$ coldbrew ls}} command.&lt;br /&gt;
&lt;br /&gt;
== Running glibc programs ==&lt;br /&gt;
&lt;br /&gt;
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. &lt;br /&gt;
&lt;br /&gt;
For simpler binaries, you can install [[#gcompat|gcompat]], which is a compatibility layer;  or you could do it the easy way and use [[#Flatpak|Flatpaks]] or [[#AppImage|AppImages]]. See [[#Containers|containers]] or the [[#Chroot|chroot]] section for ways to run glibc programs, including graphical ones such as {{ic|VSCode}}, {{ic|google-chrome}}, {{ic|obsidian}}, etc.&lt;br /&gt;
&lt;br /&gt;
=== gcompat ===&lt;br /&gt;
&lt;br /&gt;
[https://git.adelielinux.org/adelie/gcompat gcompat] is a library that provides glibc-compatible APIs for use on musl libc systems such as Alpine Linux. To install, issue the command: {{cmd|$ doas apk add {{pkg|gcompat}}}}&lt;br /&gt;
After that, you run your binaries as normally.&lt;br /&gt;
&lt;br /&gt;
For an usage example, refer to the [[Firefox#DRM_content_using_Widevine_workaround|Firefox]] page where gcompat is used to run the glibc-compiled Widevine binary.&lt;br /&gt;
&lt;br /&gt;
== Chroot ==&lt;br /&gt;
{{Main|Chroot}}&lt;br /&gt;
&lt;br /&gt;
Glibc applications can be run by installing a glibc-based distribution in a chroot inside the Alpine Linux. &lt;br /&gt;
&lt;br /&gt;
Instructions for setting up chroot for following popular glibc distributions are available:&lt;br /&gt;
* [[#Gentoo Linux|Gentoo Linux]]&lt;br /&gt;
* [[#Arch Linux|Arch Linux]]&lt;br /&gt;
* [[#Debian|Debian]]&lt;br /&gt;
&lt;br /&gt;
For updating the chroot, or for installing packages and their dependencies using package manager like {{ic|apt-get}}, enter the chroot as root.&lt;br /&gt;
&lt;br /&gt;
The following instructions are for a Debian chroot in {{Path|/var/chroots/debian}}, on x86_64, but can be adapted to other systems by using the appropriate paths.&lt;br /&gt;
{{cmd|$ doas mount --bind /dev /var/chroots/debian/dev&lt;br /&gt;
$ doas mount --bind /proc /var/chroots/debian/proc&lt;br /&gt;
$ doas mount --bind /dev/pts /var/chroots/debian/dev/pts&lt;br /&gt;
$ doas chroot /var/chroots/debian /bin/bash&lt;br /&gt;
[chroot]# apt update &amp;amp;&amp;amp; apt upgrade}}&lt;br /&gt;
&lt;br /&gt;
After installing the necessary applications and whatever else you might do, exit the chroot:&lt;br /&gt;
{{cmd|[chroot]# exit}}&lt;br /&gt;
&lt;br /&gt;
Then, unmount the binds for /dev/pts, dev and proc to avoid issues:&lt;br /&gt;
{{cmd|$ doas umount /var/chroots/debian/dev/pts&lt;br /&gt;
$ doas umount /var/chroots/debian/dev&lt;br /&gt;
$ doas umount /var/chroots/debian/proc}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|The most reliable way to enter and exit a chroot is to use the [[Chroot#Enter_chroot|start-chroot]] script, where the script takes care of all mounting and unmounting.}}&lt;br /&gt;
&lt;br /&gt;
Once a chroot is ready, there are at least a couple of ways to run glibc applications.&lt;br /&gt;
* [[#Using the glibc dynamic linker|Using the glibc dynamic linker]]&lt;br /&gt;
* [[#Bubblewrap + Chroot|Bubblewrap + Chroot]]&lt;br /&gt;
&lt;br /&gt;
=== Using the glibc dynamic linker ===&lt;br /&gt;
{{Todo|Please test and confirm if the below instructions are complete or requires modification.}}&lt;br /&gt;
The glibc dynamic linker can be configured in Alpine as follows. These instructions are for a Debian chroot in {{Path|/var/chroots/debian}}, on x86_64, but can be adapted to other systems by using the appropriate paths.&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /lib64&lt;br /&gt;
# ln -s /var/chroots/debian/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib64&lt;br /&gt;
# printf &#039;/var/chroots/debian/lib/x86_64-linux-gnu\n/var/chroots/debian/usr/lib/x86_64-linux-gnu\n&#039; &amp;gt; /etc/ld.so.conf&lt;br /&gt;
# /var/chroots/debian/sbin/ldconfig&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Gentoo Linux ===&lt;br /&gt;
&lt;br /&gt;
Select a &#039;&#039;stage3&#039;&#039; from [https://www.gentoo.org/downloads/ here] and the &#039;&#039;portage&#039;&#039; latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.&lt;br /&gt;
&lt;br /&gt;
First,{{cmd|$ doas apk add {{pkg|xz}}}}&lt;br /&gt;
&lt;br /&gt;
Enter the chroot:&lt;br /&gt;
{{cmd|$ mkdir ~/chroot&lt;br /&gt;
$ cd ~/chroot&lt;br /&gt;
$ doas tar -xvf stage3-*.tar.xz&lt;br /&gt;
$ doas tar -xvf portage-latest.tar.xz&lt;br /&gt;
$ doas mv portage usr&lt;br /&gt;
$ doas mount --bind /dev dev&lt;br /&gt;
$ doas mount --bind /sys sys&lt;br /&gt;
$ doas mount -t proc proc proc&lt;br /&gt;
$ doas cp /etc/resolv.conf etc&lt;br /&gt;
$ doas chroot . /bin/bash}}&lt;br /&gt;
&lt;br /&gt;
And voilà, you have your working Gentoo chroot!&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo&#039;s Handbook] to find out how you can configure and install your system, or simply extract/copy the program that you need to run in your chroot environment, and then execute it.&lt;br /&gt;
&lt;br /&gt;
Here is a wrapper script that is similar to {{ic|arch-chroot}} when you frequently reuse this chroot.  Also, create an account with the same username as host current user to the chroot, or make changes to the {{ic|userspec}} option to chroot line:&lt;br /&gt;
&lt;br /&gt;
{{Cat|gentoo-chroot.sh|&amp;lt;nowiki&amp;gt;#!/bin/bash&lt;br /&gt;
CHROOT_PATH=&amp;quot;/home/$USER/chroot&amp;quot;&lt;br /&gt;
cd $CHROOT_PATH&lt;br /&gt;
mount | grep $CHROOT_PATH/dev || doas mount --bind /dev dev&lt;br /&gt;
mount | grep $CHROOT_PATH/sys || doas mount --bind /sys sys&lt;br /&gt;
mount | grep $CHROOT_PATH/proc || doas mount -t proc proc proc&lt;br /&gt;
doas cp /etc/resolv.conf etc&lt;br /&gt;
doas chroot --userspec=$USER:users . /bin/bash&lt;br /&gt;
echo &amp;quot;You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc.&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Do {{ic|$ chmod +x gentoo-chroot.sh}} to make it executable.&lt;br /&gt;
&lt;br /&gt;
=== Arch Linux ===&lt;br /&gt;
&lt;br /&gt;
{{Seealso|Installing ArchLinux inside an Alpine chroot}}&lt;br /&gt;
Either use &#039;&#039;&#039;pacstrap&#039;&#039;&#039; (included with the arch-install-scripts package) or an Arch bootstrap image:&lt;br /&gt;
&lt;br /&gt;
{{cmd|$ doas apk add {{pkg|arch-install-scripts}}&lt;br /&gt;
$ mkdir ~/chroot &amp;amp;&amp;amp; cd ~/chroot&lt;br /&gt;
$ curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.zst&lt;br /&gt;
$ doas tar -x --zstd -f archlinux-bootstrap-x86_64.tar.zst &amp;amp;&amp;amp; rm archlinux-bootstrap-x86_64.tar.zst&lt;br /&gt;
$ doas sed -i &#039;/evowise/s/^#//&#039; root.x86_64/etc/pacman.d/mirrorlist&lt;br /&gt;
$ doas sed -i &#039;/CheckSpace/s/^/#/&#039; root.x86_64/etc/pacman.conf&lt;br /&gt;
$ doas arch-chroot root.x86_64&lt;br /&gt;
[chroot]# pacman-key --init&lt;br /&gt;
[chroot]# pacman-key --populate archlinux}}&lt;br /&gt;
&lt;br /&gt;
Once that is done, update the system and install the desired package(s) (denoted by &#039;&#039;&amp;quot;foo&amp;quot;&#039;&#039; in this example):&lt;br /&gt;
  &lt;br /&gt;
{{cmd|[chroot]# pacman -Syu &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Debian ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux provides the {{pkg|debootstrap}} package to create the Debian chroot. Here are the steps: {{cmd|$ doas apk add debootstrap&lt;br /&gt;
$ doas mkdir -p /var/chroots/debian&lt;br /&gt;
$ doas debootstrap --arch amd64 stable /var/chroots/debian/ https://deb.debian.org/debian}}&lt;br /&gt;
&lt;br /&gt;
The {{ic|--arch}} is optional, depending on your needs. Instructions for entering and exiting the Debian chroot are given in the [[#Chroot|Chroot]] section above.&lt;br /&gt;
&lt;br /&gt;
== Containers ==&lt;br /&gt;
&lt;br /&gt;
=== Distrobox + Podman ===&lt;br /&gt;
&lt;br /&gt;
[[Distrobox]], combined with [[Podman|podman]] container running in rootless mode, allows to easily run [[Distrobox#Running_graphical_programs|glibc-compiled graphical programs]]. This will not require root privileges once set up.&lt;br /&gt;
&lt;br /&gt;
=== Bubblewrap + Chroot ===&lt;br /&gt;
&lt;br /&gt;
Shell aliases are used to create a container with [[Bubblewrap]] with [[#Chroot|Chroot]] as its content. Once the graphical  glibc packages are installed inside the chroot, this allows for running them without requiring root privileges using bwrap. &lt;br /&gt;
&lt;br /&gt;
* [[Install]] the {{pkg|bubblewrap}} package.&lt;br /&gt;
* Follow the instructions to set up a [[#Chroot|Chroot]]. For eg. [[#Debian|Debian chroot]]. &lt;br /&gt;
* Install necessary glibc applications inside the chroot as root either using package manager like {{ic|apt-get}} or otherwise.&lt;br /&gt;
* Create alias {{ic|glibc}} and/or {{ic|glibcX11}} using bwrap in the Alpine Linux host as regular user.&lt;br /&gt;
&lt;br /&gt;
{{cmd|$ alias glibc{{=}}&amp;quot;LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
{{cmd|$ alias glibcX11{{=}}&amp;quot;LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 --setenv DISPLAY :0&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
To run programs that use X11/Xorg, you might need to use {{ic|xhost}} on the Alpine Linux host in order to allow local connections. For example:{{cmd|$ doas xhost + local:}}&lt;br /&gt;
&lt;br /&gt;
Now we can invoke any glibc_binary from the chroot using the above alias from the Alpine Linux host, as follows:&lt;br /&gt;
{{cmd|$ glibc glibc_binary}} or {{cmd|$ glibcX11 glibc_binary}} &lt;br /&gt;
&lt;br /&gt;
When a [[Wayland]] desktop such as [[Sway]] runs without XWayland on the Alpine Linux host, Electron apps need to be started with certain flags. These flags enforce Wayland rendering.&lt;br /&gt;
* For VS Code:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;glibc code --enable-features=UseOzonePlatform --ozone-platform=wayland&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* For Google Chrome:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;glibc google-chrome --enable-features=UseOzonePlatform --ozone-platform=wayland&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Tip|The Bubblewrap aliases are sufficient only for running applications. To install, remove, or update software within the chroot, follow the steps described in the [[#Chroot|Chroot]] section.}}&lt;br /&gt;
&lt;br /&gt;
== See also == &lt;br /&gt;
&lt;br /&gt;
* [[Alpine Package Keeper]]&lt;br /&gt;
* [[Installing ArchLinux inside an Alpine chroot]]&lt;br /&gt;
* [[Compile software from source]]&lt;br /&gt;
* [[Kernels]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Package Manager]] [[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Diskless_Mode&amp;diff=32096</id>
		<title>Diskless Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Diskless_Mode&amp;diff=32096"/>
		<updated>2026-02-28T11:34:08Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added clarification on the need for two media. refer redd.it/1rgyl6p&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In Diskless mode, the entire operating system with all applications are first loaded into RAM (&amp;lt;code&amp;gt;tmpfs&amp;lt;/code&amp;gt;) and then only run from there. This is also the method used to boot the Alpine Linux &amp;lt;Code&amp;gt;ISO9660&amp;lt;/Code&amp;gt; filesystem based read-only [[Installation#Preparing_installation_media|installation media]].&lt;br /&gt;
&lt;br /&gt;
Diskless mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear and suitable for servers. It is similar to what other linux distributions may call a &amp;quot;frugal&amp;quot; install or boot using a &amp;quot;toram&amp;quot; option.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux provides [[Alpine_local_backup|Local Backup Utility]]({{ic|lbu}}) that allows custom configurations and package installations to be optionally preserved or made to &amp;quot;persist&amp;quot; across reboots as [[#Apkovl|apkovl]] files on persistent storage. &lt;br /&gt;
&lt;br /&gt;
If additional or updated packages have been added to the system, these may also be made available for automatic (re)installation during the boot phase without any (re)downloading, by enabling a [[#Local package cache|local package cache]].&lt;br /&gt;
&lt;br /&gt;
== Diskless installation ==&lt;br /&gt;
&lt;br /&gt;
When running the &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; script, if &amp;quot;disk=none&amp;quot; is specified, then Alpine Linux will continue to run in diskless mode. It invokes &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-lbu|setup-lbu]]&amp;lt;/code&amp;gt;  and &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-apkcache|setup-apkcache]]&amp;lt;/code&amp;gt; to use any available writable filesystem on any media other than the read-only installation media for saving the configuration settings as apkovl file and local package cache.&lt;br /&gt;
&lt;br /&gt;
{{Tip|If you are using a single USB flash drive for a diskless install, use a [[#Using customizable boot device for persistent storage|customizable boot device]] rather than standard read-only installation media. This allows the drive to host both the OS and your persistent storage.}}&lt;br /&gt;
&lt;br /&gt;
Complete the below preparatory steps depending on the available persistent storage option for apkovl and local package cache. Persistent storage are configured as read-only in {{Path|/etc/fstab}}, as [[Alpine_local_backup|lbu]] can temporarily remount them as writable for their operation.&lt;br /&gt;
&lt;br /&gt;
=== Using customizable boot device for persistent storage ===&lt;br /&gt;
&lt;br /&gt;
A [[Create_a_Bootable_Device|Customizable boot device]] allows Alpine Linux to boot and run in Diskless mode from a partition with a writable filesystem on USB-Stick/CompactFlash/SDCard or SSD/NVMe harddisk. The [[#Apkovl|apkovl]] file(s) and [[#Local package cache|local package cache]] can be stored in this customizable boot device and no other storage is required.&lt;br /&gt;
&lt;br /&gt;
# Boot using the [[Create_a_Bootable_Device|Customizable boot device]].	&lt;br /&gt;
# Find out where the customizable boot device is mounted, the location could vary.{{Cmd|&amp;lt;nowiki&amp;gt;# mount | grep /media&lt;br /&gt;
/dev/sdXY on /media/sdXY type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# Mount the customizable boot device in rw mode, if required. {{Cmd|# mount -o remount,rw /media/sdXY}}&lt;br /&gt;
# Proceed to [[#Finishing diskless installation|Finishing diskless installation]] section without rebooting the computer.&lt;br /&gt;
&lt;br /&gt;
=== Using an internal disk for persistent storage ===&lt;br /&gt;
&lt;br /&gt;
Storing local configs on &#039;&#039;&#039;internal disks&#039;&#039;&#039; requires manual steps, i.e making an entry in {{Path|/etc/fstab}}, create mountpoint, and mount the partition before running &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script due to Issue [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10473 #10473]. Use only ext4 filesystem partitions on classic drives to store diskless mode states as diskless setup currently doesn&#039;t work on btrfs and xfs filesystems, or nvme-based devices as per {{Issue|11589|}}. &lt;br /&gt;
&lt;br /&gt;
# In this case, boot the target diskless system from the installation media and do not proceed after the [[Installation#Boot_Process|boot process]] stage. &lt;br /&gt;
# If necessary partition(s) are unavailable, manually [[Setting_up_disks_manually#Creating_partitions|create]] a partition using &amp;lt;Code&amp;gt;fdisk&amp;lt;/Code&amp;gt;. In the below steps, we will use /dev/sdXY as partition number. Adjust the partition identifier as per the output of {{Codeline|&amp;lt;Code&amp;gt;blkid&amp;lt;/Code&amp;gt;}}&amp;lt;br&amp;gt;&lt;br /&gt;
#*  mkfs.ext4 creates ext4 filesystem with 64bit feature enabled by default, but extlinux may not be able to boot with that due to Issue {{Issue|14895}}. You may need to add &amp;quot;-O ^64bit&amp;quot; to mkfs.ext4 to circumvent this. The below command creates an ext4 partition with disabled journaling, to reduce write operations and allow the disk to spin down after the .apkovl and the packages have been read from the partition during the boot. Install package {{pkg|&amp;lt;Code&amp;gt;e2fsprogs&amp;lt;/code&amp;gt;}} using command {{Codeline|&amp;lt;Code&amp;gt;apk add e2fsprogs&amp;lt;/Code&amp;gt;}}, if the command &amp;lt;Code&amp;gt;mkfs.ext4&amp;lt;/Code&amp;gt; is not available.&lt;br /&gt;
#: {{Cmd|# mkfs.ext4 -O ^has_journal,^64bit /dev/sdXY}}&lt;br /&gt;
# Configure the /etc/fstab to mount the writable partition to /media/sdXY conforming to the hot/cold-plug mountpoints.  &lt;br /&gt;
#: {{Cmd|# mkdir /media/sdXY}}&lt;br /&gt;
#: {{cmd|# echo &amp;quot;/dev/sdXY /media/sdXY ext4 noatime,ro 0 0&amp;quot; &amp;gt;&amp;gt; /etc/fstab}}&lt;br /&gt;
# Mount the partitions listed in {{Path|/etc/fstab}}:{{Cmd|# &amp;lt;code&amp;gt;mount -a&amp;lt;/code&amp;gt;}} &lt;br /&gt;
# Verify that the changes have been applied correctly by looking at the output of {{Cmd|$ &amp;lt;code&amp;gt;mount&amp;lt;/code&amp;gt;}} &lt;br /&gt;
# Proceed to [[#Finishing diskless installation|Finishing diskless installation]] section without rebooting the computer.&lt;br /&gt;
&lt;br /&gt;
=== Finishing diskless installation ===&lt;br /&gt;
&lt;br /&gt;
# If &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; has not run before, follow the [[Installation#Installation_Step_Details|Installation steps]] to complete until the &#039;&#039;&#039;Disk &amp;amp; Install&#039;&#039;&#039; option appears.&lt;br /&gt;
&amp;lt;!--If asked, there is no need to first unmount the partition, that would only be needed to allow installing on its parent disk.--&amp;gt;&lt;br /&gt;
# When the &#039;&#039;&#039; Disk &amp;amp; Install&#039;&#039;&#039; option appears, the preparatory steps done earlier for [[#Using an internal disk for persistent storage|internal disk]] or [[#Using customizable boot device for persistent storage|customizable boot device]] should now enable you to choose the partition(&#039;&#039;&#039;sdXY&#039;&#039;&#039;) for saving the local configs and package cache. So accept the choices as follows:{{Cmd|&amp;lt;nowiki&amp;gt;Which disk(s) would you like to use? (or &#039;?&#039; for help or &#039;none&#039;) [none] &lt;br /&gt;
Enter where to store configs (&#039;floppy&#039;, &#039;sdXY&#039;, &#039;usb&#039; or &#039;none&#039;) [sdXY]: &lt;br /&gt;
Enter apk cache directory (or &#039;?&#039; or &#039;none&#039;) [/media/sdXY/cache]:&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# If &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; has already been run to configure the diskless system, the storage and package cache settings can be configured using the &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-lbu|setup-lbu]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-apkcache|setup-apkcache]]&amp;lt;/code&amp;gt; as follows:{{cmd|&amp;lt;nowiki&amp;gt;# setup-lbu sdXY&lt;br /&gt;
# mkdir /media/sdXY/cache&lt;br /&gt;
# setup-apkcache /media/sdXY/cache&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# After the installer finished one can see how many created/modified files are detected and will be added to the backup:{{Cmd|&amp;lt;nowiki&amp;gt;# lbu status&lt;br /&gt;
# lbu status | wc -l&lt;br /&gt;
59&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# Now Commit all the changes using the command:{{Cmd|# lbu commit}}&lt;br /&gt;
# Verify that the above command has created the [[#Apkovl|apkovl]] file i.e &amp;lt;Code&amp;gt;&amp;lt;hostname&amp;gt;.apkovl.tar.gz&amp;lt;/Code&amp;gt; as follows:{{Cmd|&amp;lt;nowiki&amp;gt;ls -l /media/sda1/*apkovl.tar.gz&lt;br /&gt;
-rwxr-xr-x    1 root     root          9591 Oct 19 15:23 /media/sda1/foo.apkovl.tar.gz&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# Now the diskless installation can be considered complete.&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
Refer to the following sections related to running a Diskless installation.&lt;br /&gt;
&lt;br /&gt;
=== Modifying root filesystem size ===&lt;br /&gt;
&lt;br /&gt;
In Diskless mode, the root filesystem is mounted as &amp;lt;code&amp;gt;tmpfs&amp;lt;/code&amp;gt;. By default rootfs is allocated 50% of available RAM (without swap). This may be adjusted to arbitrary value (like 300MB) temporarily after boot by issuing &amp;lt;code&amp;gt;mount -o remount,size{{=}}300M /&amp;lt;/code&amp;gt;, or permanently at boot by setting [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/54bae0769080710e0769370a7bf3e0e158eec152/initramfs-init.in#L809-813 kernel parameter] as &amp;lt;code&amp;gt;rootflags{{=}}size{{=}}300M&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Local package cache ===&lt;br /&gt;
{{Main|Local APK cache}}&lt;br /&gt;
When Alpine Linux boots in Diskless Mode, the remote repositories will not be available until after networking has started. That means newer or extra packages not in your local boot media&#039;s squashfs image would not be available after a reboot, unless they were made available as [[Local APK cache|local package cache]] on a writable local storage device. The local package cache can be on the same partition as the &#039;&#039;&#039;apkovl&#039;&#039;&#039; file. &lt;br /&gt;
&lt;br /&gt;
=== Apkovl ===&lt;br /&gt;
&lt;br /&gt;
The local configuration or system state is saved  as APK Overlay (&#039;&#039;&#039;apkovl&#039;&#039;&#039;) file to a backup location by the {{ic|lbu}}and loaded when booting. The filename for the &#039;&#039;&#039;apkovl&#039;&#039;&#039;  file is of the format &amp;lt;Code&amp;gt;&amp;lt;hostname&amp;gt;.apkovl.tar.gz&amp;lt;/Code&amp;gt; and is stored in a location whose path is defined in {{Path|/etc/lbu/lbu.conf}} file. Apkovl file stores all configuration files that have changed from the default ones. The contents from the Apkovl file are overlaid on top of the contents of the base image. In Diskless mode, for every change made to the running system to persist across reboot, the command {{ic|lbu commit}} must be issued to update the apkovl file.&lt;br /&gt;
&lt;br /&gt;
==== Loading apkovl from webserver ====&lt;br /&gt;
&lt;br /&gt;
If a read-only installation media is used, it can remain the only boot device for the &amp;quot;diskless&amp;quot; system by saving the running state i.e [[#Apkovl|apkovl]] file to a webserver, and have these automatically loaded when booting from the boot device. The Alpine linux boot process supports passing boot parameters to load [[#Apkovl|apkovl]] file from a webserver, by supplying a custom url with the {{ic|apkovl}} kernel boot parameter. If you don&#039;t have a web server you can run busybox&#039;s httpd temporarily to serve an .apkovl - &amp;lt;code&amp;gt;busybox httpd -p 127.0.0.1:80&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Upgrading a diskless system ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine_Package_Keeper#Upgrade_a_Running_System|Upgrading a running]] system with [[Diskless Mode|diskless]] or [[Data Disk Mode|Data disk]] mode for regular package update requires running the below command from [[Alpine_local_backup|Local Backup Utility]] after every package update:{{Cmd|# lbu commit}}&lt;br /&gt;
&lt;br /&gt;
For upgrading the kernel, with its modules and firmware files use [[Diskless Mode#update-kernel script|update-kernel]] script. For upgrading  [[Diskless Mode|diskless]] or [[Data Disk Mode|Data disk]] installations to a new release branch refer  [[Upgrading Alpine Linux to a new release branch#Upgrading diskless and data disk mode installs to latest release|Upgrading diskless and data disk mode installs to latest release]].&lt;br /&gt;
&lt;br /&gt;
=== update-kernel script ===&lt;br /&gt;
&lt;br /&gt;
When kernel packages with its modules and firmware packages are upgraded, the &amp;lt;code&amp;gt;update-kernel&amp;lt;/code&amp;gt; script generates initfs images and installs them together with upgraded kernel and updates the boot files in persistent storages like [[Create_a_Bootable_Device|customizable boot device]].&lt;br /&gt;
&lt;br /&gt;
* Before upgrading, install the {{Pkg|mkinitfs}} package as this is required for the generation of the initial filesystem used during boot as follows: {{cmd|# apk add mkinitfs}}&lt;br /&gt;
* Additional initfs features that are missing in the default configuration, like the [[Btrfs|btrfs]] filesystem support (at the time of writing, to allow loading .apkovl configs and package cache during boot), may be enabled in the file {{Path|/etc/mkinitfs/mkinitfs.conf}}.&lt;br /&gt;
* Available initfs features may be listed with &amp;lt;code&amp;gt;ls /etc/mkinitfs/features.d&amp;lt;/code&amp;gt;&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# ls /etc/mkinitfs/features.d&lt;br /&gt;
# apk add nano&lt;br /&gt;
# nano /etc/mkinitfs/mkinitfs.conf&lt;br /&gt;
# lbu commit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
* Finally update the kernel and its boot environment.&lt;br /&gt;
{{cmd|# update-kernel /media/sdXY/boot/&lt;br /&gt;
}}&lt;br /&gt;
{{Note|&amp;lt;code&amp;gt;update-kernel&amp;lt;/code&amp;gt; run needs at least 8 GB free ram memory to avoid a broken modloop-image. So, in memory constrained devices like [[Raspberry Pi]], use the environment variable &amp;lt;code&amp;gt;TMPDIR&amp;lt;/code&amp;gt; to point to a directory on a *nix file system formatted physical device, like a SD-Card or USB-Stick as follows: {{Cmd|&amp;lt;nowiki&amp;gt;# TMPDIR=/media/sdc1/tmp update-kernel /media/mmcblk0p1/boot/&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
&lt;br /&gt;
See &amp;lt;code&amp;gt;update-kernel --help&amp;lt;/code&amp;gt; for options to manually add additional module or firmware packages.&lt;br /&gt;
&lt;br /&gt;
== Documentation on kernel options ==&lt;br /&gt;
&lt;br /&gt;
Documentation about kernel command line options regarding diskless mode can be accessed by installing the documentation sub-package {{Pkg|mkinitfs-doc}} and running the command {{Cmd|man mkinitfs-bootparam}}  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
       If no root= parameter is given, the initramfs will build a live system&lt;br /&gt;
       in memory from scratch. This is also called diskless mode.&lt;br /&gt;
&lt;br /&gt;
       When booting in diskless mode, the following options are also&lt;br /&gt;
       available:&lt;br /&gt;
&lt;br /&gt;
       alpine_repo=(URL | PATH)&lt;br /&gt;
              If set, /etc/apk/repositories will be filled with this. May be a&lt;br /&gt;
              comma-separated list of URLs.&lt;br /&gt;
&lt;br /&gt;
       apkovl=(URL | [DEVICE[:FS_TYPE]:]PATH)&lt;br /&gt;
              A HTTP, HTTPS or FTP URL to an apkovl.tar.gz file which will be&lt;br /&gt;
              retrieved and applied. Can also be a filesystem path, optionally&lt;br /&gt;
              prepended with the device name without the /dev/ prefix.&lt;br /&gt;
&lt;br /&gt;
       autodetect_serial=no&lt;br /&gt;
              Disable automatic detection and setup of serial console.&lt;br /&gt;
&lt;br /&gt;
       ds=OPTIONS&lt;br /&gt;
              Data source for tiny-cloud. If OPTIONS starts with nocloud,&lt;br /&gt;
              tiny-cloud will be enabled.&lt;br /&gt;
&lt;br /&gt;
       nokeep_apk_new&lt;br /&gt;
              Setup a fresh system, ignore any apkovl.&lt;br /&gt;
&lt;br /&gt;
       pkgs=PACKAGE{,PACKAGE}&lt;br /&gt;
              Comma-separated list of packages to be installed.&lt;br /&gt;
       ssh_key=(URL | SSH_KEY)&lt;br /&gt;
              This setting installs openssh and places the public key given as&lt;br /&gt;
              value in /root/.ssh/authorized_keys.  If the value is an HTTP or&lt;br /&gt;
              FTP url, its fetches the key(s) from there.&lt;br /&gt;
&lt;br /&gt;
       splash Enable splash screen.&lt;br /&gt;
&lt;br /&gt;
       usbdelay=NUMBER&lt;br /&gt;
              Wait NUMBER seconds for USB devices to show up before searching&lt;br /&gt;
              for boot media.&lt;br /&gt;
&lt;br /&gt;
       wireguard=INTERFACE;IP_ADDRESS{,IP_ADDRESS,...}[;WG_CONFIG_FILE]&lt;br /&gt;
              Set up a wireguard interface named INTERFACE with the addresses&lt;br /&gt;
              IP_ADDRESS and use /etc/wireguard/initrd.conf or WG_CONFIG_FILE&lt;br /&gt;
              as a classic wg (not wg-quick) config.&lt;br /&gt;
&lt;br /&gt;
       zfs_force=NUMBER&lt;br /&gt;
              Enable force importing the root zpool on boot, even if it was&lt;br /&gt;
              previously mounted from a different system/OS.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine_local_backup|Alpine Local backup Utility - &#039;&#039;lbu&#039;&#039;&#039;]]&lt;br /&gt;
* [[Local APK cache|Local package cache]]&lt;br /&gt;
* [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Back Up a Flash Memory Installation]]&lt;br /&gt;
* [[Upgrading_Alpine#Upgrading_Alpine_Linux_on_other_removable_media_(such_as_CF/USB)|Upgrading Diskless to New Alpine Linux Release]]&lt;br /&gt;
* [[PXE boot#Specifying an apkovl|Diskless PXE Boot]]&lt;br /&gt;
* [[How to make a custom ISO image with mkimage]]&lt;br /&gt;
* [[QEMU#Live_mode|QEMU Diskless example]] &lt;br /&gt;
* [[Alpine local backup#Include special files.2Ffolders to the apkovl|Include special files section]] - To include custom files outside of &amp;lt;code&amp;gt;/etc&amp;lt;/code&amp;gt; in .apkovl file.&lt;br /&gt;
* [[SquashFS]] &lt;br /&gt;
* [[OverlayFS]] &lt;br /&gt;
* [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/54bae0769080710e0769370a7bf3e0e158eec152/initramfs-init.in#L809-813 Root filesystem Size Allocation]&lt;br /&gt;
* [https://www.fedux.net/post/setup-alpine-linux-diskless/ Detailed Diskless Installation Instruction]&lt;br /&gt;
* [https://www.reddit.com/r/AlpineLinux/comments/1bezynm/comment/kuxcy70 Diskless Installation Instructions]&lt;br /&gt;
&lt;br /&gt;
[[Category:Diskless]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=32077</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=32077"/>
		<updated>2026-02-19T09:44:09Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: removed duplicate entries&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Howtos are smaller articles&#039;&#039;&#039; explaining how to perform a particular task with Alpine Linux, that expects a minimal knowledge from reader to perform actions. Howto&#039;s have been organized in the below page based on the topics.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The [[#Tutorials|tutorials]] are hands-on&#039;&#039;&#039; and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
* Contributors are requested to refer to [[Help:Editing]] first and make use of resources like [[How to write a HOWTO]].&lt;br /&gt;
* Contributions must be complete articles. &lt;br /&gt;
* Don&#039;t override already made contributions, unless there is a mistake. &lt;br /&gt;
* If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].}}&lt;br /&gt;
&lt;br /&gt;
== Desktop ==&lt;br /&gt;
&lt;br /&gt;
* {{:Daily driver guide}}&lt;br /&gt;
&lt;br /&gt;
=== Networking ===&lt;br /&gt;
&lt;br /&gt;
* [[Bluetooth]] - Instructions for installing and configuring Bluetooth&lt;br /&gt;
* [[Bonding]] - Bond (or aggregate) multiple ethernet interfaces&lt;br /&gt;
* [[Bridge]] - Configuring a network bridge&lt;br /&gt;
** [[Bridge wlan0 to eth0]]&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
* Modem&lt;br /&gt;
** [[Using HSDPA modem]]&lt;br /&gt;
** [[Using serial modem]]&lt;br /&gt;
* [[mDNS]] - Howto implement multicast DNS resolution in Alpine. &lt;br /&gt;
* [[Multi ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[PXE boot]]&lt;br /&gt;
* Wi-Fi&lt;br /&gt;
** [[Wi-Fi|Connecting to a wireless access point]]&lt;br /&gt;
** [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* Use [https://github.com/ifupdown-ng/ifupdown-ng/blob/main/doc/interfaces-vxlan.scd vxlan], if using  [[Ifupdown-ng]] instead of [[VLAN]]&lt;br /&gt;
* [[Setting up a Home Router]]&lt;br /&gt;
&lt;br /&gt;
=== Backup and data migration ===&lt;br /&gt;
&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
* [[Rsnapshot]] - setting up periodic backups&lt;br /&gt;
&lt;br /&gt;
=== Other topics ===&lt;br /&gt;
&lt;br /&gt;
* [[Gaming on Alpine]]&lt;br /&gt;
* [[Remote Desktop Server]]&lt;br /&gt;
* [[Default applications|How to change default application]]&lt;br /&gt;
* [[CPU frequency scaling]]&lt;br /&gt;
* [[Mimalloc]]&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[How to build the Alpine Linux kernel]]&lt;br /&gt;
* [[Nextcloud]] &#039;&#039;(Self hostable cloud suite - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
* [[Fingerprint Authentication with swaylock]]&lt;br /&gt;
* [[Mounting a LUKS Encrypted Data Partition at Boot]]&lt;br /&gt;
* [[Desktop environments and Window managers|List of supported Desktop environments and Window managers]]&lt;br /&gt;
&lt;br /&gt;
== Diskless ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]]&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
== Other Architectures ==&lt;br /&gt;
&lt;br /&gt;
=== APU (PCEngines) ===&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Install: from a disc to PC Engines APU|Alpine on PC Engines APU]]&lt;br /&gt;
* [https://github.com/huubsch/Installation-of-Alpine-Linux-on-PC-Engines-APU3/tree/main?tab=readme-ov-file Installation of Alpine Linux on PCEngines APU, legacy BIOS]&lt;br /&gt;
&lt;br /&gt;
=== ARM ===&lt;br /&gt;
&lt;br /&gt;
* [[Alpine on ARM]]&lt;br /&gt;
&lt;br /&gt;
==== Raspberry Pi ====&lt;br /&gt;
&lt;br /&gt;
* [[Raspberry Pi|Raspberry Pi main page]]&lt;br /&gt;
* [[Raspberry Pi Bluetooth Speaker|Raspberry Pi - Bluetooth Speaker]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi|Raspberry Pi - Router with VPN]]&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi (IPv6)|Raspberry Pi - Router with VPN (IPv6)]]&lt;br /&gt;
* [[Classic install or sys mode on Raspberry Pi|Raspberry Pi - Sys mode install]]&lt;br /&gt;
* [[Raspberry Pi LVM on LUKS|Raspberry Pi - Sys mode install - LVM on LUKS]]&lt;br /&gt;
* [[RPI Video Receiver|Raspberry Pi - Video Receiver]] &#039;&#039;(network video decoder using Rasperry Pi and omxplayer)&#039;&#039;&lt;br /&gt;
* [[Raspberry Pi 3 - Browser Client]] - kiosk or digital sign&lt;br /&gt;
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]&lt;br /&gt;
* [[Raspberry Pi 3 - Setting Up Bluetooth]]&lt;br /&gt;
* [[Raspberry Pi 4 - Persistent system acting as a NAS and Time Machine]]&lt;br /&gt;
* [[Raspberry_Pi_Zero_W_-_Installation|Raspberry Pi Zero W - Installation]]&lt;br /&gt;
* [[How to set up Alpine as a wireless router|Raspberry Pi Zero W - Wireless router]] &#039;&#039;(Setting up a firewalled, Wireless AP with wired network on a Pi Zero W)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== IBM Z (IBM z Systems) ===&lt;br /&gt;
&lt;br /&gt;
* [[s390x|s390x - Installation]]&lt;br /&gt;
&lt;br /&gt;
=== PowerPC ===&lt;br /&gt;
&lt;br /&gt;
* [[Ppc64le|Powerpc64le - Installation]]&lt;br /&gt;
&lt;br /&gt;
== Security ==&lt;br /&gt;
&lt;br /&gt;
* [[#Desktop security|Desktop security]] lists steps for securing Alpine Linux desktops&lt;br /&gt;
* [[Setting up a laptop]] page has detailed guidelines to configure a secured laptop&lt;br /&gt;
* [[Securing Alpine Linux|Secure Alpine Linux]] using Security Technical Implementation Guides (STIGs)&lt;br /&gt;
* [[Sshguard|SSHGuard]] - Protects hosts against brute-force attacks:  monitoring logs, attack detection, blocking using firewall.&lt;br /&gt;
&lt;br /&gt;
== Services == &lt;br /&gt;
&lt;br /&gt;
{{Note| Services are arranged in alphabetical order.}}&lt;br /&gt;
&lt;br /&gt;
=== Content management systems ===&lt;br /&gt;
&lt;br /&gt;
* [[DokuWiki]] &#039;&#039;(Simple and easy to use wiki, no database required)&#039;&#039;&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[Kopano]] &#039;&#039;(Microsoft Outlook compatible Groupware)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
* [[Moodle]] &#039;&#039;(Online Learning Management system)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Database === &lt;br /&gt;
&lt;br /&gt;
* [[MariaDB]] or [[MySQL|MySQL]]&lt;br /&gt;
&lt;br /&gt;
=== DNS ===&lt;br /&gt;
&lt;br /&gt;
* [[DNSCrypt-Proxy]] &#039;&#039;Encrypt and authenticate DNS calls from your system&#039;&#039;&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[Small-Time DNS with BIND9]] &#039;&#039;(A simple configuration with ad blocking for your home network)&#039;&#039;&lt;br /&gt;
* Unbound&lt;br /&gt;
** [[Setting up unbound DNS server]]&lt;br /&gt;
** [[Using Unbound as an Ad-blocker]] &#039;&#039;(Setup ad blocking for your network)&#039;&#039;&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
&lt;br /&gt;
=== File server ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting up an NFS server|nfs-server]]&lt;br /&gt;
* [[Setting up a Samba server|samba-server]] &#039;&#039;(standard file sharing)&#039;&#039;&lt;br /&gt;
* [[Setting up a samba-ad-dc|samba-ad-dc]] &#039;&#039;(Active Directory compatible domain controller)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User&#039;s Guide]&lt;br /&gt;
** [[Zero-To-Awall]] -&#039;&#039;AWall for dummies&#039;&#039;&lt;br /&gt;
** [[How-To Alpine Wall]] - &#039;&#039;AWall for Shorewall users&#039;&#039;&lt;br /&gt;
** [[Alpine Wall]] - &#039;&#039;AWall - Firewall management framework - Design Document&#039;&#039;&lt;br /&gt;
* [[Iptables]]&lt;br /&gt;
* [[nftables]]&lt;br /&gt;
* [[Uncomplicated Firewall|Uncomplicated Firewall or UFW]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP and web services ===&lt;br /&gt;
&lt;br /&gt;
* [[Althttpd]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Apache with php-fpm]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Advanced security]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
** [[Production Web server: Lighttpd|Production web server: Lighttpd‎‎]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
** [[Nginx as reverse proxy with acme (letsencrypt)]]&lt;br /&gt;
** [[Nginx with PHP]]&lt;br /&gt;
* Squid Proxy&lt;br /&gt;
** [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
** [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Tomcat]]&lt;br /&gt;
** [[Production LAMP system: Lighttpd + PHP + MySQL‎‎|Production LAMP system: Lighttpd + PHP + MariaDB/MySQL‎‎]]&lt;br /&gt;
&lt;br /&gt;
=== IRC ===&lt;br /&gt;
&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
* [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
* Exim/Dovecot&lt;br /&gt;
** [[Small-Time Email with Exim and Dovecot]] &#039;&#039;(A simple configuration for your home network.)&lt;br /&gt;
** [[Setting up dovecot with imap and tls]]&lt;br /&gt;
* [[relay email to gmail (msmtp, mailx, sendmail]]&lt;br /&gt;
* [[relay email (nullmailer)]]&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* Server protection&lt;br /&gt;
** [[Setting up clamsmtp]]&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Cacti: traffic analysis and monitoring network]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Logcheck]] &#039;&#039;(log file monitoring tool)&#039;&#039;&lt;br /&gt;
* [[Matomo]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Rasdaemon]] &#039;&#039;(Platform Reliability, Availability and Serviceability monitoring tool)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance; for alpine 3.10-3.12 only)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
** [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Zabbix|Zabbix - the professional complete manager]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[ZoneMinder video camera security and surveillance]]&lt;br /&gt;
&lt;br /&gt;
=== Remote Administration ===&lt;br /&gt;
&lt;br /&gt;
* ACF&lt;br /&gt;
** [[Changing passwords for ACF|ACF - changing passwords]]&lt;br /&gt;
** [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
** [[setup-acf| ACF - setup]] &#039;&#039;(Configures ACF (webconfiguration/webmin) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Setting up a SSH server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
** [[HOWTO OpenSSH 2FA with password and Google Authenticator |OpenSSH 2FA]] &#039;&#039;(A simple two factor setup for OpenSSH)&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
&lt;br /&gt;
* [[FreePBX|FreePBX on Alpine Linux]]&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== VPN ===&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[GNUnet]]&lt;br /&gt;
* [[IGMPproxy]]&lt;br /&gt;
* [[Setting up a OpenVPN server|OpenVPN server]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
* [[OpenVSwitch]]&lt;br /&gt;
* [[Tor]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
* [[Configure a Wireguard interface (wg)|Wireguard]]&lt;br /&gt;
* [[Vpnc]]&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
&lt;br /&gt;
* [[apcupsd]] &#039;&#039;(UPS Monitoring with apcupsd)&#039;&#039;&lt;br /&gt;
* [[Chrony and GPSD | Chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[nut-ups|NUT UPS]] &#039;&#039;(UPS Monitoring with Network UPS Tools)&#039;&#039;&lt;br /&gt;
* [[Odoo]]&lt;br /&gt;
* [[Configure OpenLDAP | OpenLDAP]] &#039;&#039;(Installing and configuring the Alpine package for OpenLDAP)&#039;&#039;&lt;br /&gt;
* [[Setting up a LLDAP server|lldap-server]] &#039;&#039;(Directory Server)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software development ==&lt;br /&gt;
&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Patchwork]] &#039;&#039;(Patch review management system)&#039;&#039;&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system) [Deprecated]&#039;&#039;&lt;br /&gt;
* [[Request Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
* [[Installing Oracle Java|Oracle Java (installation)]]&lt;br /&gt;
&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually|Manual partitioning]]&lt;br /&gt;
* [[Disk Replication with DRBD|DRBD: Disk Replication]]&lt;br /&gt;
* [[Filesystems]]&lt;br /&gt;
** [[Burning ISOs]]&lt;br /&gt;
* [[Setting up iSCSI|iSCSI Setup]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
** [[Linux iSCSI Target (TCM)|iSCSI Target (TCM)/LinuxIO (LIO)]]&lt;br /&gt;
** [[Linux iSCSI Target (tgt)|User space iSCSI Target (tgt)]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM|LVM Setup]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks|LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM|LVM on GPT-labeled disks (updated)]]&lt;br /&gt;
** [[LVM on LUKS]]&lt;br /&gt;
* RAID&lt;br /&gt;
** [[Raid Administration]]&lt;br /&gt;
** [[Setting up a software RAID array]]&lt;br /&gt;
* [[ZFS]]&lt;br /&gt;
** [[Root on ZFS with native encryption]]&lt;br /&gt;
** [[Setting up ZFS on LUKS]]&lt;br /&gt;
* [[CEPH|CEPH]]&lt;br /&gt;
&lt;br /&gt;
== Virtualization ==&lt;br /&gt;
&lt;br /&gt;
* [[Docker]]&lt;br /&gt;
* [[Installing Alpine in a virtual machine]]&lt;br /&gt;
** [[Install Alpine on VMware ESXi]]&lt;br /&gt;
* [[KVM]] &#039;&#039;(Setting up Alpine as a KVM hypervisor)&#039;&#039;&lt;br /&gt;
* [[LXC]] &#039;&#039;(Setting up a Linux container in Alpine Linux)&#039;&#039;&lt;br /&gt;
* [[QEMU]]&lt;br /&gt;
* Xen&lt;br /&gt;
** [[Xen Dom0]] &#039;&#039;(Setting up Alpine as a dom0 for Xen hypervisor)&#039;&#039;&lt;br /&gt;
** [[Xen Dom0 on USB or SD]]&lt;br /&gt;
** [[Create Alpine Linux PV DomU|Xen DomU (paravirtualized)]]&lt;br /&gt;
** [[Xen LiveCD]]&lt;br /&gt;
** [[Xen PCI Passthrough]]&lt;br /&gt;
** [[K8s]] Building a K8s Kubernetes Cluster on Alpine Linux&lt;br /&gt;
* [[Runc]]&lt;br /&gt;
&lt;br /&gt;
== [[Simple_Walkthrough]] ==&lt;br /&gt;
* [[About-virtualization-simple]]&lt;br /&gt;
* [[LXC_Alpinelinux_Simple]]&lt;br /&gt;
* [[Qemu-simple]]&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
* [[TTY_Autologin|TTY Autologin]]&lt;br /&gt;
* [[Kexec|Faster rebooting with kexec]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small Office Services]]&lt;br /&gt;
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[ISP Mail Server 3.x HowTo]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-service ISP mail server)&#039;&#039;&lt;br /&gt;
* [[Grommunio Mail Server]] &#039;&#039;(Mariadb+Postfix+Rspamd+Grommunio - Full-service mail server as MS exchange replacement)&#039;&#039;&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Install Alpine on a btrfs filesystem with refind as boot manager]]&lt;br /&gt;
* [[Compile software from source|How to Compile a software from source in Alpine Linux]]&lt;br /&gt;
* [https://ww2.coastal.edu/mmurphy2/oer/alpine/ Alpine Linux tutorials - Dr Murphy, Computing Science Associate Professor]&lt;br /&gt;
* [[Michael&#039;s base installation procedure|Michael&#039;s base installation procedure]]&lt;br /&gt;
* [[Michael&#039;s cwm  desktop (minimal)|Michael&#039;s cwm desktop (minimal)]]&lt;br /&gt;
* [[Michael&#039;s sway desktop (minimal)|Michael&#039;s Sway desktop (minimal)]]&lt;br /&gt;
* [[Sway_customization_guide|Sway customization guide]] &#039;&#039;(Tutorial re Sway config file basics)&#039;&#039;&lt;br /&gt;
* [[Using Distrobox For VR Gaming|Using Distrobox For VR Gaming]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32076</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32076"/>
		<updated>2026-02-19T07:39:33Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: removed some repetitions to reduce the content&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk audit|audit]]|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk audit ==&lt;br /&gt;
&lt;br /&gt;
The audit applet examines the system or specified directories for changes compared to the package database. The purpose of audit is to detect unauthorized modifications or to identify files/paths to [[Alpine_local_backup#Include_special_files/folders_to_the_apkovl|include them in apkovl]]. &lt;br /&gt;
&lt;br /&gt;
These flags determine the &#039;&#039;&#039;scope&#039;&#039;&#039; of the audit i.e which files are examined: &lt;br /&gt;
    --backup (Default): Files flagged as configuration/protected &lt;br /&gt;
    --system: Files provided by packages but ignores new/untracked files and configuration files.&lt;br /&gt;
    --full: All package tracked files and all newly added files/directories.&lt;br /&gt;
&lt;br /&gt;
When the audit exits with code 99 but produces no output, change the scope and re-run the audit with option --full --details to reveal the output.&lt;br /&gt;
&lt;br /&gt;
The following flags modify the output and provide additional information:&lt;br /&gt;
 --details: Shows the exact metadata differences using + and - symbols.&lt;br /&gt;
 --check-permissions: Includes UID, GID, and Mode in the comparison.&lt;br /&gt;
 --packages: Prints only the packages with changed files. &lt;br /&gt;
&lt;br /&gt;
The packages flag is useful to repair all packages with modified files, by using the command:{{Cmd|&amp;lt;nowiki&amp;gt;# apk audit --packages -q | xargs apk fix&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
By default, the output format is one file per line, for each modified file. A character is printed indicating the line type, followed by a space, then either the affected path or the metadata details. The metadata details appear above the relevant file/path. &lt;br /&gt;
&lt;br /&gt;
An optional &amp;lt;path&amp;gt; can be added to limit the audit to a specific directory. The example output below illustrates most of the options explained above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod 777 /etc/init.d/networking&lt;br /&gt;
# apk audit --check-permissions --details /etc/init.d/networking&lt;br /&gt;
# echo $?&lt;br /&gt;
99 &lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
- mode=755 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
+ mode=777 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
M etc/init.d/networking&lt;br /&gt;
# apk fix openrc&lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
# echo $?&lt;br /&gt;
1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the changes detected and displayed by the audit command.&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Audit command output&lt;br /&gt;
|-&lt;br /&gt;
| - || Details as per Database record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| + ||  Details as per On-disk record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| A ||  File added &lt;br /&gt;
|-&lt;br /&gt;
| d ||  Directory added &lt;br /&gt;
|-  &lt;br /&gt;
| D ||  Directory added (with non-listed files/subdirs) &lt;br /&gt;
|-  &lt;br /&gt;
| e ||  error occured during audit (e.g. no permissions to read file) &lt;br /&gt;
|-&lt;br /&gt;
|  M ||  File metadata changed (uid, gid, or mode) &lt;br /&gt;
|-&lt;br /&gt;
|  m ||  Directory metadata changed &lt;br /&gt;
|-&lt;br /&gt;
|  U ||  File contents modified &lt;br /&gt;
|-&lt;br /&gt;
|  X ||  File deleted &lt;br /&gt;
|-&lt;br /&gt;
|  x || xattrs changed&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
=== Issues due to /usr merge ===&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, for users who have migrated to the [[Repositories#Message_on_/usr_merge|merged /usr]], there are certain known issues like {{Issue|17624|apk audit does not work}}. &lt;br /&gt;
&amp;lt;!-- This entire  section has to be removed at a future date once the issues related to /usr merge are fixed completely --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ERROR:Could not find owner package ====&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[[Repositories#Message_on_/usr_merge|/usr merge]]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32075</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32075"/>
		<updated>2026-02-19T07:30:46Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: moved the exit code section and added wikilink&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk audit|audit]]|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk audit ==&lt;br /&gt;
&lt;br /&gt;
The audit applet audits the system or specified directories for changes compared to the package database. The default option is to audit configuration files only. Options are available to audit all system files or to audit specified directories to detect unauthorized modifications or to identify files/paths to [[Alpine_local_backup#Include_special_files/folders_to_the_apkovl|include them in apkovl]]. &lt;br /&gt;
&lt;br /&gt;
These flags determine which files audit applet will examine i.e &#039;&#039;&#039;scope&#039;&#039;&#039; of the audit. &lt;br /&gt;
    --backup (Default): Files flagged as configuration/protected &lt;br /&gt;
    --system: Files provided by packages but ignores new/untracked files and configuration files.&lt;br /&gt;
    --full: All package tracked files and all newly added files/directories.&lt;br /&gt;
&lt;br /&gt;
When the audit exits with code 99 but produces no output,change the scope and re-run the audit with option --full --details to reveal the output.&lt;br /&gt;
&lt;br /&gt;
The following flags modify the output and provide additional information:&lt;br /&gt;
 --details: Shows the exact metadata differences using + and - symbols.&lt;br /&gt;
 --check-permissions: Includes UID, GID, and Mode in the comparison.&lt;br /&gt;
 --packages: Prints only the packages with changed files. &lt;br /&gt;
&lt;br /&gt;
The packages flag is useful to repair all packages with modified files, by using the command:{{Cmd|&amp;lt;nowiki&amp;gt;# apk audit --packages -q | xargs apk fix&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
By default, the output format is one file per line, for each modified file. A character is printed indicating the line type, followed by a space, then either the affected path or the metadata details. The metadata details usually appears above the relevant file/path. &lt;br /&gt;
&lt;br /&gt;
An optional &amp;lt;path&amp;gt; can be added to limit the audit to a specific directory. The example output below illustrates most of the options explained above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod 777 /etc/init.d/networking&lt;br /&gt;
# apk audit --check-permissions --details /etc/init.d/networking&lt;br /&gt;
# echo $?&lt;br /&gt;
99 &lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
- mode=755 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
+ mode=777 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
M etc/init.d/networking&lt;br /&gt;
# apk fix openrc&lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
# echo $?&lt;br /&gt;
1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the changes detected and displayed by the audit command.&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Audit command output&lt;br /&gt;
|-&lt;br /&gt;
| - || Details as per Database record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| + ||  Details as per On-disk record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| A ||  File added &lt;br /&gt;
|-&lt;br /&gt;
| d ||  Directory added &lt;br /&gt;
|-  &lt;br /&gt;
| D ||  Directory added (with non-listed files/subdirs) &lt;br /&gt;
|-  &lt;br /&gt;
| e ||  error occured during audit (e.g. no permissions to read file) &lt;br /&gt;
|-&lt;br /&gt;
|  M ||  File metadata changed (uid, gid, or mode) &lt;br /&gt;
|-&lt;br /&gt;
|  m ||  Directory metadata changed &lt;br /&gt;
|-&lt;br /&gt;
|  U ||  File contents modified &lt;br /&gt;
|-&lt;br /&gt;
|  X ||  File deleted &lt;br /&gt;
|-&lt;br /&gt;
|  x || xattrs changed&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
=== Issues due to /usr merge ===&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, for users who have migrated to the [[Repositories#Message_on_/usr_merge|merged /usr]], there are certain known issues like {{Issue|17624|apk audit does not work}}. &lt;br /&gt;
&amp;lt;!-- This entire  section has to be removed at a future date once the issues related to /usr merge are fixed completely --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ERROR:Could not find owner package ====&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[[Repositories#Message_on_/usr_merge|/usr merge]]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32074</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32074"/>
		<updated>2026-02-19T07:04:51Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: clarified on the scope of the audit as this word is not part of the man page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk audit ==&lt;br /&gt;
&lt;br /&gt;
The audit applet audits the system or specified directories for changes compared to the package database. The default option is to audit configuration files only. Options are available to audit all system files or to audit specified directories to detect unauthorized modifications or to identify files/paths to [[Alpine_local_backup#Include_special_files/folders_to_the_apkovl|include them in apkovl]]. &lt;br /&gt;
&lt;br /&gt;
These flags determine which files audit applet will examine i.e &#039;&#039;&#039;scope&#039;&#039;&#039; of the audit. &lt;br /&gt;
    --backup (Default): Files flagged as configuration/protected &lt;br /&gt;
    --system: Files provided by packages but ignores new/untracked files and configuration files.&lt;br /&gt;
    --full: All package tracked files and all newly added files/directories.&lt;br /&gt;
&lt;br /&gt;
The following flags modify the output and provide additional information:&lt;br /&gt;
 --details: Shows the exact metadata differences using + and - symbols.&lt;br /&gt;
 --check-permissions: Includes UID, GID, and Mode in the comparison.&lt;br /&gt;
 --packages: Prints only the packages with changed files. &lt;br /&gt;
&lt;br /&gt;
The packages flag is useful to repair all packages with modified files, by using the command:{{Cmd|&amp;lt;nowiki&amp;gt;# apk audit --packages -q | xargs apk fix&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
By default, the output format is one file per line, for each modified file. A character is printed indicating the line type, followed by a space, then either the affected path or the metadata details. The metadata details usually appears above the relevant file/path. &lt;br /&gt;
&lt;br /&gt;
Exit Codes are affected by the scope:&lt;br /&gt;
    1 (or 0): Audit completed and found no discrepancies&lt;br /&gt;
    99: The audit found discrepancies, but not printed. &lt;br /&gt;
&lt;br /&gt;
For exit code 99 with no output, change the scope and re-run the audit with options like --full --details.&lt;br /&gt;
&lt;br /&gt;
An optional &amp;lt;path&amp;gt; can be added to limit the audit to a specific directory. The example output below illustrates most of the options explained above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod 777 /etc/init.d/networking&lt;br /&gt;
# apk audit --check-permissions --details /etc/init.d/networking&lt;br /&gt;
# echo $?&lt;br /&gt;
99 &lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
- mode=755 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
+ mode=777 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
M etc/init.d/networking&lt;br /&gt;
# apk fix openrc&lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
# echo $?&lt;br /&gt;
1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the changes detected and displayed by the audit command.&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Audit command output&lt;br /&gt;
|-&lt;br /&gt;
| - || Details as per Database record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| + ||  Details as per On-disk record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| A ||  File added &lt;br /&gt;
|-&lt;br /&gt;
| d ||  Directory added &lt;br /&gt;
|-  &lt;br /&gt;
| D ||  Directory added (with non-listed files/subdirs) &lt;br /&gt;
|-  &lt;br /&gt;
| e ||  error occured during audit (e.g. no permissions to read file) &lt;br /&gt;
|-&lt;br /&gt;
|  M ||  File metadata changed (uid, gid, or mode) &lt;br /&gt;
|-&lt;br /&gt;
|  m ||  Directory metadata changed &lt;br /&gt;
|-&lt;br /&gt;
|  U ||  File contents modified &lt;br /&gt;
|-&lt;br /&gt;
|  X ||  File deleted &lt;br /&gt;
|-&lt;br /&gt;
|  x || xattrs changed&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
=== Issues due to /usr merge ===&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, for users who have migrated to the [[Repositories#Message_on_/usr_merge|merged /usr]], there are certain known issues like {{Issue|17624|apk audit does not work}}. &lt;br /&gt;
&amp;lt;!-- This entire  section has to be removed at a future date once the issues related to /usr merge are fixed completely --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ERROR:Could not find owner package ====&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[[Repositories#Message_on_/usr_merge|/usr merge]]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32073</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32073"/>
		<updated>2026-02-19T06:45:05Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added example along with explanations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk audit ==&lt;br /&gt;
&lt;br /&gt;
The audit applet audits the system or specified directories for changes compared to the package database. The default option is to audit configuration files only. Options are available to audit all system files or to audit specified directories to detect unauthorized modifications or to identify files/paths to [[Alpine_local_backup#Include_special_files/folders_to_the_apkovl|include them in apkovl]]. &lt;br /&gt;
&lt;br /&gt;
These flags determine which files audit applet will examine. &lt;br /&gt;
    --backup (Default): Only audits files flagged as configuration/protected (those listed in protected_paths.d).&lt;br /&gt;
    --system: Audits all files provided by packages (integrity check) but ignores new/untracked files and skips configuration files.&lt;br /&gt;
    --full: The most comprehensive scan. Use this option to audit all package tracked files and to report all newly added files/directories.&lt;br /&gt;
&lt;br /&gt;
Exit Codes:&lt;br /&gt;
    Exit Code 1 (or 0): The audit completed and found no discrepancies within the specified scope.&lt;br /&gt;
    Exit Code 99: The audit found discrepancies, but they are not being printed because they fall outside the current filter (e.g., a system file was modified but you didn&#039;t use --full). If you see 99 with no output, re-run with --full --details.&lt;br /&gt;
&lt;br /&gt;
The following flags modify the output and provide additional information:&lt;br /&gt;
 --details: Shows the exact metadata differences using + and - symbols.&lt;br /&gt;
 --check-permissions: Includes UID, GID, and Mode in the comparison.&lt;br /&gt;
 --packages: Prints only the packages with changed files. &lt;br /&gt;
&lt;br /&gt;
The packages flag is useful to repair all packages with modified files, by using the command:{{Cmd|&amp;lt;nowiki&amp;gt;# apk audit --packages -q | xargs apk fix&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
By default, the output format is one file per line, for each modified file. A character is printed indicating the line type, followed by a space, then either the affected path or the metadata details. The metadata details usually appears above the relevant file/path. &lt;br /&gt;
&lt;br /&gt;
An optional &amp;lt;path&amp;gt; can be added to limit the audit to a specific directory in all the above cases as can be seen in the example output below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod 777 /etc/init.d/networking&lt;br /&gt;
# apk audit --check-permissions --details /etc/init.d/networking&lt;br /&gt;
# echo $?&lt;br /&gt;
99 &lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
- mode=755 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
+ mode=777 uid=0 gid=0 hash=9fe622bd6d06ed19eb53c1a665343b98f864c5cd&lt;br /&gt;
M etc/init.d/networking&lt;br /&gt;
# apk fix openrc&lt;br /&gt;
# apk audit --check-permissions --details --full |grep -C 3 networking&lt;br /&gt;
# echo $?&lt;br /&gt;
1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following table summarizes the changes detected and displayed by the audit command.&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Audit command output&lt;br /&gt;
|-&lt;br /&gt;
| - || Details as per Database record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| + ||  Details as per On-disk record (shown only with --details flag)&lt;br /&gt;
|-&lt;br /&gt;
| A ||  File added &lt;br /&gt;
|-&lt;br /&gt;
| d ||  Directory added &lt;br /&gt;
|-  &lt;br /&gt;
| D ||  Directory added (with non-listed files/subdirs) &lt;br /&gt;
|-  &lt;br /&gt;
| e ||  error occured during audit (e.g. no permissions to read file) &lt;br /&gt;
|-&lt;br /&gt;
|  M ||  File metadata changed (uid, gid, or mode) &lt;br /&gt;
|-&lt;br /&gt;
|  m ||  Directory metadata changed &lt;br /&gt;
|-&lt;br /&gt;
|  U ||  File contents modified &lt;br /&gt;
|-&lt;br /&gt;
|  X ||  File deleted &lt;br /&gt;
|-&lt;br /&gt;
|  x || xattrs changed&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
=== Issues due to /usr merge ===&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, for users who have migrated to the [[Repositories#Message_on_/usr_merge|merged /usr]], there are certain known issues like {{Issue|17624|apk audit does not work}}. &lt;br /&gt;
&amp;lt;!-- This entire  section has to be removed at a future date once the issues related to /usr merge are fixed completely --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ERROR:Could not find owner package ====&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[[Repositories#Message_on_/usr_merge|/usr merge]]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Alpine_Package_Keeper&amp;diff=32071</id>
		<title>Talk:Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Alpine_Package_Keeper&amp;diff=32071"/>
		<updated>2026-02-19T04:14:47Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added explanation on why the content was moved&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== note on apk update ==&lt;br /&gt;
&lt;br /&gt;
There is an --update-cache or -U option which can be used together with &#039;&#039;apk &amp;lt;anything&amp;gt;&#039;&#039; that will first perform an &#039;&#039;apk update&#039;&#039;. Might be worth mentioning that. --[[User:Ncopa|Ncopa]] 11:02, 16 August 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
There is an --initdb option that does not even show in apk help command. Is this deprecated ? --[[User:Vkrishn|Vkrishn]] ([[User talk:Vkrishn|talk]]) 10:32, 2 May 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
== &amp;quot;Packages and Repositories&amp;quot; section - ftp still being used? ==&lt;br /&gt;
&lt;br /&gt;
The stated section currently has the following example of a valid repo:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;ftp://dl-3.alpinelinux.org/alpine/v2.6/main&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Is the &#039;&#039;&#039;ftp&#039;&#039;&#039; protocol still being used?  &lt;br /&gt;
The passage could then be updated to &amp;quot;v3.7&amp;quot;.&lt;br /&gt;
--[[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 22:43, 19 January 2018 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting -  &amp;quot;apk-tools is old&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
Could the following instruction be added?  This may not yet have been tested on a system that is still exhibiting this error message:&lt;br /&gt;
&lt;br /&gt;
If edge is not tagged, upgrade from one of the edge/main mirrors.  For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;sudo apk add --upgrade apk-tools --update-cache --repository http://dl-2.alpinelinux.org/alpine/edge/main/ --allow-untrusted&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--[[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 04:58, 1 February 2018 (UTC)&lt;br /&gt;
&lt;br /&gt;
== How to use the --virtual parameter ==&lt;br /&gt;
&lt;br /&gt;
As a new user trying to keep a docker image small but needing to compile some packages, it would be very, very helpful to include a detailed explanation of the `--virtual` parameter of `add` with examples of how to use it. I would add it myself but I only know what I&#039;ve read in stackoverflow and, well, you know how reliable that can be… TIA&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[Help:Signature|unsigned]] comment added by [[User:Tedsecretsource|Tedsecretsource]] ([[User talk:Tedsecretsource|{{int:talkpagelinktext}}]] • [[Special:Contributions/Tedsecretsource|{{int:contribslink}}]]) 08:45, 22 January 2023‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== .boot_repository in package cache ==&lt;br /&gt;
&lt;br /&gt;
It seems like the advice about using .boot_repository with the cache directory doesn&#039;t work, since a repository requires an APKINDEX.tar.gz file but the cache has APKINDEX.f00bar.tar.gz files. Should the article be changed, or is this a bug?&lt;br /&gt;
[[User:Dklr433|Dklr433]] ([[User talk:Dklr433|talk]]) 20:01, 4 March 2024 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Repository pinning==&lt;br /&gt;
&lt;br /&gt;
I found the below section in a [https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;amp;oldid=26240#Repository_pinning older version] of this page. But after reading the [https://github.com/alpinelinux/apk-tools/blob/master/doc/apk-world.5.scd manual], i believe the information is wrong. The current content appears as [[Repositories#Tagged repository|tagged repository]]. Can someone please confirm, if my understanding/changes are correct. &lt;br /&gt;
----&lt;br /&gt;
You can specify additional &amp;quot;tagged&amp;quot; repositories {{Cat|/etc/apk/repositories|...&lt;br /&gt;
@personal https:/personal-repo.example.com/alpine-apks/}}&lt;br /&gt;
After which you can &amp;quot;pin&amp;quot; dependencies to these tags using: {{ic|apk add application@personal}}&lt;br /&gt;
apk will by default only use the untagged repositories, but adding a package with a @tag:&lt;br /&gt;
1. will prefer the repository with that tag for the named package, even if a later version of the package is available in another repository&lt;br /&gt;
2. &#039;&#039;allows&#039;&#039; pulling in dependencies for the tagged package from the tagged repository (though it &#039;&#039;prefers&#039;&#039; to use untagged repositories to satisfy dependencies if possible)&lt;br /&gt;
---- [[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 05:32, 24 March 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Issues due to /usr merge==&lt;br /&gt;
&lt;br /&gt;
Dear [[User:John3-16|John3-16]], I have moved the content added by you to a seperate section titled [[Alpine_Package_Keeper#Issues_due_to_/usr_merge|Issues due to /usr merge]] under troubleshooting. Since the /usr merge has been paused as of now and affects only migrated users, let this be kept in a seperate section, so it is easier to remove at a future date, once all related issues are resolved. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 04:14, 19 February 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32070</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32070"/>
		<updated>2026-02-19T04:04:01Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: moved the error related to info command to troubleshooting section and added apk audit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk audit ==&lt;br /&gt;
&lt;br /&gt;
The audit applet audits the system or specified directories for changes compared to the package database. The default option is to audit configuration files only. Options are available to audit all system files or to audit specified directories and files or packages.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
=== Issues due to /usr merge ===&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, for users who have migrated to the [[Repositories#Message_on_/usr_merge|merged /usr]], there are certain known issues like {{Issue|17624|apk audit does not work}}. &lt;br /&gt;
&amp;lt;!-- This entire  section has to be removed at a future date once the issues related to /usr merge are fixed completely --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== ERROR:Could not find owner package ====&lt;br /&gt;
&lt;br /&gt;
The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[[Repositories#Message_on_/usr_merge|/usr merge]]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32067</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32067"/>
		<updated>2026-02-18T13:12:42Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added note to file a bug&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[https://wiki.alpinelinux.org/wiki/Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge /usr merge]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, in order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file and appears when [[Upgrading Alpine Linux to a new release branch]]. When apk-tools solver returns above message, that is always a bug. Please file a bug report [https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues here].&lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for an example on how this error was temporarily resolved.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32066</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32066"/>
		<updated>2026-02-18T06:44:12Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: fixed typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[https://wiki.alpinelinux.org/wiki/Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge /usr merge]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, in order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
When [[Upgrading Alpine Linux to a new release branch]] you may receive the below message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#World|world]] file. &lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for more information.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32065</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32065"/>
		<updated>2026-02-18T06:18:25Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added warning about alpine-base&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
{{Warning|When manually editing world file, do not remove the meta package entry &#039;&#039;&#039;alpine-base&#039;&#039;&#039; or other important entries like &#039;&#039;&#039;linux-*&#039;&#039;&#039; etc. Doing so may render the system unbootable.}}&lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning|The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[https://wiki.alpinelinux.org/wiki/Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge /usr merge]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, in order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
When [[Upgrading Alpine Linux to a new release branch]] you may receive the below message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#world|world]] file. &lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for more information.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32064</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32064"/>
		<updated>2026-02-18T05:59:08Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: /* Huh? Error reporter did not find the broken constraints. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[https://wiki.alpinelinux.org/wiki/Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge /usr merge]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, in order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints===&lt;br /&gt;
&lt;br /&gt;
When [[Upgrading Alpine Linux to a new release branch]] you may receive the below message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#world|world]] file. &lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for more information.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32063</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32063"/>
		<updated>2026-02-18T05:58:53Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added error message based on IRC discussion&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to when used with the {{ic|--who-owns}} option, or simply {{ic|-W}}.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|apk info --who-owns}} command is currently subject to requiring the declaration of a file&#039;s path to be updated in the case where &#039;&#039;&#039;[https://wiki.alpinelinux.org/wiki/Upgrading_Alpine_Linux_to_a_new_release_branch#Upgrading_to_Edge /usr merge]&#039;&#039;&#039; had been previously applied and where, additionally, the file was originally assigned to paths under {{Path|/lib}}, {{Path|/bin}} or {{Path|/sbin}}.  Otherwise, an error is returned, seeing how these are now soft-linked into {{Path|/usr}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ apk info --who-owns /sbin/lbu&lt;br /&gt;
ERROR: /sbin/lbu: Could not find owner package&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further to the [https://alpinelinux.org/posts/2025-10-01-usr-merge.html /usr merge] announcement, in order for this facility to function in such cases, {{Path|/usr}} currently needs to be prepended to the declaration of the path for all such files, seeing how those files are now soft-linked to {{Path|/usr/lib}}, {{Path|/usr/bin}} or {{Path|/usr/sbin}}:  {{cmd|$ apk info --who-owns /usr/sbin/lbu}} &lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
However, if the currently installed &#039;&#039;&#039;&#039;&#039;version&#039;&#039;&#039;&#039;&#039; of the package (say, &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt; version &amp;lt;var&amp;gt;1.2.3-r4&amp;lt;/var&amp;gt;) is no longer available in the operating system&#039;s repositories (i.e. the repos specified in {{Path|/etc/apk/repositories}}) following the latest system update, then &#039;&#039;&#039;apk fix&#039;&#039;&#039; will not fix the package and will report &#039;&#039;&amp;quot;[APK unavailable, skipped]&amp;quot;&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ doas apk fix &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;&lt;br /&gt;
(1/1) [APK unavailable, skipped] Reinstalling foo (1.2.3-r4)}}&lt;br /&gt;
&lt;br /&gt;
This outcome applies both with &#039;&#039;&#039;apk v3&#039;&#039;&#039; and &#039;&#039;&#039;v2&#039;&#039;&#039;, and includes cases where either a higher or lower version of the package is found in the employed repos.  In such cases where a different version exists, consider replacing the package using the [[Alpine_Package_Keeper#Add_a_local_Package|{{ic|apk upgrade --available}}]] command, which will either upgrade or downgrade &#039;&#039;all packages&#039;&#039; to the versions currently offered. &lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== Huh? Error reporter did not find the broken constraints.===&lt;br /&gt;
&lt;br /&gt;
When [[Upgrading Alpine Linux to a new release branch]] you may receive the below message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
Huh? Error reporter did not find the broken constraints.&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above message can be due to version conflicts caused by a software package present in the [[#world|world]] file. &lt;br /&gt;
&lt;br /&gt;
To identify the offending software package, take a backup of the world file, then take stuff out of world until the upgrade works. Or alternatively, begin with a minimal version of world file and add things until it breaks again. &lt;br /&gt;
&lt;br /&gt;
Once the upgrade is done, you may be able to add back the offending software package, if supported in the newer version.&lt;br /&gt;
&lt;br /&gt;
Check the [https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log IRC logs] dated 2026-02-18 for more information.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32058</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32058"/>
		<updated>2026-02-17T09:57:06Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: add wikitag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; command:&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;$ apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32057</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32057"/>
		<updated>2026-02-17T09:53:17Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: replaced the command with a simpler alternative&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; commands. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apk --installed query --format json --fields name,installed-size &#039;*&#039;|jq -r &#039;.[] | [.&amp;quot;installed-size&amp;quot;, .&amp;quot;name&amp;quot;] | @tsv&#039; | sort -nr&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32056</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=32056"/>
		<updated>2026-02-17T07:12:16Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: based on irc discusion on 2026-02-17  - https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List packages by installed size ===&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk query}}&lt;br /&gt;
The below command lists all installed packages by installed size. It requires {{pkg|jq}} package and uses [[#apk query|query]] option. Use the below command with &amp;lt;Code&amp;gt;less&amp;lt;/Code&amp;gt; or &amp;lt;Code&amp;gt;head&amp;lt;/Code&amp;gt; commands. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apk query --installed --format json --fields name,installed-size &#039;*&#039; | jq -r &#039;.[] | (.[&amp;quot;installed-size&amp;quot;] // 0) as $s | (if $s &amp;gt;= 1048576 then &amp;quot;\($s/1048576|round) MB&amp;quot; elif $s &amp;gt; 0 then &amp;quot;\($s/1024|round) KB&amp;quot; else &amp;quot;0 B&amp;quot; end) as $f | &amp;quot;\($s)\t\($f)\t\(.name)&amp;quot;&#039; | sort -nr | cut -f2- | expand -t 15&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32047</id>
		<title>System Disk Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32047"/>
		<updated>2026-02-13T18:00:55Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: fixed wikitag as per Help:Editing page and added wikilink&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;System Disk mode is the traditional or classic harddisk installation of Alpine Linux. This installation mode is suitable for most use cases including generic [[Tutorials_and_Howtos#Desktop|desktop]], [[Setting up the build environment|development machine]] etc. &lt;br /&gt;
&lt;br /&gt;
If an entire hard disk(s) is available for Alpine Linux, [[Installation#setup-alpine_based_System_Disk_Install|setup-alpine based install]] is the recommended way to install Alpine Linux. For all other use cases, follow the [[Alpine_setup_scripts#setup-disk|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] based Installation given below.&lt;br /&gt;
&lt;br /&gt;
== setup-disk based Installation ==&lt;br /&gt;
&lt;br /&gt;
To perform a traditional hard-disk installation of Alpine Linux, after completing the base configuration, proceed to create, format and mount your partitions with MOUNTPOINT {{Path|&#039;&#039;&#039;/mnt&#039;&#039;&#039;}} as root and run the command {{Codeline|&#039;&#039;&#039;&amp;lt;Code&amp;gt;setup-disk -m sys /mnt&amp;lt;/Code&amp;gt;&#039;&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
# Follow the [[Installation#General_course_of_action|Installation guide]] to complete the [[Installation#Base_configuration|base configuration]], if not already done. A working [[Configure_Networking#Connectivity_testing|Internet access]] is mandatory to complete this installation.&lt;br /&gt;
# If necessary formatted partition(s) are unavailable, manually [[Setting up disks manually#Creating_partitions|create]] them first and [[Setting up disks manually#Formatting_partitions|format]] them including swap partition(if used). If you&#039;re using legacy BIOS mode, use DOS i.e MBR partition table and ensure that proper partition is bootable for [[Bootloaders#Syslinux|extlinux]].&lt;br /&gt;
# Mount the &#039;&#039;&#039;/ (root)&#039;&#039;&#039;  partition on a mount point i.e say {{Path|/mnt}} as follows: {{Cmd|# mount /dev/sdXY /mnt}}&lt;br /&gt;
# If you&#039;re using [[UEFI|EFI]], create a mount point &amp;lt;code&amp;gt;/mnt/boot&amp;lt;/code&amp;gt; and mount the EFI system partition(ESP) on it. {{Cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/boot&lt;br /&gt;
# mount /dev/sdXY /mnt/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# If [[Swap|swap]] partition is available, you can also enable it now: {{Cmd|# swapon /dev/sdXY }}&lt;br /&gt;
# Install Alpine Linux using the following command: {{Cmd|# setup-disk -m sys /mnt}}&lt;br /&gt;
# &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will perform a traditional hard disk install of your running system, detects your file system layout and generates {{Path|/etc/fstab}} and installs a [[Bootloaders|bootloader]] based on the &amp;lt;Code&amp;gt;BOOTLOADER&amp;lt;/Code&amp;gt; [[Alpine_setup_scripts#Environment_Variables|environment variable]].&lt;br /&gt;
# At the end of Installation, you can [[Installation#Reboot|reboot]] to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Mounting on /dev/sdXY sysroot failed ===&lt;br /&gt;
&lt;br /&gt;
The error message appears as follows with variations in &amp;lt;code&amp;gt;/dev/sda8&amp;lt;/code&amp;gt; depending on the partition number and SSD/HDD etc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
mounting /dev/sda8 on /sysroot failed: No such file or directory&lt;br /&gt;
mounting root: failed&lt;br /&gt;
initramfs emergency recovery shell launched. Type &#039;exit&#039; to continue boot&lt;br /&gt;
sh: can&#039;t access tty: job control turned off&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message can be caused by various reasons. Follow the below steps in the emergency shell to identify one possible cause.&lt;br /&gt;
&lt;br /&gt;
# Verify that the partition name in which Alpine Linux was installed matches the above [[#Mounting on /dev/sdXY sysroot failed|error]] by issuing the command and also note down the filesystem type of that partition (say TYPE=&amp;quot;ext4&amp;quot;) : {{Cmd| blkid}}&lt;br /&gt;
# If the expected disk (e.g., /dev/sda, /dev/nvme0n1) itself is missing in the output of {{ic| blkid}}, check [[#Disks not detected after setup-disk|Disks not detected after setup-disk]].&lt;br /&gt;
# Verify that sysroot exists by issuing the command. {{Cmd|ls -ld /sysroot}}&lt;br /&gt;
# Check if the above error message apears when issuing the command. {{Cmd|mount /dev/sda8 /sysroot}}&lt;br /&gt;
# If there is no error message, proceed to check if the issue is caused by a [[#Filesystem corruption|filesystem corruption]].&lt;br /&gt;
# If the manual mount command fails with &amp;quot;No such file or directory&amp;quot; even though you verified /sysroot exists in Step 3, this confirms the kernel doesn&#039;t recognize the filesystem type. Check whether filesystem modules(change ext4 if needed) are loaded by issuing the command. {{Cmd|&amp;lt;nowiki&amp;gt;lsmod | grep ext4 &amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
# If there is no output, then it confirms that the above [[#Mounting on /dev/sdXY sysroot failed|issue]] is caused by [[#Missing filesystem modules in the kernel cmdline|missing filesystem module]].&lt;br /&gt;
&lt;br /&gt;
==== Disks not detected after setup-disk====&lt;br /&gt;
&lt;br /&gt;
After running the standard Alpine installation command: {{ic|setup-disk -m sys /mnt}} and rebooting, the system gives the error mentioned in [[#Mounting on /dev/sdXY sysroot failed|Mounting on /dev/sdXY sysroot failed]] with the expected disk (e.g., /dev/sda, /dev/nvme0n1) missing to show at the output of {{ic| blkid}}. This prevents booting into the installed system. &lt;br /&gt;
&lt;br /&gt;
Issue: As per [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10615 bug report] this might be caused by BIOS storage controller being set to &amp;quot;RAID On (Intel Rapid Storage Technology)&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
Resolution: Switch the storage mode in BIOS/UEFI: Go to BIOS → Storage or SATA/NVMe Operation. Change setting from:RAID On (Intel Rapid Storage Technology) to: AHCI or AHCI/NVMe.&lt;br /&gt;
&lt;br /&gt;
==== Missing filesystem modules in the kernel cmdline ====&lt;br /&gt;
&lt;br /&gt;
[[BusyBox]] mount command does not autoload modules, so need to add filesystem modules to the kernel cmdline. Even though alpine installer does this automatically, this has to be taken care of in case of manual disk install, particularly for [[Dualbooting|dualboot]] installations.&lt;br /&gt;
&lt;br /&gt;
# To resolve, issue the command to load the appropriate filesystem module(say TYPE=&amp;quot;ext4&amp;quot;).{{Cmd|modprobe ext4}}&lt;br /&gt;
# To verify if the issue is resolved, reissue the command.{{Cmd|mount /dev/sda8 /sysroot}} &lt;br /&gt;
# If mount succeeded, issue the following command to boot into Alpine Linux. {{Cmd|exit}}&lt;br /&gt;
&lt;br /&gt;
Choose the appropriate solution based on your use case for a permanent fix:&lt;br /&gt;
&lt;br /&gt;
*If you are using [[Bootloaders#GRUB|grub]], then ensure that {{Codeline|GRUB_CMDLINE_LINUX}} line in the file {{Path|/etc/default/grub}} has the appropriate filesystem module &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
GRUB_CMDLINE_LINUX=&amp;quot;console=ttyS0,19200n8 net.ifnames=0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
* If you are using [[Bootloaders#Syslinux|ExtLinux/SysLinux]], then ensure that {{Codeline|APPEND}} line in the file {{Path|/boot/extlinux.conf}} has &amp;lt;code&amp;gt;root=UUID=&amp;lt;UUID ID&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;root=/dev/sdXY&amp;lt;/code&amp;gt; and the same matches the root path in the {{Path|/etc/fstab}} file. Also ensure that modules has the appropriate filesystem like &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/boot/extlinux.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
APPEND root=/dev/sdXY modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
# root=UUID=&amp;lt;UUID ID&amp;gt; can be used also in the APPEND Line.&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|For both above cases, you may need to issue {{Codeline|update-grub}} or {{Codeline|update-extlinux}} after making above changes.}}&lt;br /&gt;
 &lt;br /&gt;
*For a solution independent of [[Bootloaders|bootloaders]], ensure that the file {{Path|/etc/mkinitfs/mkinitfs.conf}} has the necessary filesystem module in it. Refer [[Initramfs init|Initramfs]] page for more information and recreate initramfs image.&lt;br /&gt;
&lt;br /&gt;
==== Filesystem corruption ====&lt;br /&gt;
&lt;br /&gt;
To fix filesystem corruption issues, the command fsck must be run on the root partition. The root partition should be umounted before running fsck. Boot from a [[Rescue disk]] to run the fsck command on the root partition:{{Cmd|&amp;lt;nowiki&amp;gt;# fsck -y /dev/&amp;lt;DEVICE&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After running fsck, proceed to Reboot the Computer.&lt;br /&gt;
&lt;br /&gt;
If the fsck Command does Fix the Corruption on the Root File System but the &#039;&#039;&#039;Error: Mounting Root Failed&#039;&#039;&#039; still persists then the next step would be to ReBuild the &#039;&#039;&#039;initramfs&#039;&#039;&#039; File System with the &#039;&#039;&#039;mkinitfs&#039;&#039;&#039; Command then Reboot. You need to &#039;&#039;&#039;Mount the Root Partition&#039;&#039;&#039; and [[Chroot]] into the Mounted Root Partition before running the mkinitfs Command as shown in the [[Initramfs init|initramfs]] page. &lt;br /&gt;
&lt;br /&gt;
==== Check File System Kernel Modules are Loading ====&lt;br /&gt;
&lt;br /&gt;
Run the below command to output the File System Kernel modules, where the file system can be one among the following: &#039;&#039;&#039;ext2&#039;&#039;&#039;, &#039;&#039;&#039;ext3&#039;&#039;&#039;, &#039;&#039;&#039;ext4&#039;&#039;&#039;, &#039;&#039;&#039;btrfs&#039;&#039;&#039;, &#039;&#039;&#039;xfs&#039;&#039;&#039;, &#039;&#039;&#039;fat&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# lsmod | grep &amp;lt;File System&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An example output is given below for the above command, with necessary abbreviations explained:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
alpinepc:~# lsmod | grep ext4&lt;br /&gt;
&lt;br /&gt;
ext4                 1155072  2&lt;br /&gt;
crc16                  12288  1 ext4&lt;br /&gt;
mbcache                16384  1 ext4&lt;br /&gt;
jbd2                  200704  1 ext4&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
EXT4 = [[Filesystems|File System]]&amp;lt;br&amp;gt;&lt;br /&gt;
CRC16 = EXT4 Compression Support&amp;lt;br&amp;gt;&lt;br /&gt;
MBCACHE = MetaData Cache&amp;lt;br&amp;gt;&lt;br /&gt;
JBD2 = Journaling&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Blinking underscore ===&lt;br /&gt;
&lt;br /&gt;
On a UEFI system, at the end of Installation after rebooting, the computer screen may appear with a &#039;&#039;&#039;blinking underscore&#039;&#039;&#039;. This may be due to the firmware not finding a valid boot entry.&lt;br /&gt;
&lt;br /&gt;
The [[UEFI#EFI bootloaders|EFI bootloader]] entries are added without writing to NVRAM, thus preventing GRUB from calling {{ic|efibootmgr}}. In some cases the UEFI firmware may not boot from a bootloader without a valid NVRAM entry. In such cases, at the end of installation, instead of rebooting, manually add an entry for Alpine Linux in the NVRAM as follows:&lt;br /&gt;
* Install the {{pkg|efibootmgr}} package:{{Cmd|# apk add efibootmgr}}&lt;br /&gt;
* Adjust the device name {{ic|/dev/sdX}} and partition number {{ic|1}}, before issuing the command: {{Cmd|# efibootmgr --create --disk /dev/sdX --part 1 --label &amp;quot;Alpine&amp;quot; --loader &#039;\EFI\alpine\grubx64.efi&#039;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Bootloaders]] - For information on GRUB, Syslinux and rEFInd&lt;br /&gt;
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]&lt;br /&gt;
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32045</id>
		<title>Bootloaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32045"/>
		<updated>2026-02-12T04:14:34Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added limine and moved grub and refind as refind is still in testing repository as of 3.23&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;bootloader&#039;&#039; is a computer program that is responsible for booting a computer. In the case where it also provides an interactive menu with multiple boot choices, then it&#039;s often called a &#039;&#039;boot manager&#039;&#039;. This page shows the basic steps that you need to perform if, for any reason, you want to switch bootloaders or to apply some manual configuration.&lt;br /&gt;
&lt;br /&gt;
The following bootloaders are available in Alpine Linux:-&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#Syslinux|Syslinux]]&amp;lt;/code&amp;gt; is the default lightweight bootloader used in Alpine Linux when booting the Alpine Installer ISO.  It is also the bootloader when creating a Live USB/CD/ISOLinux/PXELinux.  Supports the Filesystems: FAT12/16/32&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#Extlinux|Extlinux]]&amp;lt;/code&amp;gt; is the default lightweight bootloader used in Alpine Linux when Installing the Alpine OS to Disk via BIOS/Legacy Boot.  Supports the Filesystems: EXT2/3/4, BTRFS, XFS&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#GRUB|GRUB]]&amp;lt;/code&amp;gt; is a standard Linux bootloader used in Alpine Linux when Installing the Alpine OS to Disk via UEFI.&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#Limine|Limine]]&amp;lt;/code&amp;gt; is a modern, advanced, portable, multiprotocol bootloader and boot manager.&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#EFI_Boot_Stub|EFI Boot Stub]]&amp;lt;/code&amp;gt; allows for booting Linux directly from a motherboard supporting &#039;&#039;UEFI&#039;&#039; or from another bootloader.&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#rEFInd|rEFInd]]&amp;lt;/code&amp;gt; is an easy-to-use &#039;&#039;EFI&#039;&#039; boot menu that allows booting different operating systems.&amp;lt;br&amp;gt;&lt;br /&gt;
* [[UEFI Secure Boot]] uses {{pkg|systemd-efistub}} or {{pkg|stubbyboot-efistub}}.&lt;br /&gt;
&lt;br /&gt;
A [[#Using a UKI|Unified Kernel Image (UKI)]] is additionally supported, available  for UEFI only. It is a UEFI executable that can be useful in [https://uapi-group.org/specifications/specs/unified_kernel_image/ certain use cases], including secure boot, clouds and containers.&lt;br /&gt;
&lt;br /&gt;
Note that {{pkg|gummiboot}} is a &#039;&#039;deprecated&#039;&#039; UEFI boot manager that was originally able to leverage UEFI firmware and detect bootable images such as Linux kernels that have an EFI stub on the EFI System Partition (ESP).  The [https://cgit.freedesktop.org/gummiboot/ gummiboot project] was discontinued in 2015 and renamed as {{Pkg|systemd-boot}} for systemd systems and is only available in Alpine Linux in the [[Repositories#Testing|testing repository]].  As it had no runtime dependencies, &#039;&#039;&#039;gummiboot&#039;&#039;&#039; was appreciated for its simplicity as a lightweight, minimal UEFI boot solution.  Its UEFI stub, {{pkg|gummiboot-efistub}}, was used [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|to generate a Unified Kernel Images (UKIs)]] e.g. for [[DM-verity]] and Secure Boot, but [[Release_Notes_for_Alpine_3.22.0#Secure_Boot_and_Gummiboot|it has been deprecated since Alpine Linux 3.22]] and is no longer maintained;  it has been replaced by &#039;&#039;&#039;systemd-efistub&#039;&#039;&#039; (note that the latter package [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|only supplies EFI stub binaries]] and doesn’t depend on any systemd components).&lt;br /&gt;
&lt;br /&gt;
== Syslinux ==&lt;br /&gt;
&lt;br /&gt;
If you want to switch from another bootloader back to &#039;&#039;Syslinux&#039;&#039;, or if for some reason you want to install Syslinux manually, then the following steps are required.&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|syslinux}} package:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add syslinux}}&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using GPT partitions, then install the &#039;&#039;GPT MBR&#039;&#039; onto the drive that you want to install the bootloader on (in this case, {{path|/dev/sda}}):&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, if you&#039;re using DOS partitions, then install the &#039;&#039;DOS MBR&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&amp;lt;!-- See also: http://www.syslinux.org/wiki/index.php?title=Mbr --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, install the required Syslinux binaries. Despite being called &amp;lt;code&amp;gt;extlinux&amp;lt;/code&amp;gt;, Syslinux supports booting from FAT12/16/32, NTFS, ext2/3/4, [[Btrfs|btrfs]], XFS and UFS/FFS filesystems.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# syslinux --install /boot}}&lt;br /&gt;
&lt;br /&gt;
The configuration file is located in {{path|/boot/syslinux/syslinux.cfg}}. &lt;br /&gt;
&lt;br /&gt;
Alpine Linux ships with a script, &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, that automatically (re)generates this file, for example, on updates to Syslinux. The settings for this script can be found in {{path|/etc/update-extlinux.conf}}, including the option to disable automatic overwriting of {{path|/boot/extlinux.conf}}. &lt;br /&gt;
&lt;br /&gt;
You can also edit and add additional menu entries in the bootloader configuration file for dual booting multiple os&#039;s: {{path|/boot/syslinux/syslinux.cfg}}&lt;br /&gt;
&lt;br /&gt;
=== Using EFI with syslinux ===&lt;br /&gt;
&lt;br /&gt;
The Alpine Linux installer automatically uses [[#GRUB|GRUB]] if EFI mode is detected. The section below is specifically about using EFI with Syslinux.&lt;br /&gt;
&lt;br /&gt;
Assuming that {{path|/mnt}} is a FAT32 partition of type EF00 and that {{path|/boot}} belongs to the rootfs created after running &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/EFI/syslinux&lt;br /&gt;
# cp /usr/share/syslinux/efi64/* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/extlinux.conf /mnt/EFI/syslinux/syslinux.cfg&lt;br /&gt;
# cp /boot/vmlinuz* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/initramfs* /mnt/EFI/syslinux/&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You may need to modify {{path|/mnt/EFI/syslinux/syslinux.cfg}} to change the paths to absolute paths (just add a / in front of the vmlinuz/initramfs entries), or copy the files to {{path|/mnt/EFI/syslinux}} instead (XXX: untested).&lt;br /&gt;
&lt;br /&gt;
In the end, the {{path|/mnt/EFI/syslinux/syslinux.cfg}} file should look like this:&lt;br /&gt;
&lt;br /&gt;
{{cat|/mnt/EFI/syslinux/syslinux.cfg|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
DEFAULT menu.c32&lt;br /&gt;
PROMPT 0&lt;br /&gt;
MENU TITLE Alpine/Linux Boot Menu&lt;br /&gt;
MENU HIDDEN&lt;br /&gt;
MENU AUTOBOOT Alpine will be booted automatically in # seconds&lt;br /&gt;
TIMEOUT 10&lt;br /&gt;
LABEL lts&lt;br /&gt;
  MENU DEFAULT&lt;br /&gt;
  MENU LABEL Linux lts&lt;br /&gt;
  LINUX /vmlinuz-lts&lt;br /&gt;
  INITRD /initrd-lts&lt;br /&gt;
  APPEND root=/dev/sda3 modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Finally, add &amp;lt;code&amp;gt;syslinux&amp;lt;/code&amp;gt; to the EFI boot menu.  Assuming that {{path|/dev/sda}} is your hard drive —&#039;&#039;&#039;&#039;&#039;be careful to check first what is its path on your device and to adjust accordingly&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk add efibootmgr&lt;br /&gt;
# efibootmgr -c -d /dev/sda -p 1 -l \\EFI\\syslinux\\syslinux.efi -L &amp;quot;ALPINE-SYSLINUX&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can now verify that the boot entry has been added:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;efibootmgr&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BootCurrent: 0001&lt;br /&gt;
Timeout: 0 seconds&lt;br /&gt;
BootOrder: 0001,0000,0002,...&lt;br /&gt;
Boot001* ALPINE-SYSLINUX HD(1,GPT,xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)/FILE(\EFI\syslinux\syslinux.efi)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRUB ==&lt;br /&gt;
&lt;br /&gt;
To install GRUB in BIOS mode, (optionally) remove the Syslinux package and install the required GRUB packages:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk del syslinux&lt;br /&gt;
# apk add grub grub-bios&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For EFI, install GRUB&#039;s EFI package instead. Note that {{path|/boot}} has to be an EFI-compatible filesystem, such as FAT32.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add grub-efi efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Next, install the MBR and GRUB binaries to disk for BIOS mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-install /dev/vda}}&lt;br /&gt;
&lt;br /&gt;
For EFI mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# grub-install --target=x86_64-efi --efi-directory=/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Then, add this line to {{path|/etc/default/grub}}:&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;# GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;quiet rootfstype=ext4 modules=sd-mod,usb-storage,ext4&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
GRUB ships with an automatic configuration generator, including some automatic detection of other operating systems installed on the device:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
This script can be configured via the {{path|/etc/default/grub}} file. &lt;br /&gt;
&lt;br /&gt;
If the font in the GRUB boot screen appears too small, then [[Fonts#Changing_GRUB_font_and_font_size|change the GRUB font]].&lt;br /&gt;
&lt;br /&gt;
Consult [https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html gnu.org&#039;s online manual] for a list of available &amp;lt;code&amp;gt;grub-mkconfig&amp;lt;/code&amp;gt; configuration options.&lt;br /&gt;
&lt;br /&gt;
== Limine ==&lt;br /&gt;
&lt;br /&gt;
[https://codeberg.org/Limine/Limine Limine] is a modern, advanced, portable, multiprotocol bootloader and boot manager, also used as the reference implementation for the Limine boot protocol. It supports partitioning schemes like MBR, GPT and  Unpartitioned media.&lt;br /&gt;
&lt;br /&gt;
== EFI Boot Stub ==&lt;br /&gt;
&lt;br /&gt;
To boot directly from your motherboard&#039;s UEFI boot menu, a boot entry needs to be created either with a UEFI shell or with &#039;&#039;efibootmgr&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== efibootmgr ===&lt;br /&gt;
&lt;br /&gt;
Install {{Pkg|efibootmgr}}:&lt;br /&gt;
{{cmd|# apk add efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Create a boot entry. It is recommended to do this in a script, as efibootmgr does not allow for editing entries.&lt;br /&gt;
&lt;br /&gt;
{{cat|add-bootentry|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
params=&amp;quot;root=/dev/sdXZ rootfstype=ext4 rw \&lt;br /&gt;
  initrd=\intel-ucode.img \&lt;br /&gt;
  initrd=\initramfs-lts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
efibootmgr --create --label &amp;quot;Alpine Linux&amp;quot; \&lt;br /&gt;
  --disk /dev/sdX --part Y \&lt;br /&gt;
  --loader /vmlinuz-lts \&lt;br /&gt;
  --unicode &amp;quot;${params}&amp;quot; \&lt;br /&gt;
  --verbose&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Where {{path|/dev/sdXY}} contains the EFI partition and {{path|/dev/sdXZ}} contains the root partition. If you are using {{Pkg|linux-stable}}, then replace &amp;lt;code&amp;gt;lts&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;stable&amp;lt;/code&amp;gt; in the script.&lt;br /&gt;
&lt;br /&gt;
{{Tip|If you&#039;re modifying EFI records from a running system (e. g. migrating from GRUB), you can populate {{ic|$params}} from {{ic|/proc/cmdline}}. Make sure to append {{ic|initrd}} param if it&#039;s missing since GRUB does not add it to the command line.}}&lt;br /&gt;
&lt;br /&gt;
{{Note| The kernel contains the [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/init/do_mounts.c#n254 exhaustive list] of ways to specify the block device. For a more robust boot entry, it is recommended to use a persistent name such as the PARTUUID.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Optionally, set the newly-created entry as the default:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# efibootmgr -n XXXX}}&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;XXXX&amp;lt;/code&amp;gt; is the boot number of the new entry.&lt;br /&gt;
&lt;br /&gt;
{{Note| The loader and initrd file arguments are relative to the EFI partition. In a default installation, Alpine Linux places these files in {{path|/boot/}}, while EFI is mounted to {{path|/boot/efi/}}. You can either update &amp;lt;code&amp;gt;fstab&amp;lt;/code&amp;gt; to mount EFI at {{path|/boot/}}, or manually copy them to {{path|/boot/efi/}}.                                                                                           }}&lt;br /&gt;
&lt;br /&gt;
== rEFInd ==&lt;br /&gt;
{{Main|rEFInd}}&lt;br /&gt;
&lt;br /&gt;
[[rEFInd]] provides a graphical boot menu for [[UEFI]] systems.&lt;br /&gt;
== Using a UKI  ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://github.com/uapi-group/specifications/blob/main/specs/unified_kernel_image.md#unified-kernel-image-uki Unified Kernel Image]&#039;&#039;&#039; (UKI) is supported in UEFI only. It is possible to boot directly into a UKI. A UKI is a single file that contains the initfs, kernel and cmdline. &lt;br /&gt;
&lt;br /&gt;
The [[UEFI Secure Boot]] page contains the instructions for setting up an a UKI.  While this is typically done in order to &#039;&#039;SecureBoot&#039;&#039;, it is perfectly feasible to skip enrolling the custom keys and to leave SecureBoot off. &lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to install the UKI in the default fallback path used by most UEFI implementations. By installing the UKI into this path, the system will automatically boot into it if no other entries are defined. This can be automated as part of the kernel hook by adding the following to {{path|/etc/kernel-hooks.d/secureboot.conf}} :&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/kernel-hooks.d/secureboot.conf|&amp;lt;nowiki&amp;gt;# For the stable kernel, install the UKI into the default UEFI path.&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;stable&amp;quot; ]; then&lt;br /&gt;
  output_dir=&amp;quot;/efi/EFI/Boot/&amp;quot;&lt;br /&gt;
  output_name=&amp;quot;bootx64.efi&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|  {{path|bootx64.efi}} is only correct for &amp;lt;code&amp;gt;x86_64&amp;lt;/code&amp;gt; systems. For other architectures, the exact name will vary.}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
Since bootloaders are installed only during [[System Disk Mode]], the errors related to them are documented in [[System Disk Mode#Troubleshooting|that page]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Silent boot]]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Bootloader Gentoo Wiki - Bootloaders]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader Archwiki - Boot loader]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/Category:Bootloaders PostmarketOS Wiki - Bootloaders]&lt;br /&gt;
* [https://docs.u-boot.org/en/latest/develop/release_cycle.html u-boot.org docs - U-Boot Release Cycle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32032</id>
		<title>Bootloaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32032"/>
		<updated>2026-02-10T15:17:22Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: fixed typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;bootloader&#039;&#039; is a computer program that is responsible for booting a computer. In the case where it also provides an interactive menu with multiple boot choices, then it&#039;s often called a &#039;&#039;boot manager&#039;&#039;. This page shows the basic steps that you need to perform if, for any reason, you want to switch bootloaders or to apply some manual configuration.&lt;br /&gt;
&lt;br /&gt;
The following bootloaders are available in Alpine Linux:-&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#Syslinux|Syslinux]]&amp;lt;/code&amp;gt; is the default lightweight bootloader used in Alpine Linux.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#rEFInd|rEFInd]]&amp;lt;/code&amp;gt; is an easy-to-use &#039;&#039;EFI&#039;&#039; boot menu that allows booting different operating systems.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#GRUB|GRUB]]&amp;lt;/code&amp;gt; is a standard Linux bootloader.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#EFI_Boot_Stub|EFI Boot Stub]]&amp;lt;/code&amp;gt; allows for booting Linux directly from a motherboard supporting &#039;&#039;UEFI&#039;&#039; or from another bootloader.&amp;lt;br&amp;gt;&lt;br /&gt;
* [[UEFI Secure Boot]] uses {{pkg|systemd-efistub}} or {{pkg|stubbyboot-efistub}}.&lt;br /&gt;
&lt;br /&gt;
A [[#Using a UKI|Unified Kernel Image (UKI)]] is additionally supported, available  for UEFI only. It is a UEFI executable that can be useful in [https://uapi-group.org/specifications/specs/unified_kernel_image/ certain use cases], including secure boot, clouds and containers.&lt;br /&gt;
&lt;br /&gt;
Note that {{pkg|gummiboot}} is a &#039;&#039;deprecated&#039;&#039; UEFI boot manager that was originally able to leverage UEFI firmware and detect bootable images such as Linux kernels that have an EFI stub on the EFI System Partition (ESP).  The [https://cgit.freedesktop.org/gummiboot/ gummiboot project] was discontinued in 2015 and renamed as {{Pkg|systemd-boot}} for systemd systems and is only available in Alpine Linux in the [[Repositories#Testing|testing repository]].  As it had no runtime dependencies, &#039;&#039;&#039;gummiboot&#039;&#039;&#039; was appreciated for its simplicity as a lightweight, minimal UEFI boot solution.  Its UEFI stub, {{pkg|gummiboot-efistub}}, was used [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|to generate a Unified Kernel Images (UKIs)]] e.g. for [[DM-verity]] and Secure Boot, but [[Release_Notes_for_Alpine_3.22.0#Secure_Boot_and_Gummiboot|it has been deprecated since Alpine Linux 3.22]] and is no longer maintained;  it has been replaced by &#039;&#039;&#039;systemd-efistub&#039;&#039;&#039; (note that the latter package [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|only supplies EFI stub binaries]] and doesn’t depend on any systemd components).&lt;br /&gt;
&lt;br /&gt;
== Syslinux ==&lt;br /&gt;
&lt;br /&gt;
If you want to switch from another bootloader back to &#039;&#039;Syslinux&#039;&#039;, or if for some reason you want to install Syslinux manually, then the following steps are required.&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|syslinux}} package:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add syslinux}}&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using GPT partitions, then install the &#039;&#039;GPT MBR&#039;&#039; onto the drive that you want to install the bootloader on (in this case, {{path|/dev/sda}}):&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, if you&#039;re using DOS partitions, then install the &#039;&#039;DOS MBR&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&amp;lt;!-- See also: http://www.syslinux.org/wiki/index.php?title=Mbr --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, install the required Syslinux binaries. Despite being called &amp;lt;code&amp;gt;extlinux&amp;lt;/code&amp;gt;, Syslinux supports booting from FAT12/16/32, NTFS, ext2/3/4, [[Btrfs|btrfs]], XFS and UFS/FFS filesystems.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# extlinux --install /boot}}&lt;br /&gt;
&lt;br /&gt;
The configuration file is located in {{path|/boot/extlinux.conf}}. &lt;br /&gt;
&lt;br /&gt;
Alpine Linux ships with a script, &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, that automatically (re)generates this file, for example, on updates to Syslinux. The settings for this script can be found in {{path|/etc/update-extlinux.conf}}, including the option to disable automatic overwriting of {{path|/boot/extlinux.conf}}. &lt;br /&gt;
&lt;br /&gt;
You can also place additional menu entries in the {{path|/etc/update-extlinux.d/}} directory e.g. for dual booting.&lt;br /&gt;
&lt;br /&gt;
=== Using EFI with syslinux ===&lt;br /&gt;
&lt;br /&gt;
The Alpine Linux installer automatically uses [[#GRUB|GRUB]] if EFI mode is detected. The section below is specifically about using EFI with Syslinux.&lt;br /&gt;
&lt;br /&gt;
Assuming that {{path|/mnt}} is a FAT32 partition of type EF00 and that {{path|/boot}} belongs to the rootfs created after running &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/EFI/syslinux&lt;br /&gt;
# cp /usr/share/syslinux/efi64/* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/extlinux.conf /mnt/EFI/syslinux/syslinux.cfg&lt;br /&gt;
# cp /boot/vmlinuz* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/initramfs* /mnt/EFI/syslinux/&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You may need to modify {{path|/mnt/EFI/syslinux/syslinux.cfg}} to change the paths to absolute paths (just add a / in front of the vmlinuz/initramfs entries), or copy the files to {{path|/mnt/EFI/syslinux}} instead (XXX: untested).&lt;br /&gt;
&lt;br /&gt;
In the end, the {{path|/mnt/EFI/syslinux/syslinux.cfg}} file should look like this:&lt;br /&gt;
&lt;br /&gt;
{{cat|/mnt/EFI/syslinux/syslinux.cfg|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
DEFAULT menu.c32&lt;br /&gt;
PROMPT 0&lt;br /&gt;
MENU TITLE Alpine/Linux Boot Menu&lt;br /&gt;
MENU HIDDEN&lt;br /&gt;
MENU AUTOBOOT Alpine will be booted automatically in # seconds&lt;br /&gt;
TIMEOUT 10&lt;br /&gt;
LABEL lts&lt;br /&gt;
  MENU DEFAULT&lt;br /&gt;
  MENU LABEL Linux lts&lt;br /&gt;
  LINUX /vmlinuz-lts&lt;br /&gt;
  INITRD /initrd-lts&lt;br /&gt;
  APPEND root=/dev/sda3 modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Finally, add &amp;lt;code&amp;gt;syslinux&amp;lt;/code&amp;gt; to the EFI boot menu.  Assuming that {{path|/dev/sda}} is your hard drive —&#039;&#039;&#039;&#039;&#039;be careful to check first what is its path on your device and to adjust accordingly&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk add efibootmgr&lt;br /&gt;
# efibootmgr -c -d /dev/sda -p 1 -l \\EFI\\syslinux\\syslinux.efi -L &amp;quot;ALPINE-SYSLINUX&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can now verify that the boot entry has been added:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;efibootmgr&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BootCurrent: 0001&lt;br /&gt;
Timeout: 0 seconds&lt;br /&gt;
BootOrder: 0001,0000,0002,...&lt;br /&gt;
Boot001* ALPINE-SYSLINUX HD(1,GPT,xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)/FILE(\EFI\syslinux\syslinux.efi)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== rEFInd ==&lt;br /&gt;
{{Main|rEFInd}}&lt;br /&gt;
&lt;br /&gt;
[[rEFInd]] provides a graphical boot menu for [[UEFI]] systems.&lt;br /&gt;
&lt;br /&gt;
== GRUB ==&lt;br /&gt;
&lt;br /&gt;
To install GRUB in BIOS mode, (optionally) remove the Syslinux package and install the required GRUB packages:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk del syslinux&lt;br /&gt;
# apk add grub grub-bios&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For EFI, install GRUB&#039;s EFI package instead. Note that {{path|/boot}} has to be an EFI-compatible filesystem, such as FAT32.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add grub-efi efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Next, install the MBR and GRUB binaries to disk for BIOS mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-install /dev/vda}}&lt;br /&gt;
&lt;br /&gt;
For EFI mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# grub-install --target=x86_64-efi --efi-directory=/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Then, add this line to {{path|/etc/default/grub}}:&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;# GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;quiet rootfstype=ext4 modules=sd-mod,usb-storage,ext4&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
GRUB ships with an automatic configuration generator, including some automatic detection of other operating systems installed on the device:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
This script can be configured via the {{path|/etc/default/grub}} file. &lt;br /&gt;
&lt;br /&gt;
If the font in the GRUB boot screen appears too small, then [[Fonts#Changing_GRUB_font_and_font_size|change the GRUB font]].&lt;br /&gt;
&lt;br /&gt;
Consult [https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html gnu.org&#039;s online manual] for a list of available &amp;lt;code&amp;gt;grub-mkconfig&amp;lt;/code&amp;gt; configuration options.&lt;br /&gt;
&lt;br /&gt;
== EFI Boot Stub ==&lt;br /&gt;
&lt;br /&gt;
To boot directly from your motherboard&#039;s UEFI boot menu, a boot entry needs to be created either with a UEFI shell or with &#039;&#039;efibootmgr&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== efibootmgr ===&lt;br /&gt;
&lt;br /&gt;
Install {{Pkg|efibootmgr}}:&lt;br /&gt;
{{cmd|# apk add efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Create a boot entry. It is recommended to do this in a script, as efibootmgr does not allow for editing entries.&lt;br /&gt;
&lt;br /&gt;
{{cat|add-bootentry|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
params=&amp;quot;root=/dev/sdXZ rootfstype=ext4 rw \&lt;br /&gt;
  initrd=\intel-ucode.img \&lt;br /&gt;
  initrd=\initramfs-lts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
efibootmgr --create --label &amp;quot;Alpine Linux&amp;quot; \&lt;br /&gt;
  --disk /dev/sdX --part Y \&lt;br /&gt;
  --loader /vmlinuz-lts \&lt;br /&gt;
  --unicode &amp;quot;${params}&amp;quot; \&lt;br /&gt;
  --verbose&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Where {{path|/dev/sdXY}} contains the EFI partition and {{path|/dev/sdXZ}} contains the root partition. If you are using {{Pkg|linux-stable}}, then replace &amp;lt;code&amp;gt;lts&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;stable&amp;lt;/code&amp;gt; in the script.&lt;br /&gt;
&lt;br /&gt;
{{Tip|If you&#039;re modifying EFI records from a running system (e. g. migrating from GRUB), you can populate {{ic|$params}} from {{ic|/proc/cmdline}}. Make sure to append {{ic|initrd}} param if it&#039;s missing since GRUB does not add it to the command line.}}&lt;br /&gt;
&lt;br /&gt;
{{Note| The kernel contains the [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/init/do_mounts.c#n254 exhaustive list] of ways to specify the block device. For a more robust boot entry, it is recommended to use a persistent name such as the PARTUUID.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Optionally, set the newly-created entry as the default:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# efibootmgr -n XXXX}}&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;XXXX&amp;lt;/code&amp;gt; is the boot number of the new entry.&lt;br /&gt;
&lt;br /&gt;
{{Note| The loader and initrd file arguments are relative to the EFI partition. In a default installation, Alpine Linux places these files in {{path|/boot/}}, while EFI is mounted to {{path|/boot/efi/}}. You can either update &amp;lt;code&amp;gt;fstab&amp;lt;/code&amp;gt; to mount EFI at {{path|/boot/}}, or manually copy them to {{path|/boot/efi/}}.                                                                                           }}&lt;br /&gt;
&lt;br /&gt;
== Using a UKI  ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://github.com/uapi-group/specifications/blob/main/specs/unified_kernel_image.md#unified-kernel-image-uki Unified Kernel Image]&#039;&#039;&#039; (UKI) is supported in UEFI only. It is possible to boot directly into a UKI. A UKI is a single file that contains the initfs, kernel and cmdline. &lt;br /&gt;
&lt;br /&gt;
The [[UEFI Secure Boot]] page contains the instructions for setting up an a UKI.  While this is typically done in order to &#039;&#039;SecureBoot&#039;&#039;, it is perfectly feasible to skip enrolling the custom keys and to leave SecureBoot off. &lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to install the UKI in the default fallback path used by most UEFI implementations. By installing the UKI into this path, the system will automatically boot into it if no other entries are defined. This can be automated as part of the kernel hook by adding the following to {{path|/etc/kernel-hooks.d/secureboot.conf}} :&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/kernel-hooks.d/secureboot.conf|&amp;lt;nowiki&amp;gt;# For the stable kernel, install the UKI into the default UEFI path.&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;stable&amp;quot; ]; then&lt;br /&gt;
  output_dir=&amp;quot;/efi/EFI/Boot/&amp;quot;&lt;br /&gt;
  output_name=&amp;quot;bootx64.efi&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|  {{path|bootx64.efi}} is only correct for &amp;lt;code&amp;gt;x86_64&amp;lt;/code&amp;gt; systems. For other architectures, the exact name will vary.}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
Since bootloaders are installed only during [[System Disk Mode]], the errors related to them are documented in [[System Disk Mode#Troubleshooting|that page]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Silent boot]]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Bootloader Gentoo Wiki - Bootloaders]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader Archwiki - Boot loader]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/Category:Bootloaders PostmarketOS Wiki - Bootloaders]&lt;br /&gt;
* [https://docs.u-boot.org/en/latest/develop/release_cycle.html u-boot.org docs - U-Boot Release Cycle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32031</id>
		<title>Bootloaders</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Bootloaders&amp;diff=32031"/>
		<updated>2026-02-10T14:46:18Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added wikilink&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;bootloader&#039;&#039; is a computer program that is responsible for booting a computer. In the case where it also provides an interactive menu with multiple boot choices, then it&#039;s often called a &#039;&#039;boot manager&#039;&#039;. This page shows the basic steps that you need to perform if, for any reason, you want to switch bootloaders or to apply some manual configuration.&lt;br /&gt;
&lt;br /&gt;
The following bootloaders are available in Alpine Linux:-&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#Syslinux|Syslinux]]&amp;lt;/code&amp;gt; is the default lightweight bootloader used in Alpine Linux.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#rEFInd|rEFInd]]&amp;lt;/code&amp;gt; is an easy-to-use &#039;&#039;EFI&#039;&#039; boot menu that allows booting different operating systems.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#GRUB|GRUB]]&amp;lt;/code&amp;gt; is a standard Linux bootloader.&amp;lt;br&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[#EFI_Boot_Stub|EFI Boot Stub]]&amp;lt;/code&amp;gt; allows for booting Linux directly from a motherboard supporting &#039;&#039;UEFI&#039;&#039; or from another bootloader.&amp;lt;br&amp;gt;&lt;br /&gt;
* [[UEFI Secure Boot]] uses {{pkg|systemd-efistub}} or {{pkg|stubbyboot-efistub}}.&lt;br /&gt;
&lt;br /&gt;
A [[#Using a UKI|Unified Kernel Image (UKI)]] is additionally supported, available  for UEFI only. It is a UEFI executable that can be useful in [https://uapi-group.org/specifications/specs/unified_kernel_image/ certain use cases], including secure boot, clouds and containers.&lt;br /&gt;
&lt;br /&gt;
Note that {{pkg|gummiboot}} is a &#039;&#039;deprecated&#039;&#039; UEFI boot manager that was originally able to leverage UEFI firmware and detect bootable images such as Linux kernels that have an EFI stub on the EFI System Partition (ESP).  The [https://cgit.freedesktop.org/gummiboot/ gummiboot project] was discontinued in 2015 and renamed as {{Pkg|systemd-boot}} for systemd systems and is only available in Alpine Linux in the [[Repositories#Testing|testing repository]].  As it had no runtime dependencies, &#039;&#039;&#039;gummiboot&#039;&#039;&#039; was appreciated for its simplicity as a lightweight, minimal UEFI boot solution.  Its UEFI stub, {{pkg|gummiboot-efistub}}, was used [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|to generate a Unified Kernel Images (UKIs)]] e.g. for [[DM-verity]] and Secure Boot, but [[Release_Notes_for_Alpine_3.22.0#Secure_Boot_and_Gummiboot|it has been deprecated since Alpine Linux 3.22]] and is no longer maintained;  it has been replaced by &#039;&#039;&#039;systemd-efistub&#039;&#039;&#039; (note that the latter package [[UEFI_Secure_Boot#Generating_Unified_Kernel_Image|only supplies EFI stub binaries]] and doesn’t depend on any systemd components).&lt;br /&gt;
&lt;br /&gt;
== Syslinux ==&lt;br /&gt;
&lt;br /&gt;
If you want to switch from another bootloader back to &#039;&#039;Syslinux&#039;&#039;, or if for some reason you want to install Syslinux manually, then the following steps are required.&lt;br /&gt;
&lt;br /&gt;
Install the {{pkg|syslinux}} package:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add syslinux}}&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using GPT partitions, then install the &#039;&#039;GPT MBR&#039;&#039; onto the drive that you want to install the bootloader on (in this case, {{path|/dev/sda}}):&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, if you&#039;re using DOS partitions, then install the &#039;&#039;DOS MBR&#039;&#039; instead:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sda&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&amp;lt;!-- See also: http://www.syslinux.org/wiki/index.php?title=Mbr --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, install the required Syslinux binaries. Despite being called &amp;lt;code&amp;gt;extlinux&amp;lt;/code&amp;gt;, Syslinux supports booting from FAT12/16/32, NTFS, ext2/3/4, [[Btrfs|btrfs]], XFS and UFS/FFS filesystems.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# extlinux --install /boot}}&lt;br /&gt;
&lt;br /&gt;
The configuration file is located in {{path|/boot/extlinux.conf}}. &lt;br /&gt;
&lt;br /&gt;
Alpine Linux ships with a script, &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;, that automatically (re)generates this file, for example, on updates to Syslinux. The settings for this script can be found in {{path|/etc/update-extlinux.conf}}, including the option to disable automatic overwriting of {{path|/boot/extlinux.conf}}. &lt;br /&gt;
&lt;br /&gt;
You can also place additional menu entries in the {{path|/etc/update-extlinux.d/}} directory e.g. for dual booting.&lt;br /&gt;
&lt;br /&gt;
=== Using EFI with syslinux ===&lt;br /&gt;
&lt;br /&gt;
The Alpine Linux installer automatically uses [[#GRUB|GRUB]] if EFI mode is detected. The section below is specifically about using EFI with Syslinux.&lt;br /&gt;
&lt;br /&gt;
Assuming that {{path|/mnt}} is a FAT32 partition of type EF00 and that {{path|/boot}} belongs to the rootfs created after running &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/EFI/syslinux&lt;br /&gt;
# cp /usr/share/syslinux/efi64/* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/extlinux.conf /mnt/EFI/syslinux/syslinux.cfg&lt;br /&gt;
# cp /boot/vmlinuz* /mnt/EFI/syslinux/&lt;br /&gt;
# cp /boot/initramfs* /mnt/EFI/syslinux/&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You may need to modify {{path|/mnt/EFI/syslinux/syslinux.cfg}} to change the paths to absolute paths (just add a / in front of the vmlinuz/initramfs entries), or copy the files to {{path|/mnt/EFI/syslinux}} instead (XXX: untested).&lt;br /&gt;
&lt;br /&gt;
In the end, the {{path|/mnt/EFI/syslinux/syslinux.cfg}} file should look like this:&lt;br /&gt;
&lt;br /&gt;
{{cat|/mnt/EFI/syslinux/syslinux.cfg|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
DEFAULT menu.c32&lt;br /&gt;
PROMPT 0&lt;br /&gt;
MENU TITLE Alpine/Linux Boot Menu&lt;br /&gt;
MENU HIDDEN&lt;br /&gt;
MENU AUTOBOOT Alpine will be booted automatically in # seconds&lt;br /&gt;
TIMEOUT 10&lt;br /&gt;
LABEL lts&lt;br /&gt;
  MENU DEFAULT&lt;br /&gt;
  MENU LABEL Linux lts&lt;br /&gt;
  LINUX /vmlinuz-lts&lt;br /&gt;
  INITRD /initrd-lts&lt;br /&gt;
  APPEND root=/dev/sda3 modules=sd-load,usb-storage,ext4 quiet&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Finally, add &amp;lt;code&amp;gt;syslinux&amp;lt;/code&amp;gt; to the EFI boot menu.  Assuming that {{path|/dev/sda}} is your hard drive —&#039;&#039;&#039;&#039;&#039;be careful to check first what is its path on your device and to adjust accordingly&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk add efibootmgr&lt;br /&gt;
# efibootmgr -c -d /dev/sda -p 1 -l \\EFI\\syslinux\\syslinux.efi -L &amp;quot;ALPINE-SYSLINUX&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can now verify that the boot entry has been added:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;efibootmgr&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
BootCurrent: 0001&lt;br /&gt;
Timeout: 0 seconds&lt;br /&gt;
BootOrder: 0001,0000,0002,...&lt;br /&gt;
Boot001* ALPINE-SYSLINUX HD(1,GPT,xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)/FILE(\EFI\syslinux\syslinux.efi)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== rEFInd ==&lt;br /&gt;
{{Main|rEFInd}}&lt;br /&gt;
&lt;br /&gt;
[[rEFInd]] provides a graphical boot menu for [[UEFI]] systems.&lt;br /&gt;
&lt;br /&gt;
== GRUB ==&lt;br /&gt;
&lt;br /&gt;
To install GRUB in BIOS mode, (optionally) remove the Syslinux package and install the required GRUB packages:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# apk del syslinux&lt;br /&gt;
# apk add grub grub-bios&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
For EFI, install GRUB&#039;s EFI package instead. Note that {{path|/boot}} has to be an EFI-compatible filesystem, such as FAT32.&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add grub-efi efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Next, install the MBR and GRUB binaries to disk for BIOS mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-install /dev/vda}}&lt;br /&gt;
&lt;br /&gt;
For EFI mode:&lt;br /&gt;
&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;# grub-install --target=x86_64-efi --efi-directory=/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Then, add this line to {{path|/etc/default/grub}}:&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;# GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;quiet rootfstype=ext4 modules=sd-mod,usb-storage,ext4&amp;quot;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
GRUB ships with an automatic configuration generator, including some automatic detection of other operating systems installed on the device:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# grub-mkconfig -o /boot/grub/grub.cfg}}&lt;br /&gt;
&lt;br /&gt;
This script can be configured via the {{path|/etc/default/grub}} file. &lt;br /&gt;
&lt;br /&gt;
If the font in the GRUB boot screen appears too small, then [[Fonts#Changing_GRUB_font_and_font_size|change the GRUB font]].&lt;br /&gt;
&lt;br /&gt;
Consult [https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html gnu.org&#039;s online manual] for a list of available &amp;lt;code&amp;gt;grub-mkconfig&amp;lt;/code&amp;gt; configuration options.&lt;br /&gt;
&lt;br /&gt;
== EFI Boot Stub ==&lt;br /&gt;
&lt;br /&gt;
To boot directly from your motherboard&#039;s UEFI boot menu, a boot entry needs to be created either with a UEFI shell or with &#039;&#039;efibootmgr&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== efibootmgr ===&lt;br /&gt;
&lt;br /&gt;
Install {{Pkg|efibootmgr}}:&lt;br /&gt;
{{cmd|# apk add efibootmgr}}&lt;br /&gt;
&lt;br /&gt;
Create a boot entry. It is recommended to do this in a script, as efibootmgr does not allow for editing entries.&lt;br /&gt;
&lt;br /&gt;
{{cat|add-bootentry|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
params=&amp;quot;root=/dev/sdXZ rootfstype=ext4 rw \&lt;br /&gt;
  initrd=\intel-ucode.img \&lt;br /&gt;
  initrd=\initramfs-lts&amp;quot;&lt;br /&gt;
&lt;br /&gt;
efibootmgr --create --label &amp;quot;Alpine Linux&amp;quot; \&lt;br /&gt;
  --disk /dev/sdX --part Y \&lt;br /&gt;
  --loader /vmlinuz-lts \&lt;br /&gt;
  --unicode &amp;quot;${params}&amp;quot; \&lt;br /&gt;
  --verbose&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Where {{path|/dev/sdXY}} contains the EFI partition and {{path|/dev/sdXZ}} contains the root partition. If you are using {{Pkg|linux-stable}}, then replace &amp;lt;code&amp;gt;lts&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;stable&amp;lt;/code&amp;gt; in the script.&lt;br /&gt;
&lt;br /&gt;
{{Tip|If you&#039;re modifying EFI records from a running system (e. g. migrating from GRUB), you can populate {{ic|$params}} from {{ic|/proc/cmdline}}. Make sure to append {{ic|initrd}} param if it&#039;s missing since GRUB does not add it to the command line.}}&lt;br /&gt;
&lt;br /&gt;
{{Note| The kernel contains the [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/init/do_mounts.c#n254 exhaustive list] of ways to specify the block device. For a more robust boot entry, it is recommended to use a persistent name such as the PARTUUID.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Optionally, set the newly-created entry as the default:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# efibootmgr -n XXXX}}&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;code&amp;gt;XXXX&amp;lt;/code&amp;gt; is the boot number of the new entry.&lt;br /&gt;
&lt;br /&gt;
{{Note| The loader and initrd file arguments are relative to the EFI partition. In a default installation, Alpine Linux places these files in {{path|/boot/}}, while EFI is mounted to {{path|/boot/efi/}}. You can either update &amp;lt;code&amp;gt;fstab&amp;lt;/code&amp;gt; to mount EFI at {{path|/boot/}}, or manually copy them to {{path|/boot/efi/}}.                                                                                           }}&lt;br /&gt;
&lt;br /&gt;
== Using a UKI  ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://github.com/uapi-group/specifications/blob/main/specs/unified_kernel_image.md#unified-kernel-image-uki Unified Kernel Image]&#039;&#039;&#039; (UKI) is supported in UEFI only. It is possible to boot directly into a UKI. A UKI is a single file that contains the initfs, kernel and cmdline. &lt;br /&gt;
&lt;br /&gt;
The [[UEFI Secure Boot]] page contains the instructions for setting up an a UKI.  While this is typically done in order to &#039;&#039;SecureBoot&#039;&#039;, it is perfectly feasible to skip enrolling the custom keys and to leave SecureBoot off. &lt;br /&gt;
&lt;br /&gt;
Additionally, it is possible to install the UKI in the default fallback path used by most UEFI implementations. By installing the UKI into this path, the system will automatically boot into it if no other entries are defined. This can be automated as part of the kernel hook by adding the following to {{path|/etc/kernel-hooks.d/secureboot.conf}} :&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/kernel-hooks.d/secureboot.conf|&amp;lt;nowiki&amp;gt;# For the stable kernel, install the UKI into the default UEFI path.&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;stable&amp;quot; ]; then&lt;br /&gt;
  output_dir=&amp;quot;/efi/EFI/Boot/&amp;quot;&lt;br /&gt;
  output_name=&amp;quot;bootx64.efi&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|  {{path|bootx64.efi}} is only correct for &amp;lt;code&amp;gt;x86_64&amp;lt;/code&amp;gt; systems. For other architectures, the exact name will vary.}}&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting == &lt;br /&gt;
&lt;br /&gt;
Since bootloaders are installed only during [[System Disk Mode]], the errors related to them are documented in [[System Disk Mode#Troubleshooting|that page]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
* [[Silent boot]]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Bootloader Gentoo Wiki - Bootloaders]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Arch_boot_process#Boot_loader Archwiki - Boot loader]&lt;br /&gt;
* [https://wiki.postmarketos.org/wiki/Category:Bootloaders PostmarketOS Wiki - Bootloaders]&lt;br /&gt;
* [https://docs.u-boot.org/en/latest/develop/release_cycle.html u-boot.org docs - U-Boot Release Cycle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:Booting]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32030</id>
		<title>System Disk Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32030"/>
		<updated>2026-02-10T14:34:42Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: updated based on clarification from reddit user u/kenrmayfield&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;System Disk mode is the traditional or classic harddisk installation of Alpine Linux. This installation mode is suitable for most use cases including generic [[Tutorials_and_Howtos#Desktop|desktop]], [[Setting up the build environment|development machine]] etc. &lt;br /&gt;
&lt;br /&gt;
If an entire hard disk(s) is available for Alpine Linux, [[Installation#setup-alpine_based_System_Disk_Install|setup-alpine based install]] is the recommended way to install Alpine Linux. For all other use cases, follow the [[Alpine_setup_scripts#setup-disk|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] based Installation given below.&lt;br /&gt;
&lt;br /&gt;
== setup-disk based Installation ==&lt;br /&gt;
&lt;br /&gt;
To perform a traditional hard-disk installation of Alpine Linux, after completing the base configuration, proceed to create, format and mount your partitions with MOUNTPOINT {{Path|&#039;&#039;&#039;/mnt&#039;&#039;&#039;}} as root and run the command {{Codeline|&#039;&#039;&#039;&amp;lt;Code&amp;gt;setup-disk -m sys /mnt&amp;lt;/Code&amp;gt;&#039;&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
# Follow the [[Installation#General_course_of_action|Installation guide]] to complete the [[Installation#Base_configuration|base configuration]], if not already done. A working [[Configure_Networking#Connectivity_testing|Internet access]] is mandatory to complete this installation.&lt;br /&gt;
# If necessary formatted partition(s) are unavailable, manually [[Setting up disks manually#Creating_partitions|create]] them first and [[Setting up disks manually#Formatting_partitions|format]] them including swap partition(if used). If you&#039;re using legacy BIOS mode, use DOS i.e MBR partition table and ensure that proper partition is bootable for [[Bootloaders#Syslinux|extlinux]].&lt;br /&gt;
# Mount the &#039;&#039;&#039;/ (root)&#039;&#039;&#039;  partition on a mount point i.e say {{Path|/mnt}} as follows: {{Cmd|# mount /dev/sdXY /mnt}}&lt;br /&gt;
# If you&#039;re using [[UEFI|EFI]], create a mount point &amp;lt;code&amp;gt;/mnt/boot&amp;lt;/code&amp;gt; and mount the EFI system partition(ESP) on it. {{Cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/boot&lt;br /&gt;
# mount /dev/sdXY /mnt/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# If [[Swap|swap]] partition is available, you can also enable it now: {{Cmd|# swapon /dev/sdXY }}&lt;br /&gt;
# Install Alpine Linux using the following command: {{Cmd|# setup-disk -m sys /mnt}}&lt;br /&gt;
# &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will perform a traditional hard disk install of your running system, detects your file system layout and generates {{Path|/etc/fstab}} and installs a [[Bootloaders|bootloader]] based on the &amp;lt;Code&amp;gt;BOOTLOADER&amp;lt;/Code&amp;gt; [[Alpine_setup_scripts#Environment_Variables|environment variable]].&lt;br /&gt;
# At the end of Installation, you can [[Installation#Reboot|reboot]] to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Mounting on /dev/sdXY sysroot failed ===&lt;br /&gt;
&lt;br /&gt;
The error message appears as follows with variations in &amp;lt;code&amp;gt;/dev/sda8&amp;lt;/code&amp;gt; depending on the partition number and SSD/HDD etc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
mounting /dev/sda8 on /sysroot failed: No such file or directory&lt;br /&gt;
mounting root: failed&lt;br /&gt;
initramfs emergency recovery shell launched. Type &#039;exit&#039; to continue boot&lt;br /&gt;
sh: can&#039;t access tty: job control turned off&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message can be caused by various reasons. Follow the below steps in the emergency shell to identify one possible cause.&lt;br /&gt;
&lt;br /&gt;
# Verify that the partition name in which Alpine Linux was installed matches the above [[#Mounting on /dev/sdXY sysroot failed|error]] by issuing the command and also note down the filesystem type of that partition (say TYPE=&amp;quot;ext4&amp;quot;) : {{Cmd| blkid}}&lt;br /&gt;
# If the expected disk (e.g., /dev/sda, /dev/nvme0n1) itself is missing in the output of {{ic| blkid}}, check [[#Disks not detected after setup-disk|Disks not detected after setup-disk]].&lt;br /&gt;
# Verify that sysroot exists by issuing the command. {{Cmd|ls -ld /sysroot}}&lt;br /&gt;
# Check if the above error message apears when issuing the command. {{Cmd|mount /dev/sda8 /sysroot}}&lt;br /&gt;
# If there is no error message, proceed to check if the issue is caused by a [[#Filesystem corruption|filesystem corruption]].&lt;br /&gt;
# If the manual mount command fails with &amp;quot;No such file or directory&amp;quot; even though you verified /sysroot exists in Step 3, this confirms the kernel doesn&#039;t recognize the filesystem type. Check whether filesystem modules(change ext4 if needed) are loaded by issuing the command. {{Cmd|&amp;lt;nowiki&amp;gt;lsmod | grep ext4 &amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
# If there is no output, then it confirms that the above [[#Mounting on /dev/sdXY sysroot failed|issue]] is caused by [[#Missing filesystem modules in the kernel cmdline|missing filesystem module]].&lt;br /&gt;
&lt;br /&gt;
==== Disks not detected after setup-disk====&lt;br /&gt;
&lt;br /&gt;
After running the standard Alpine installation command: {{ic|setup-disk -m sys /mnt}} and rebooting, the system gives the error mentioned in [[#Mounting on /dev/sdXY sysroot failed|Mounting on /dev/sdXY sysroot failed]] with the expected disk (e.g., /dev/sda, /dev/nvme0n1) missing to show at the output of {{ic| blkid}}. This prevents booting into the installed system. &lt;br /&gt;
&lt;br /&gt;
Issue: As per [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10615 bug report] this might be caused by BIOS storage controller being set to &amp;quot;RAID On (Intel Rapid Storage Technology)&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
Resolution: Switch the storage mode in BIOS/UEFI: Go to BIOS → Storage or SATA/NVMe Operation. Change setting from:RAID On (Intel Rapid Storage Technology) to: AHCI or AHCI/NVMe.&lt;br /&gt;
&lt;br /&gt;
==== Missing filesystem modules in the kernel cmdline ====&lt;br /&gt;
&lt;br /&gt;
[[BusyBox]] mount command does not autoload modules, so need to add filesystem modules to the kernel cmdline. Even though alpine installer does this automatically, this has to be taken care of in case of manual disk install, particularly for [[Dualbooting|dualboot]] installations.&lt;br /&gt;
&lt;br /&gt;
# To resolve, issue the command to load the appropriate filesystem module(say TYPE=&amp;quot;ext4&amp;quot;).{{Cmd|modprobe ext4}}&lt;br /&gt;
# To verify if the issue is resolved, reissue the command.{{Cmd|mount /dev/sda8 /sysroot}} &lt;br /&gt;
# If mount succeeded, issue the following command to boot into Alpine Linux. {{Cmd|exit}}&lt;br /&gt;
&lt;br /&gt;
Choose the appropriate solution based on your use case for a permanent fix:&lt;br /&gt;
&lt;br /&gt;
*If you are using [[Bootloaders#GRUB|grub]], then ensure that {{Codeline|GRUB_CMDLINE_LINUX}} line in the file {{Path|/etc/default/grub}} has the appropriate filesystem module &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
GRUB_CMDLINE_LINUX=&amp;quot;console=ttyS0,19200n8 net.ifnames=0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
* If you are using [[Bootloaders#Syslinux|ExtLinux/SysLinux]], then ensure that {{Codeline|APPEND}} line in the file {{Path|/boot/extlinux.conf}} has &amp;lt;code&amp;gt;root=UUID=&amp;lt;UUID ID&amp;gt;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;root=/dev/sdXY&amp;lt;/code&amp;gt; and the same matches the root path in the {{Path|/etc/fstab}} file. Also ensure that modules has the appropriate filesystem like &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/boot/extlinux.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
APPEND root=/dev/sdXY modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
# root=UUID=&amp;lt;UUID ID&amp;gt; can be used also in the APPEND Line.&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|For both above cases, you may need to issue {{Codeline|update-grub}} or {{Codeline|update-extlinux}} after making above changes.}}&lt;br /&gt;
 &lt;br /&gt;
*For a solution independent of [[Bootloaders|bootloaders]], ensure that the file {{Path|/etc/mkinitfs/mkinitfs.conf}} has the necessary filesystem module in it. Refer [[Initramfs init|Initramfs]] page for more information and recreate initramfs image.&lt;br /&gt;
&lt;br /&gt;
==== Filesystem corruption ====&lt;br /&gt;
&lt;br /&gt;
To fix filesystem corruption issues, the command fsck must be run on the root partition. The root partition should be umounted before running fsck. Boot from a [[Rescue disk]] to run the fsck command on the root partition:{{Cmd|&amp;lt;nowiki&amp;gt;# fsck -y /dev/&amp;lt;DEVICE&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After running fsck, proceed to reboot the computer.&lt;br /&gt;
&lt;br /&gt;
If the fsck command fixes the corruption but the Error:&amp;quot;Mounting Root Failed&amp;quot;, still persists then the next step would be to rebuild the initram file system. After running fsck, mount the root partition and [[Chroot]] into the mounted root partition before running the mkinitfs command as shown in the [[Initramfs init|initramfs]] page. &lt;br /&gt;
&lt;br /&gt;
=== Blinking underscore ===&lt;br /&gt;
&lt;br /&gt;
On a UEFI system, at the end of Installation after rebooting, the computer screen may appear with a &#039;&#039;&#039;blinking underscore&#039;&#039;&#039;. This may be due to the firmware not finding a valid boot entry.&lt;br /&gt;
&lt;br /&gt;
The [[UEFI#EFI bootloaders|EFI bootloader]] entries are added without writing to NVRAM, thus preventing GRUB from calling {{ic|efibootmgr}}. In some cases the UEFI firmware may not boot from a bootloader without a valid NVRAM entry. In such cases, at the end of installation, instead of rebooting, manually add an entry for Alpine Linux in the NVRAM as follows:&lt;br /&gt;
* Install the {{pkg|efibootmgr}} package:{{Cmd|# apk add efibootmgr}}&lt;br /&gt;
* Adjust the device name {{ic|/dev/sdX}} and partition number {{ic|1}}, before issuing the command: {{Cmd|# efibootmgr --create --disk /dev/sdX --part 1 --label &amp;quot;Alpine&amp;quot; --loader &#039;\EFI\alpine\grubx64.efi&#039;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Bootloaders]] - For information on GRUB, Syslinux and rEFInd&lt;br /&gt;
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]&lt;br /&gt;
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32029</id>
		<title>System Disk Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=System_Disk_Mode&amp;diff=32029"/>
		<updated>2026-02-10T10:33:26Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added additional steps based on the detailed instructions provided by reddit user u/kenrmayfield here https://redd.it/1qyxwdo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;System Disk mode is the traditional or classic harddisk installation of Alpine Linux. This installation mode is suitable for most use cases including generic [[Tutorials_and_Howtos#Desktop|desktop]], [[Setting up the build environment|development machine]] etc. &lt;br /&gt;
&lt;br /&gt;
If an entire hard disk(s) is available for Alpine Linux, [[Installation#setup-alpine_based_System_Disk_Install|setup-alpine based install]] is the recommended way to install Alpine Linux. For all other use cases, follow the [[Alpine_setup_scripts#setup-disk|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] based Installation given below.&lt;br /&gt;
&lt;br /&gt;
== setup-disk based Installation ==&lt;br /&gt;
&lt;br /&gt;
To perform a traditional hard-disk installation of Alpine Linux, after completing the base configuration, proceed to create, format and mount your partitions with MOUNTPOINT {{Path|&#039;&#039;&#039;/mnt&#039;&#039;&#039;}} as root and run the command {{Codeline|&#039;&#039;&#039;&amp;lt;Code&amp;gt;setup-disk -m sys /mnt&amp;lt;/Code&amp;gt;&#039;&#039;&#039;}}.&lt;br /&gt;
&lt;br /&gt;
# Follow the [[Installation#General_course_of_action|Installation guide]] to complete the [[Installation#Base_configuration|base configuration]], if not already done. A working [[Configure_Networking#Connectivity_testing|Internet access]] is mandatory to complete this installation.&lt;br /&gt;
# If necessary formatted partition(s) are unavailable, manually [[Setting up disks manually#Creating_partitions|create]] them first and [[Setting up disks manually#Formatting_partitions|format]] them including swap partition(if used). If you&#039;re using legacy BIOS mode, use DOS i.e MBR partition table and ensure that proper partition is bootable for [[Bootloaders#Syslinux|extlinux]].&lt;br /&gt;
# Mount the &#039;&#039;&#039;/ (root)&#039;&#039;&#039;  partition on a mount point i.e say {{Path|/mnt}} as follows: {{Cmd|# mount /dev/sdXY /mnt}}&lt;br /&gt;
# If you&#039;re using [[UEFI|EFI]], create a mount point &amp;lt;code&amp;gt;/mnt/boot&amp;lt;/code&amp;gt; and mount the EFI system partition(ESP) on it. {{Cmd|&amp;lt;nowiki&amp;gt;# mkdir -p /mnt/boot&lt;br /&gt;
# mount /dev/sdXY /mnt/boot&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
# If [[Swap|swap]] partition is available, you can also enable it now: {{Cmd|# swapon /dev/sdXY }}&lt;br /&gt;
# Install Alpine Linux using the following command: {{Cmd|# setup-disk -m sys /mnt}}&lt;br /&gt;
# &amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt; will perform a traditional hard disk install of your running system, detects your file system layout and generates {{Path|/etc/fstab}} and installs a [[Bootloaders|bootloader]] based on the &amp;lt;Code&amp;gt;BOOTLOADER&amp;lt;/Code&amp;gt; [[Alpine_setup_scripts#Environment_Variables|environment variable]].&lt;br /&gt;
# At the end of Installation, you can [[Installation#Reboot|reboot]] to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== Mounting on /dev/sdXY sysroot failed ===&lt;br /&gt;
&lt;br /&gt;
The error message appears as follows with variations in &amp;lt;code&amp;gt;/dev/sda8&amp;lt;/code&amp;gt; depending on the partition number and SSD/HDD etc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
mounting /dev/sda8 on /sysroot failed: No such file or directory&lt;br /&gt;
mounting root: failed&lt;br /&gt;
initramfs emergency recovery shell launched. Type &#039;exit&#039; to continue boot&lt;br /&gt;
sh: can&#039;t access tty: job control turned off&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message can be caused by various reasons. Follow the below steps in the emergency shell to identify one possible cause.&lt;br /&gt;
&lt;br /&gt;
# Verify that the partition name in which Alpine Linux was installed matches the above [[#Mounting on /dev/sdXY sysroot failed|error]] by issuing the command and also note down the filesystem type of that partition (say TYPE=&amp;quot;ext4&amp;quot;) : {{Cmd| blkid}}&lt;br /&gt;
# If the expected disk (e.g., /dev/sda, /dev/nvme0n1) itself is missing in the output of {{ic| blkid}}, check [[#Disks not detected after setup-disk|Disks not detected after setup-disk]].&lt;br /&gt;
# Verify that sysroot exists by issuing the command. {{Cmd|ls -ld /sysroot}}&lt;br /&gt;
# Check if the above error message apears when issuing the command. {{Cmd|mount /dev/sda8 /sysroot}}&lt;br /&gt;
# If there is no error message, proceed to check if the issue is caused by a [[#Filesystem corruption|filesystem corruption]].&lt;br /&gt;
# If the manual mount command fails with &amp;quot;No such file or directory&amp;quot; even though you verified /sysroot exists in Step 3, this confirms the kernel doesn&#039;t recognize the filesystem type. Check whether filesystem modules(change ext4 if needed) are loaded by issuing the command. {{Cmd|&amp;lt;nowiki&amp;gt;lsmod | grep ext4 &amp;lt;/nowiki&amp;gt;}} &lt;br /&gt;
# If there is no output, then it confirms that the above [[#Mounting on /dev/sdXY sysroot failed|issue]] is caused by [[#Missing filesystem modules in the kernel cmdline|missing filesystem module]].&lt;br /&gt;
&lt;br /&gt;
==== Disks not detected after setup-disk====&lt;br /&gt;
&lt;br /&gt;
After running the standard Alpine installation command: {{ic|setup-disk -m sys /mnt}} and rebooting, the system gives the error mentioned in [[#Mounting on /dev/sdXY sysroot failed|Mounting on /dev/sdXY sysroot failed]] with the expected disk (e.g., /dev/sda, /dev/nvme0n1) missing to show at the output of {{ic| blkid}}. This prevents booting into the installed system. &lt;br /&gt;
&lt;br /&gt;
Issue: As per [https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10615 bug report] this might be caused by BIOS storage controller being set to &amp;quot;RAID On (Intel Rapid Storage Technology)&amp;quot;.  &lt;br /&gt;
&lt;br /&gt;
Resolution: Switch the storage mode in BIOS/UEFI: Go to BIOS → Storage or SATA/NVMe Operation. Change setting from:RAID On (Intel Rapid Storage Technology) to: AHCI or AHCI/NVMe.&lt;br /&gt;
&lt;br /&gt;
==== Missing filesystem modules in the kernel cmdline ====&lt;br /&gt;
&lt;br /&gt;
[[BusyBox]] mount command does not autoload modules, so need to add filesystem modules to the kernel cmdline. Even though alpine installer does this automatically, this has to be taken care of in case of manual disk install, particularly for [[Dualbooting|dualboot]] installations.&lt;br /&gt;
&lt;br /&gt;
# To resolve, issue the command to load the appropriate filesystem module(say TYPE=&amp;quot;ext4&amp;quot;).{{Cmd|modprobe ext4}}&lt;br /&gt;
# To verify if the issue is resolved, reissue the command.{{Cmd|mount /dev/sda8 /sysroot}} &lt;br /&gt;
# If mount succeeded, issue the following command to boot into Alpine Linux. {{Cmd|exit}}&lt;br /&gt;
&lt;br /&gt;
Choose the appropriate solution based on your use case for a permanent fix:&lt;br /&gt;
&lt;br /&gt;
*If you are using [[Bootloaders#GRUB|grub]], then ensure that {{Codeline|GRUB_CMDLINE_LINUX}} line in the file {{Path|/etc/default/grub}} has the appropriate filesystem module &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rootfstype=ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/etc/default/grub|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
GRUB_CMDLINE_LINUX=&amp;quot;console=ttyS0,19200n8 net.ifnames=0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
*If you are using [[Bootloaders#Syslinux|Syslinux]], then ensure that {{Codeline|APPEND root}} line in the file {{Path|/boot/extlinux.conf}} has the appropriate filesystem module &amp;lt;code&amp;gt;ext4&amp;lt;/code&amp;gt; as follows: {{Cat|/boot/extlinux.conf|&amp;lt;nowiki&amp;gt;...&lt;br /&gt;
APPEND root=/dev/sdXY modules=sd-mod,usb-storage,ext4 quiet&lt;br /&gt;
...&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{Note|For both above cases, you may need to issue {{Codeline|update-grub}} or {{Codeline|update-extlinux}} after making above changes.}}&lt;br /&gt;
 &lt;br /&gt;
*For a solution independent of [[Bootloaders|bootloaders]], ensure that the file {{Path|/etc/mkinitfs/mkinitfs.conf}} has the necessary filesystem module in it. Refer [[Initramfs init|Initramfs]] page for more information and recreate initramfs image.&lt;br /&gt;
&lt;br /&gt;
==== Filesystem corruption ====&lt;br /&gt;
&lt;br /&gt;
To fix filesystem corruption issues, the command fsck must be run on the root partition. The root partition should be umounted before running fsck. Boot from a [[Rescue disk]] to run the fsck command on the root partition:{{Cmd|&amp;lt;nowiki&amp;gt;# fsck -y /dev/&amp;lt;DEVICE&amp;gt;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After running fsck, proceed to reboot the computer.&lt;br /&gt;
&lt;br /&gt;
If the fsck command fixes the corruption but the Error:&amp;quot;Mounting Root Failed&amp;quot;, still persists then the next step would be to rebuild the initram file system. After running fsck, mount the root partition and [[Chroot]] into the mounted root partition before running the mkinitfs command as shown in the [[Initramfs init|initramfs]] page. &lt;br /&gt;
&lt;br /&gt;
=== Blinking underscore ===&lt;br /&gt;
&lt;br /&gt;
On a UEFI system, at the end of Installation after rebooting, the computer screen may appear with a &#039;&#039;&#039;blinking underscore&#039;&#039;&#039;. This may be due to the firmware not finding a valid boot entry.&lt;br /&gt;
&lt;br /&gt;
The [[UEFI#EFI bootloaders|EFI bootloader]] entries are added without writing to NVRAM, thus preventing GRUB from calling {{ic|efibootmgr}}. In some cases the UEFI firmware may not boot from a bootloader without a valid NVRAM entry. In such cases, at the end of installation, instead of rebooting, manually add an entry for Alpine Linux in the NVRAM as follows:&lt;br /&gt;
* Install the {{pkg|efibootmgr}} package:{{Cmd|# apk add efibootmgr}}&lt;br /&gt;
* Adjust the device name {{ic|/dev/sdX}} and partition number {{ic|1}}, before issuing the command: {{Cmd|# efibootmgr --create --disk /dev/sdX --part 1 --label &amp;quot;Alpine&amp;quot; --loader &#039;\EFI\alpine\grubx64.efi&#039;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Bootloaders]] - For information on GRUB, Syslinux and rEFInd&lt;br /&gt;
* [[Installing Alpine on HDD dualbooting|Install to HDD with dual-boot]]&lt;br /&gt;
* [[Installing Alpine Linux in a chroot|Installing Alpine Linux in a chroot]]&lt;br /&gt;
* [https://github.com/itoffshore/alpine-linux-scripts setup-partitions]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=PipeWire&amp;diff=32028</id>
		<title>PipeWire</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=PipeWire&amp;diff=32028"/>
		<updated>2026-02-09T05:58:25Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: updated wiki based on message by invoked on 2026-02-08 16:49:14 in https://irclogs.alpinelinux.org/%23alpine-linux-2026-02.log&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOC right}}&lt;br /&gt;
[https://pipewire.org/ PipeWire] is a multimedia processing engine that aims to improve audio and video handling on Linux. PipeWire can act as a replacement for both [[PulseAudio]] and [[ALSA]] servers.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* PipeWire requires [[D-Bus#D-Bus_session_bus|D-Bus session bus]] for most of its functionality.&lt;br /&gt;
* Ensure that your [[Setting_up_a_new_user#Creating_a_new_user|non-root user account]] has appropriate [[Setting_up_a_new_user#Groups_for_desktop_usage|groups for desktop usage]].&lt;br /&gt;
* WirePlumber requires [[eudev]] for ALSA device discovery.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install {{Pkg|pipewire}} and {{Pkg|wireplumber}} (session manager).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add pipewire wireplumber}}&lt;br /&gt;
&lt;br /&gt;
=== Pulseaudio interface ===&lt;br /&gt;
&lt;br /&gt;
The package {{Pkg|pipewire-pulse}} allows pulseaudio applications and [[#GUI_tools|GUI tools]] to use PipeWire as audio server in the backend.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add pipewire-pulse}}&lt;br /&gt;
&lt;br /&gt;
=== JACK compatibility ===&lt;br /&gt;
&lt;br /&gt;
Since PipeWire replaces JACK, Install {{Pkg|pipewire-jack}} package, so it provides ABI-compatible libraries for JACK applications.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add pipewire-jack}}&lt;br /&gt;
&lt;br /&gt;
=== ALSA support ===&lt;br /&gt;
&lt;br /&gt;
Install {{Pkg|pipewire-alsa}} package to provide support for ALSA applications.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# apk add pipewire-alsa}}&lt;br /&gt;
&lt;br /&gt;
=== GUI tools ===&lt;br /&gt;
&lt;br /&gt;
* {{Pkg|pavucontrol}}: simple GUI app for controlling sound, outputs, etc. Consider using {{Pkg|pavucontrol-qt}} when using [[KDE|Plasma]]. &lt;br /&gt;
&lt;br /&gt;
: [[#Pulseaudio_interface|Pulseaudio interface]] is mandatory for {{Ic|pavucontrol}} to work with PipeWire.&lt;br /&gt;
&lt;br /&gt;
* {{Pkg|xfce4-mixer}}: XFCE Audio mixer.&lt;br /&gt;
&lt;br /&gt;
: Currently available in the [[Repositories#Testing|testing]] repository.&lt;br /&gt;
&lt;br /&gt;
* {{Pkg|qpwgraph}}: graph manager dedicated to PipeWire with Qt GUI Interface.&lt;br /&gt;
&lt;br /&gt;
== Launch PipeWire ==&lt;br /&gt;
&lt;br /&gt;
Most [[Desktop_environments_and_Window_managers#Desktop_environments|desktop environments]] launch PipeWire automatically in Alpine Linux upon relogging (i.e. logging out and logging in) after [[#Installation|installing the above packages]]. Proceed with the section below only if PipeWire is [[#Testing|not launched]] after a relogin/reboot.&lt;br /&gt;
&lt;br /&gt;
{{Note|[[#PipeWire_user_service|PipeWire user service]] is the recommended method to launch PipeWire and will replace [[#pipewire-launcher|pipewire-launcher]]. Do &#039;&#039;&#039;NOT&#039;&#039;&#039; use both methods to avoid running multiple instances of PipeWire.}}&lt;br /&gt;
&lt;br /&gt;
=== PipeWire user service ===&lt;br /&gt;
&lt;br /&gt;
Since [[Release_Notes_for_Alpine_3.22.0#OpenRC_User_services|Alpine 3.22]], PipeWire can be launched as a user service.&lt;br /&gt;
&lt;br /&gt;
==== User service prerequisites ====&lt;br /&gt;
&lt;br /&gt;
* Ensure the [[OpenRC#Prerequisites|OpenRC User service Prerequisites]] are met and [[OpenRC#Configure environment variables|environment variables are configured]].&lt;br /&gt;
* PipeWire will fail to start, if [[#Realtime scheduling|realtime scheduling]] is not configured. &lt;br /&gt;
* Issue the command {{ic|$ rc-status -Ur}} to view and verify the current user runlevel as &#039;&#039;&#039;gui&#039;&#039;&#039; and &#039;&#039;&#039;default&#039;&#039;&#039; for Wayland and Xorg respectively.&lt;br /&gt;
&lt;br /&gt;
==== User service management ====&lt;br /&gt;
&lt;br /&gt;
To start the {{Ic|pipewire}} user service and its {{Ic|wireplumber}} session manager:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ rc-service -U pipewire start&lt;br /&gt;
$ rc-service -U wireplumber start}}&lt;br /&gt;
&lt;br /&gt;
To enable the {{Ic|pipewire}} and {{Ic|wireplumber}} user services in [[Wayland]], in [[Xorg]] change {{Ic|gui}} to {{Ic|default}}:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ rc-update -U add pipewire gui&lt;br /&gt;
$ rc-update -U add wireplumber gui}}&lt;br /&gt;
&lt;br /&gt;
The above steps may be repeated for {{Ic|pipewire-pulse}} user service.&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{ic|pipewire-pulse}} user service would be required to enable various functions, including setting audio levels with {{ic|pactl}}, when [[PulseAudio#PulseAudio_Utils|running pulseaudio with pulseaudio-utils]] and to enable associated volume user keys.}}&lt;br /&gt;
&lt;br /&gt;
=== pipewire-launcher ===&lt;br /&gt;
&lt;br /&gt;
{{Note|The {{Ic|pipewire-launcher}} script will be removed in the future to be replaced with the [[#PipeWire_user_service|PipeWire user service]].}}&lt;br /&gt;
&lt;br /&gt;
Launch PipeWire by using the &amp;lt;code&amp;gt;pipewire-launcher&amp;lt;/code&amp;gt; script. You&#039;ll probably get quite a few errors but just ignore them for now.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ /usr/libexec/pipewire-launcher}}&lt;br /&gt;
&lt;br /&gt;
If xinitrc is used, add {{Path|/usr/libexec/pipewire-launcher}} to your {{Path|~/.xinitrc}}.&lt;br /&gt;
&lt;br /&gt;
If you do not use GUI by default, add the following stanza to your shell configuration file:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|export $(dbus-launch) &lt;br /&gt;
/usr/libexec/pipewire-launcher}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
PipeWire and WirePlumber store their default configuration in {{Path|/usr/share/pipewire}} and {{Path|/usr/share/wireplumber}} respectively. If you want to edit the configuration, you need to move it to {{Path|/etc}}:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# cp -a /usr/share/pipewire /etc&lt;br /&gt;
# cp -a /usr/share/wireplumber /etc&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Screen sharing on Wayland ===&lt;br /&gt;
&lt;br /&gt;
Applications which don&#039;t implement native Wayland screensharing rely on [https://github.com/flatpak/xdg-desktop-portal xdg-desktop-portal] plus the correct backend for your compositor. Screen sharing is known to work on:&lt;br /&gt;
* GNOME with &amp;lt;code&amp;gt;xdg-desktop-portal-gtk&amp;lt;/code&amp;gt;&lt;br /&gt;
* KDE Plasma with &amp;lt;code&amp;gt;xdg-desktop-portal-kde&amp;lt;/code&amp;gt; and Firefox&lt;br /&gt;
* Sway with &amp;lt;code&amp;gt;xdg-desktop-portal-wlr&amp;lt;/code&amp;gt; and Firefox, see [[Sway]] for details&lt;br /&gt;
&lt;br /&gt;
=== Bluetooth audio ===&lt;br /&gt;
{{Main|Bluetooth}}&lt;br /&gt;
* Enable PulseAudio support as described above&lt;br /&gt;
* Install bluetooth service packages: &amp;lt;code&amp;gt;bluez bluez-openrc pipewire-spa-bluez&amp;lt;/code&amp;gt;&lt;br /&gt;
* Optional: install GUI manager for bluetooth &amp;lt;code&amp;gt;blueman&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable and start bluetooth service: &amp;lt;code&amp;gt;rc-update add bluetooth; rc-service bluetooth start&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart PipeWire&lt;br /&gt;
* Use commandline program &amp;lt;code&amp;gt;bluetoothctl&amp;lt;/code&amp;gt; or GUI program &amp;lt;code&amp;gt;blueman-manager&amp;lt;/code&amp;gt; to scan and pair bluetooth audio devices.&lt;br /&gt;
* Use pavucontrol to adjust volume and manually select high definition bluetooth codecs.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
Video should work out-of-the-box with v4l2 devices (e.g. a lot of webcams) and [https://gstreamer.freedesktop.org/ GStreamer] applications.&lt;br /&gt;
&lt;br /&gt;
=== Realtime scheduling ===&lt;br /&gt;
&lt;br /&gt;
Realtime scheduling will increase certain threads priorities to assist with low latency audio processing.  By default, PipeWire tries to enable realtime scheduling with the [https://docs.pipewire.org/page_module_rt.html rt module]. &lt;br /&gt;
&lt;br /&gt;
==== Option1 ====&lt;br /&gt;
&lt;br /&gt;
Since [https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/0.3.66 PipeWire 0.3.66], when you have a [[PAM]] login session, you should add your user to the {{Ic|pipewire}} group.&lt;br /&gt;
&lt;br /&gt;
==== option2 ====&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have [[PAM]] but [[D-Bus]] is available, the rt module will try to use {{Pkg|rtkit}}; if this is the case, add your user to the {{Ic|rtkit}} group.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The default system wide settings are defined in {{Path|/etc/security/limits.d/25-pw-rlimits.conf}}. You may want to adjust settings for parameters like &amp;lt;var&amp;gt;rt.prio&amp;lt;/var&amp;gt;, if required. Alternatively, it can be set at [https://docs.pipewire.org/page_module_rt.html  user level] within the ceiling set by the system&#039;s rlimits.&lt;br /&gt;
&lt;br /&gt;
{{Cat|~/.config/pipewire/pipewire.conf.d/my-rt-args.conf|&amp;lt;nowiki&amp;gt;context.modules = [&lt;br /&gt;
{   name = libpipewire-module-rt&lt;br /&gt;
    args = {&lt;br /&gt;
        #nice.level   = 20&lt;br /&gt;
        #rt.prio      = 88&lt;br /&gt;
    }&lt;br /&gt;
    flags = [ ifexists nofail ]&lt;br /&gt;
}&lt;br /&gt;
]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;wpctl&amp;lt;/code&amp;gt; utility from {{Pkg|wireplumber}} to test the working of PipeWire:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ wpctl status}}&lt;br /&gt;
&lt;br /&gt;
=== pw-cat playback ===&lt;br /&gt;
&lt;br /&gt;
Test sound is working using an audio file in a format supported by [http://www.mega-nerd.com/libsndfile/ libsndfile]{{insecure url|Server refuses HTTPS connections}} (e.g. flac, opus, ogg, wav). Use &amp;lt;code&amp;gt;pw-cat&amp;lt;/code&amp;gt; utility from {{Pkg|pipewire-tools}}:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ pw-cat -p test.flac&lt;br /&gt;
$ pw-play /usr/share/sounds/alsa/Front_Center.wav&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== pw-cat recording ===&lt;br /&gt;
&lt;br /&gt;
If you have a microphone test audio recording is working.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ pw-cat -r --list-targets&lt;br /&gt;
$ pw-cat -r recording.flac&lt;br /&gt;
(Speak for a while then stop it with Ctrl+c)&lt;br /&gt;
$ pw-cat -p recording.flac&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== PulseAudio ===&lt;br /&gt;
&lt;br /&gt;
Test PulseAudio clients using a media player, as most use PulseAudio.&lt;br /&gt;
&lt;br /&gt;
=== JACK ===&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;jack_simple_client&amp;lt;/code&amp;gt; from {{Pkg|jack-simple-clients}}:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ jack_simple_client}}&lt;br /&gt;
&lt;br /&gt;
You should hear a sustained beep.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== `wpctl status` shows no targets ===&lt;br /&gt;
&lt;br /&gt;
First, check whether ALSA knows about your sound card using the &amp;lt;code&amp;gt;aplay&amp;lt;/code&amp;gt; utility from {{pkg|alsa-utils}} package:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ aplay -l}}&lt;br /&gt;
&lt;br /&gt;
If sound devices are found, the issue is likely with your PipeWire configuration.  Ensure that [[eudev]] is installed, and consider double-checking the instructions above.&lt;br /&gt;
&lt;br /&gt;
If no sound devices are found, your sound card may not be supported in the version of the Linux Kernel you&#039;re running.  You should search online for fixes relating to your current kernel version and the codec of your sound card.  You can find each of these with:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ uname -r&lt;br /&gt;
$ cat /proc/asound/card0/codec* {{!}} grep Codec}}&lt;br /&gt;
&lt;br /&gt;
Modern devices might require {{Pkg|sof-firmware}}, which is the case if you get &amp;lt;code&amp;gt;sof firmware file is missing&amp;lt;/code&amp;gt; errors in dmesg.&lt;br /&gt;
&lt;br /&gt;
=== Error acquiring bus address: Cannot autolaunch D-Bus without X11 $DISPLAY ===&lt;br /&gt;
&lt;br /&gt;
Check and ensure that [[D-Bus#D-Bus session bus|D-Bus session bus]] is started along with your GUI session i.e. you are in a tty.&lt;br /&gt;
&lt;br /&gt;
=== Connection failure: Connection refused ===&lt;br /&gt;
&lt;br /&gt;
When using [[Wayland]], ensure that [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]] is configured correctly. If this is not set, PipeWire will create a directory in your home folder instead, called {{Path|~/pulse}}, and on attempting to run {{Ic|pavucontrol}} or {{Ic|pactl}}, you will get the following error:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|$ pactl list&lt;br /&gt;
Connection failure: Connection refused&lt;br /&gt;
pa_context_connect() failed: Connection refused}}&lt;br /&gt;
&lt;br /&gt;
If you are running Alpine 3.22+ and continue to experience this error after verifying that [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]] is correctly set, ensure that the &amp;lt;code&amp;gt;pipewire-pulse&amp;lt;/code&amp;gt; [[#PipeWire_user_service|user service is running]].&lt;br /&gt;
&lt;br /&gt;
=== Bluetooth connect failed: br-connection-profile-unavailable === &lt;br /&gt;
&lt;br /&gt;
Ensure {{Ic|wireplumber}}, the session manager, is running.&lt;br /&gt;
&lt;br /&gt;
=== Play/Pause buttons not working on bluetooth headphones ===&lt;br /&gt;
&lt;br /&gt;
Check {{Path|/var/log/messages}} for lines similar to:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/var/log/messages|bluetoothd[3463]: profiles/audio/avctp.c:uinput_create() Can&#039;t open input device: No such file or directory (2)&lt;br /&gt;
bluetoothd[3463]: profiles/audio/avctp.c:init_uinput() AVRCP: failed to init uinput for WH-1000XM5}}&lt;br /&gt;
&lt;br /&gt;
Then {{Ic|bluez}} is trying to register the headphones buttons as an input devices, but &amp;lt;code&amp;gt;uinput&amp;lt;/code&amp;gt; is not loaded. Try &amp;lt;code&amp;gt;modprobe uinput&amp;lt;/code&amp;gt;. If this works, see [[Architecture#Loading_of_Kernel_Modules|Loading of Kernel Modules]] for instructions on how to make sure this module is loaded automatically on each startup.&lt;br /&gt;
&lt;br /&gt;
=== RTKit error: org.freedesktop.DBus.Error.ServiceUnknown ===&lt;br /&gt;
&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:330:translate_error: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:995:do_rtkit_setup: RTKit does not give us MaxRealtimePriority, using 1&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:330:translate_error: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:1000:do_rtkit_setup: RTKit does not give us MinNiceLevel, using 0&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:330:translate_error: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown&lt;br /&gt;
 mod.rt ../src/modules/module-rt.c:1005:do_rtkit_setup: RTKit does not give us RTTimeUSecMax, using -1&lt;br /&gt;
&lt;br /&gt;
Follow [[#Realtime scheduling|Realtime scheduling]] section to resolve the above error message.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Bluetooth]]&lt;br /&gt;
* Official PipeWire links &lt;br /&gt;
** [https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/home Wiki]&lt;br /&gt;
** [https://docs.pipewire.org Documentation site]&lt;br /&gt;
** [https://gitlab.freedesktop.org/pipewire/pipewire Source repository]&lt;br /&gt;
* [https://wiki.archlinux.org/index.php/PipeWire PipeWire on the ArchWiki]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/PipeWire PipeWire on the Gentoo Wiki]&lt;br /&gt;
&lt;br /&gt;
[[Category:Sound]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=32017</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=32017"/>
		<updated>2026-02-05T05:24:50Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added comment to future editors&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:hdd_mount.png|left|link=]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page exists to provide a basic overview to get started. Before actually installing, it can help to skim through the [[Alpine_Linux:FAQ| Frequently Asked Questions (FAQ)]], as well as to refer to the official installation guide at [https://docs.alpinelinux.org/ docs.alpinelinux.org].&lt;br /&gt;
&lt;br /&gt;
{{Tip|This is a wiki!&lt;br /&gt;
If something isn&#039;t correct, or is incomplete, you will have to figure it out, or ask for the correct solution in the [https://alpinelinux.org/community/ community].&lt;br /&gt;
&lt;br /&gt;
And then carefully [[Help:Editing|edit]] the wiki page.&lt;br /&gt;
&lt;br /&gt;
Just as those before who did it for you.}}&lt;br /&gt;
&lt;br /&gt;
== Minimal Hardware Requirements ==&lt;br /&gt;
{{Main|Requirements}}&lt;br /&gt;
* At least 128 MB of RAM. [A graphical desktop system may require up to 512 minimum.]. Note that an installation itself (from ISO) generally requires at least 320 MB during installation.&lt;br /&gt;
* At least 0-700 MB space on a writable storage device. [Only required in [[#System Disk Mode|&amp;quot;sys&amp;quot;]] or [[#Data Disk Mode|&amp;quot;data&amp;quot;]] mode installations. It is optional in [[#Diskless Mode|&amp;quot;diskless&amp;quot;]] mode, where it may be used to save newer data and configurations states of a running system.]&lt;br /&gt;
* A working internet connection is required to complete [[#System Disk Mode|&amp;quot;sys&amp;quot;]] mode installation or use &#039;&#039;&#039;Extended image&#039;&#039;&#039; if available for your architecture.&lt;br /&gt;
&lt;br /&gt;
{{Note|Refer [[#Custom Installation Instructions|custom installation instructions]] for headless system, virtualization etc. Most of the steps outlined on this page applies to all [[Architecture#Architectures_supported|Architectures]] supported by Alpine Linux. For more specific installation instructions, refer to their respective pages.}}&lt;br /&gt;
&lt;br /&gt;
== Installation Overview ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux can be installed and run in three modes i.e [[#Diskless_Mode|Diskless Mode]], [[#Data_Disk_Mode|Data Disk Mode]] and [[#System_Disk_Mode|System Disk Mode]]. The first two installation modes are sometimes referred to, collectively, as &amp;quot;run-from-RAM&amp;quot; installations. The installation procedure for Alpine Linux &#039;&#039;&#039;requires basic understanding of the three modes&#039;&#039;&#039; explained in brief below: &lt;br /&gt;
&lt;br /&gt;
==== Diskless Mode ====&lt;br /&gt;
{{Main|Diskless Mode}}&lt;br /&gt;
In Diskless mode the entire operating system with all applications are first loaded into RAM and then only run from there. This mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear.  Alpine Linux uses this method to boot the .iso installation images. The [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] script configures the installed system to continue to boot like this if &amp;quot;disk=none&amp;quot; is specified.&lt;br /&gt;
&lt;br /&gt;
==== Data Disk Mode ====&lt;br /&gt;
{{Main|Data Disk Mode}}&lt;br /&gt;
In Data Disk mode also the operating system  runs from system RAM, thus it enjoys the same accelerated operation speed as &amp;quot;diskless&amp;quot; mode. However, swap storage and the entire {{Path|/var}} directory tree get mounted from a persistent storage device. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size. &lt;br /&gt;
&lt;br /&gt;
==== System Disk Mode ====&lt;br /&gt;
{{Main|System Disk Mode}}&lt;br /&gt;
System or &#039;&#039;&#039;sys&#039;&#039;&#039; Disk Mode is the traditional hard-disk install. Alpine Linux can be installed to an [[#setup-alpine based System Disk Install|&#039;&#039;&#039;entire hard disk&#039;&#039;&#039; using &#039;&#039;setup-alpine&#039;&#039;]] script or to a [[System Disk Mode|&#039;&#039;&#039;partition&#039;&#039;&#039; using &#039;&#039;setup-disk&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== General course of action ===&lt;br /&gt;
&lt;br /&gt;
It is really helpful for many use cases to [[#Preparing for the installation|prepare]] and complete the [[#Installation Step Details|installation]] until the [[#Base configuration|base configuration]] step, then proceed with installation of the target system with any one of the various [[#Alternative courses of action|alternative]] courses of action.&lt;br /&gt;
&lt;br /&gt;
=== Alternative courses of action ===&lt;br /&gt;
&lt;br /&gt;
Examples of preparation options:&lt;br /&gt;
&lt;br /&gt;
* Download specific driver to configure [[Alpine_kernel_module_support#List_of_out-of-tree_kernel_module_packages|hardware]], if the [[Kernels#Firmware|firmware]] does not have it and/or install some software tool that may be missing in the live system by using the Alpine package manager &amp;lt;code&amp;gt;[[Alpine Package Keeper|apk]]&amp;lt;/code&amp;gt;.  &lt;br /&gt;
* Do a [[Setting up disks manually#Manual partitioning|manual partitioning]] of the hard disk that avoids overwrite of an entire disk.&lt;br /&gt;
&lt;br /&gt;
Examples of such options:&lt;br /&gt;
&lt;br /&gt;
* To install Alpine Linux on an &#039;&#039;&#039;entire hard disk&#039;&#039;&#039; with optional [[Alpine setup scripts#Environment Variables|environment variables]], proceed to [[#setup-alpine based System Disk Install|setup-alpine based System Disk Install]].&lt;br /&gt;
* Use {{ic|setup-disk}} script to complete a [[System Disk Mode|traditional hard disk installation]] on a partition or to [[Dualbooting|dualboot]] or to configure [[Setting up disks manually#RAID|RAID]], [[Setting up disks manually#Encryption|encryption]] or [[Setting up disks manually#LVM|LVM]] for [[#System Disk Mode|&amp;quot;system&amp;quot;]] disk mode or to add a [[#Data Disk Mode|&amp;quot;data&amp;quot;]] mode partition.&lt;br /&gt;
* Create a [[Create a Bootable Device#Using setup-bootable|customizable boot media]] i.e a boot device with a writable filesystem for &#039;&#039;&#039;[[#Diskless Mode|diskless]]&#039;&#039;&#039; or &#039;&#039;&#039;[[#Data Disk Mode|data]]&#039;&#039;&#039; disk-mode.&lt;br /&gt;
* Configure a [[Diskless Mode#Using an internal disk for persistent storage|internal disk for persistent storage]] to save the local configuration state and local package cache for the [[#Diskless Mode|diskless]] system or &#039;&#039;&#039;[[#Data Disk Mode|data]]&#039;&#039;&#039; disk-mode.&lt;br /&gt;
&lt;br /&gt;
There are many more [[Alpine setup scripts|setup-scripts]] available. All these tools may also be run later to adjust specific configurations. For example, to set up a graphical environment as covered under [[#Post-Installation|Post-Installation]] below.&lt;br /&gt;
&lt;br /&gt;
== Preparing for the installation ==&lt;br /&gt;
&lt;br /&gt;
=== Downloading installation image ===&lt;br /&gt;
&lt;br /&gt;
Installation image files are available in the &#039;&#039;&#039;iso&#039;&#039;&#039;, &#039;&#039;&#039;tar.gz&#039;&#039;&#039;, and &#039;&#039;&#039;img.gz&#039;&#039;&#039; formats. Download the [https://alpinelinux.org/downloads/ stable release installation image file] for the target computer&#039;s architecture with the corresponding &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum and &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature files. &lt;br /&gt;
{{Tip|Only download the &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum and &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature files from the [https://alpinelinux.org/downloads/ official site] and not from mirrors.}}&lt;br /&gt;
&lt;br /&gt;
Now you have three files in the following format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alpine-standard-*.iso&lt;br /&gt;
alpine-standard-*.iso.sha256&lt;br /&gt;
alpine-standard-*.iso.asc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;alpine-standard-{{AlpineLatest}}-x86_64.iso&amp;lt;/code&amp;gt; is the &#039;&#039;&#039;standard&#039;&#039;&#039; image file for version &#039;&#039;&#039;{{AlpineLatest}}&#039;&#039;&#039; and the &#039;&#039;&#039;x86_64&#039;&#039;&#039; architecture in the &#039;&#039;&#039;iso&#039;&#039;&#039; format.&lt;br /&gt;
&lt;br /&gt;
=== Verifying downloaded image ===&lt;br /&gt;
&lt;br /&gt;
From Security point of view, verify the downloaded image file for both checksum and GPG signature before proceeding further. The three required utilities i.e &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;gpg&amp;lt;/code&amp;gt; or their equivalents are available in every operating system including Linux, windows, Mac and BSD derivaties. &lt;br /&gt;
&lt;br /&gt;
{{Tip|Ensure that all the three downloaded files remain in the same folder. If not, adjust the commands accordingly.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum verifies the integrity of the downloaded image i.e no modifications occurred during download.&lt;br /&gt;
{{Cmd|sha256sum -c alpine-*.iso.&#039;&#039;&#039;sha256&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature verifies the link between the downloaded image to the individual who signed it. Signature verification involves two steps:&lt;br /&gt;
&lt;br /&gt;
Step 1. Download and import the gpg signature from official website &lt;br /&gt;
{{Cmd|curl https://alpinelinux.org/keys/ncopa.asc &amp;amp;#124; gpg --import ;}}&lt;br /&gt;
&lt;br /&gt;
Step 2. Verify that the image signature matches with the one downloaded in Step 1.&lt;br /&gt;
{{Cmd|gpg --verify alpine-*.iso.&#039;&#039;&#039;asc&#039;&#039;&#039; alpine-*.&#039;&#039;&#039;iso&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
=== Preparing installation media  ===&lt;br /&gt;
{{Seealso|Burning ISOs}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|All data currently on the installation media will be &#039;&#039;&#039;erased&#039;&#039;&#039;, when Alpine Linux installation image is written on it. Correctly identify the device name for the installation media using commands &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt;.}} &lt;br /&gt;
If downloaded image file is in &#039;&#039;&#039;img.gz&#039;&#039;&#039; format, unzip it using the command {{ic|gunzip alpine-rpi-{{AlpineLatest}}-aarch64.img.gz}} to {{ic|alpine-rpi-{{AlpineLatest}}-aarch64.img}} first before using with {{ic|dd}} command. In Linux {{ic|dd}} command can be used to write image files in both &#039;&#039;&#039;iso&#039;&#039;&#039; and &#039;&#039;&#039;img&#039;&#039;&#039; format to the installation media. &lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;tar.gz&#039;&#039;&#039; format image file is downloaded, follow the [[Create a Bootable Device#Manually copying Alpine files|instructions]] to create the installation media.&lt;br /&gt;
&lt;br /&gt;
Modify the input file(&#039;&#039;&#039;if&#039;&#039;&#039;)  of the {{ic|dd}} command according to the name and path to your image file and and the target device i.e output file(&#039;&#039;&#039;of&#039;&#039;&#039;) should be a device name &#039;&#039;&#039;/dev/sdX&#039;&#039;&#039; instead of partition like &#039;&#039;&#039;/dev/sdbXY&#039;&#039;&#039;:{{Cmd|# dd if{{=}}alpine-standard-{{AlpineLatest}}-x86_64.iso of{{=}}/dev/sdX bs{{=}}4M status{{=}}progress; eject /dev/sdX}}&lt;br /&gt;
&lt;br /&gt;
If your version of &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; does not support the option &amp;quot;status=progress&amp;quot;, remove it. The &amp;lt;code&amp;gt;eject&amp;lt;/code&amp;gt; command removes the target device from the system and ensures the write cache is completely flushed.&lt;br /&gt;
&lt;br /&gt;
In Windows and Mac OS, [https://www.balena.io/etcher/  Etcher] can be used to create an installation media.&lt;br /&gt;
&lt;br /&gt;
===  Verifying Installation media ===&lt;br /&gt;
&lt;br /&gt;
After detaching and re-attaching the device, a bit-wise comparison can verify the data written to the device (instead of just data buffered in RAM). If the comparison terminates with an end-of-file error on the .iso file side, all the contents from the image have been written (and re-read) successfully:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# cmp ~/Downloads/alpine-standard-{{AlpineLatest}}-x86_64.iso /dev/sdX &lt;br /&gt;
 cmp: EOF on alpine-standard-{{AlpineLatest}}-x86_64.iso&amp;lt;/Code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Booting Installation Media ===&lt;br /&gt;
&lt;br /&gt;
Insert the [[#Preparing_installation_media|Installation media]] to a proper drive or port of the computer and turn the machine on, or restart it, if already running.&lt;br /&gt;
{{Note| To successfully boot and install Alpine Linux, disable [[UEFI#Secure boot|secure boot]] in the BIOS. Once Alpine Linux is installed, this can be [[UEFI_Secure_Boot|enabled]].}}&lt;br /&gt;
If the computer does not automatically boot from the desired device, one needs to bring up the boot menu and choose the media to boot from. Depending on the computer, the menu may be accessed by repeatedly pressing a key quickly when booting starts. Some computers require that you press the button &#039;&#039;before&#039;&#039; starting the computer and hold it down while the computer boots. Typical keys are:  {{key|F9}}-{{key|F12}}, sometimes {{key|F7}} or {{key|F8}}. If these don&#039;t bring up the boot menu, it may be necessary to enter the BIOS configuration and adjust the boot settings, for which typical keys are: {{key|Del}} {{key|F1}} {{key|F2}} {{key|F6}} or {{key|Esc}}.&lt;br /&gt;
&lt;br /&gt;
== Installation Step Details ==&lt;br /&gt;
&lt;br /&gt;
=== Boot Process ===&lt;br /&gt;
&lt;br /&gt;
The boot process of the alpine installation image first copies the entire operating system into the RAM memory, and then starts a complete Alpine Linux system from there. It will initially only provide a basic command line environment that does not depend on reading from any (possibly slow) initial boot media, anymore.&lt;br /&gt;
&lt;br /&gt;
Local log-in is possible as the user &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;. Initially, the &#039;&#039;&#039;root&#039;&#039;&#039; user has no password.&lt;br /&gt;
&lt;br /&gt;
At the command prompt, an interactive script named [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] is available to configure and install Alpine Linux. The script can be customized by the optional [[Alpine_setup_scripts#Environment_Variables|environment variables]], in case of [[Installation#Data_Disk_Mode|&#039;&#039;&#039;&amp;quot;data&amp;quot;&#039;&#039;&#039;]] or [[Installation#System_Disk_Mode|&#039;&#039;&#039;&amp;quot;sys&amp;quot;&#039;&#039;&#039;]] mode. For e.g {{Codeline|&amp;lt;code&amp;gt;USE_EFI{{=}}1 BOOT_SIZE{{=}}512 setup-alpine&amp;lt;/code&amp;gt;}}, sets the disklabel type to gpt, creates 512MB &#039;&#039;&#039;/boot&#039;&#039;&#039; partition with &#039;&#039;&#039;vfat&#039;&#039;&#039; filesystem and uses &amp;lt;code&amp;gt;grub&amp;lt;/code&amp;gt; as bootloader.&lt;br /&gt;
&lt;br /&gt;
=== Base configuration ===&lt;br /&gt;
&lt;br /&gt;
Launch the Alpine Linux Installation by running the [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] script :&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# setup-alpine}}&lt;br /&gt;
&lt;br /&gt;
The question-and-answer dialog of &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; takes care of the base configuration. It sets up a network connection to access Internet to configure the system to boot into one of three different Alpine Linux &amp;quot;disk&amp;quot; modes:  [[Installation#Diskless_Mode|&#039;&#039;&#039;&amp;quot;diskless&amp;quot;&#039;&#039;&#039;(none)]],  [[Installation#Data_Disk_Mode|&#039;&#039;&#039;&amp;quot;data&amp;quot;&#039;&#039;&#039;]]  or [[Installation#System_Disk_Mode|&#039;&#039;&#039;&amp;quot;sys&amp;quot;&#039;&#039;&#039;]]. If you choose to edit any option, the relevant file is opened in [[BusyBox#vi| &#039;&#039;&#039;vi&#039;&#039;&#039; editor]] for editing.&lt;br /&gt;
&lt;br /&gt;
{{Tip| If you have access to a wired network, consider using [https://docs.alpinelinux.org/user-handbook/0.1a/Installing/setup_alpine.html#_setup_alpine_q Quick Mode], to complete the base configuration quickly.}}&lt;br /&gt;
&lt;br /&gt;
[[File:Installation-alpine-alpine-setup-3-setup-scripts.png|350px|thumb|right|Example &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; session]]&lt;br /&gt;
 &lt;br /&gt;
The &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; script offers the following configuration options:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Keyboard Layout&#039;&#039;&#039; (Local keyboard language and usage mode, e.g. &#039;&#039;us&#039;&#039; and variant of &#039;&#039;us-nodeadkeys&#039;&#039;.)&lt;br /&gt;
# &#039;&#039;&#039;Hostname&#039;&#039;&#039; (The name for the computer.)&lt;br /&gt;
# &#039;&#039;&#039;Network &#039;&#039;&#039; (Set up network connection to access Internet.)&lt;br /&gt;
#* Available interfaces are: &#039;&#039;&#039;eth0&#039;&#039;&#039; &#039;&#039;&#039;wlan0&#039;&#039;&#039;.(List depends on your hardware.)&lt;br /&gt;
#* Which one do you want to initialize? (or &#039;?&#039; or &#039;done&#039;) [eth0] (Enter &#039;done&#039; after configuring &#039;&#039;&#039;atleast&#039;&#039;&#039; one interface for Internet access.) &lt;br /&gt;
#* Do you want to do any manual network configuration? (y/n) [n] (Default uses &amp;quot;DHCP&amp;quot;.)  &lt;br /&gt;
# &#039;&#039;&#039;DNS Servers&#039;&#039;&#039; (If none of the interfaces configured in previous step uses dhcp, set DNS server. If unsure, leave DNS domain name blank and using &amp;lt;code&amp;gt;[https://quad9.net/ 9.9.9.9 2620:fe::fe]&amp;lt;/code&amp;gt; for DNS is typically adequate.)&lt;br /&gt;
# &#039;&#039;&#039;Root password&#039;&#039;&#039; (the password used to login to the root account)&lt;br /&gt;
# &#039;&#039;&#039;Timezone&#039;&#039;&#039; (Optionally display times/dates in your local time zone)&lt;br /&gt;
# &#039;&#039;&#039;HTTP/FTP Proxy&#039;&#039;&#039; (Proxy server to use for accessing the web/ftp. Use &amp;quot;none&amp;quot; for direct connections to websites and FTP servers.)&lt;br /&gt;
# &#039;&#039;&#039;Mirror&#039;&#039;&#039; (From where to download packages. Choose the organization you trust giving your usage patterns to.)&lt;br /&gt;
# &#039;&#039;&#039;Set up a user&#039;&#039;&#039; (Setting up a regular user account)&lt;br /&gt;
# &#039;&#039;&#039;NTP&#039;&#039;&#039; (Network Time Protocol client used for keeping the system clock in sync with a time server. Default is &amp;quot;busybox&amp;quot;.)&lt;br /&gt;
# &#039;&#039;&#039;SSH&#039;&#039;&#039; (Secure SHell remote access server. &amp;quot;OpenSSH&amp;quot; is part of the default install image. Use &amp;quot;none&amp;quot; to disable remote login, e.g. on laptops.)&lt;br /&gt;
# In most cases, either one of following line(s) is displayed as follows: &lt;br /&gt;
#: &#039;&#039;&#039;No disks found.&#039;&#039;&#039; or &#039;&#039;&#039; Available disks are: sda (128.0 GB JMicron  Tech )&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Disk Mode&#039;&#039;&#039; ( A pre-setup of the &amp;quot;diskless&amp;quot; system or base configuration is completed by answering &amp;quot;none&amp;quot; when asked for the following questions.) &lt;br /&gt;
#* Which disk(s) would you like to use? (or &#039;?&#039; for help or &#039;none&#039;) &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
#* Enter where to store configs (/media/ or &#039;none&#039;) &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
#* The location of the package cache &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Base configuration is complete with the above step. Refer to the [[#Alternative courses of action|alternative courses of action]] to proceed further.&lt;br /&gt;
&lt;br /&gt;
=== setup-alpine based System Disk Install ===  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script based system disk installation, needs an &#039;&#039;&#039; entire hard disk(s)&#039;&#039;&#039; for Alpine Linux and uses a partitioning layout with (/)root partition, /boot partition and a swap partition, where [[Alpine_setup_scripts#Environment_Variables|environment variables]] determine filesystem, size of the boot partition and the bootloader used.  If your use case matches the above, at the final step of [[#Base configuration|base configuration]], type the appropriate hard disk &#039;&#039;&#039;device name&#039;&#039;&#039; instead of &#039;&#039;&#039;none&#039;&#039;&#039;. If multiple disks are chosen, [[Alpine_setup_scripts#RAID|RAID]] is used.&lt;br /&gt;
 &lt;br /&gt;
* At the &#039;&#039;&#039;Disk Mode&#039;&#039;&#039; stage, &#039;&#039;&#039;sda&#039;&#039;&#039; or relevant disk(s) must be chosen in the below screen:&lt;br /&gt;
** Which disk(s) would you like to use? (or &#039;?&#039; for help or &#039;none&#039;) &#039;&#039;&#039;sda&#039;&#039;&#039;&lt;br /&gt;
** Confirmation for the chosen disk(s) appears. &#039;&#039;The following disk is selected:&#039;&#039; &#039;&#039;&#039;sda    (128.0 GB JMicron  Tech ).&#039;&#039;&#039; &lt;br /&gt;
{{Warning|Pay close attention to the disk name and size. If you enter &#039;&#039;&#039;sys&#039;&#039;&#039; in the next step, no further questions will be asked and data on the chosen disk(s) will be overwritten!. Enter {{key|Ctrl}}+{{key|c}} to abort the installation process. Proceed only if you are 100% sure.}}&lt;br /&gt;
* How would you like to use it? (&#039;sys&#039;, &#039;data&#039;, &#039;lvm&#039; or &#039;?&#039; for help) &#039;&#039;&#039;sys&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;sys&#039;&#039;&#039; is chosen, the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script will complete the traditional hard-disk installation of Alpine Linux on the chosen disk(s) without further questions.  Once the installation is complete, you can skip the next steps and proceed to [[#Reboot|reboot]] the system to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
=== Custom partitioning  ===&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_disks_manually#Manual_partitioning|Manual partitioning]] of the harddisk may be needed to prepare the harddisk for &amp;quot;sys&amp;quot; mode install using [[System Disk Mode|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] script and for storing the config file using [[Alpine_local_backup|&amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;]] and package cache for [[Diskless Mode|Diskless]] and for &#039;&#039;&#039;/var&#039;&#039;&#039; mount for [[Data Disk Mode|Data disk]] mode installs. Refer [[Setting up disks manually|Setting up disks manually]] page for specific configurations related to [[Setting_up_disks_manually#RAID|RAID]], [[Setting_up_disks_manually#Encryption|encryption]], [[Setting_up_disks_manually#LVM|LVM]], etc...&lt;br /&gt;
&lt;br /&gt;
=== Preparing for the first boot ===&lt;br /&gt;
&lt;br /&gt;
If [[#System_Disk_Mode|System Disk Mode]] of installation was performed, ignore this section and proceed to [[#Reboot|reboot]].&lt;br /&gt;
&lt;br /&gt;
If the new local system was configured to run in &amp;quot;diskless&amp;quot; or &amp;quot;data&amp;quot; mode, and you do not want keep booting from the initial (and possibly read-only) [[Installation#Preparing_installation_media|installation media]], create a  [[Create_a_Bootable_Device|customizable boot device]]. Once everything is in place, save your customized configuration with {{ic|lbu commit}} before rebooting.&lt;br /&gt;
&lt;br /&gt;
=== Reboot ===&lt;br /&gt;
&lt;br /&gt;
First, remove the initial installation media from the boot drive, or detach it from the port it&#039;s connected to. The system may now be power-cycled or rebooted to confirm everything is working correctly. The relevant commands for this are {{ic|poweroff}} or {{ic|reboot}}. Login into the new system with the root account.&lt;br /&gt;
&lt;br /&gt;
=== Completing the installation ===&lt;br /&gt;
&lt;br /&gt;
The installation script installs only the base operating system. &#039;&#039;&#039;No&#039;&#039;&#039; applications e.g. web server, mail server, desktop environment, or web browsers are installed.&lt;br /&gt;
&lt;br /&gt;
Please look at [[Installation#Post-Installation|Post-Installation]], for some common things to do after installation.&lt;br /&gt;
&lt;br /&gt;
== Custom Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- COMMENT FOR EDITORS&lt;br /&gt;
Specific topics should be kept on separate pages and manageable category-pages only must get listed with direct reference on this general page.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[Installation on a headless host]]&lt;br /&gt;
* [[Kernels]] &#039;&#039;(kernel selection, e.g. for VMs or RPi)&#039;&#039;&lt;br /&gt;
* [[How to make a custom ISO image with mkimage]] &#039;&#039;(installation media with its own configuration)&#039;&#039;&lt;br /&gt;
* [[Directly booting an ISO file]] &#039;&#039;(without flashing it to a disk or device)&#039;&#039;&lt;br /&gt;
* [[Alpine Linux in a chroot]]&lt;br /&gt;
* [[Netboot Alpine Linux using iPXE]]&lt;br /&gt;
* [[:Category:Virtualization|Virtualization]]&lt;br /&gt;
* [[Using an answerfile with setup-alpine]]&lt;br /&gt;
&lt;br /&gt;
Also see other [[:Category:Installation|Installation category]] pages.&lt;br /&gt;
&lt;br /&gt;
== Post-Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux packages stay close to the upstream design. Therefore, all upstream documentation about configuring a software package, as well as good configuration guides from other distributions that stay close to upstream, e.g. those in the [https://wiki.archlinux.org/ ArchWiki], or [https://wiki.gentoo.org/wiki/ Gentoo wiki] are to a large degree, also applicable to configuring the software on Alpine Linux, thus can be very useful.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- COMMENT FOR EDITORS&lt;br /&gt;
If you edit Post-Install,&lt;br /&gt;
&lt;br /&gt;
  * Consider that there are already [[Tutorials_and_Howtos#Post-Install]], [[Developer_Documentation#Package_management]] [[Daily driver guide]] and the Handbook, please work towards reducing duplication and providing an overview, and maintaining topic details of considerable size on their own pages.&lt;br /&gt;
  * Here, only the most relevant jumping off points are listed, not exact list duplicates!!!&lt;br /&gt;
  * Keep short-list of links here, as overview to more detailed topic specific pages.&lt;br /&gt;
  * Don&#039;t aggregate different topics at yet another place.&lt;br /&gt;
Any topic related to configuring Alpine as Desktop workstation i.e as a daily driver must go to the [[Daily driver guide]] or [[Tutorials_and_Howtos#Desktop|Desktop]]section. Links to Tutorial and How To&#039;s should be added to [[Tutorials_and_Howtos]] and not added here.&lt;br /&gt;
  * This page used to have too many links in the past i.e https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;amp;oldid=26677#Post-Installation. &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[Tutorials_and_Howtos#Desktop|Desktop &#039;How To&#039;]] - Alpine Linux as a desktop OS&lt;br /&gt;
* [[Tutorials_and_Howtos#Services|Hosting services]] - Such as mail/web/ssh/Firewall/VPN servers &lt;br /&gt;
* [[Tutorials_and_Howtos#Virtualization|Virtualization]] guide - For using Alpine Linux as both guest and host&lt;br /&gt;
* Guide to [[OpenRC|OpenRC]] - Init system used to configure services&lt;br /&gt;
* Create and maintain a [[Rescue disk]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Tutorials and Howtos]]&lt;br /&gt;
* [[Comparison with other distros]] &#039;&#039;(how common things are done on Alpine)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=32016</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Installation&amp;diff=32016"/>
		<updated>2026-02-05T05:16:46Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: moved content to Rescue disk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:hdd_mount.png|left|link=]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page exists to provide a basic overview to get started. Before actually installing, it can help to skim through the [[Alpine_Linux:FAQ| Frequently Asked Questions (FAQ)]], as well as to refer to the official installation guide at [https://docs.alpinelinux.org/ docs.alpinelinux.org].&lt;br /&gt;
&lt;br /&gt;
{{Tip|This is a wiki!&lt;br /&gt;
If something isn&#039;t correct, or is incomplete, you will have to figure it out, or ask for the correct solution in the [https://alpinelinux.org/community/ community].&lt;br /&gt;
&lt;br /&gt;
And then carefully [[Help:Editing|edit]] the wiki page.&lt;br /&gt;
&lt;br /&gt;
Just as those before who did it for you.}}&lt;br /&gt;
&lt;br /&gt;
== Minimal Hardware Requirements ==&lt;br /&gt;
{{Main|Requirements}}&lt;br /&gt;
* At least 128 MB of RAM. [A graphical desktop system may require up to 512 minimum.]. Note that an installation itself (from ISO) generally requires at least 320 MB during installation.&lt;br /&gt;
* At least 0-700 MB space on a writable storage device. [Only required in [[#System Disk Mode|&amp;quot;sys&amp;quot;]] or [[#Data Disk Mode|&amp;quot;data&amp;quot;]] mode installations. It is optional in [[#Diskless Mode|&amp;quot;diskless&amp;quot;]] mode, where it may be used to save newer data and configurations states of a running system.]&lt;br /&gt;
* A working internet connection is required to complete [[#System Disk Mode|&amp;quot;sys&amp;quot;]] mode installation or use &#039;&#039;&#039;Extended image&#039;&#039;&#039; if available for your architecture.&lt;br /&gt;
&lt;br /&gt;
{{Note|Refer [[#Custom Installation Instructions|custom installation instructions]] for headless system, virtualization etc. Most of the steps outlined on this page applies to all [[Architecture#Architectures_supported|Architectures]] supported by Alpine Linux. For more specific installation instructions, refer to their respective pages.}}&lt;br /&gt;
&lt;br /&gt;
== Installation Overview ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux can be installed and run in three modes i.e [[#Diskless_Mode|Diskless Mode]], [[#Data_Disk_Mode|Data Disk Mode]] and [[#System_Disk_Mode|System Disk Mode]]. The first two installation modes are sometimes referred to, collectively, as &amp;quot;run-from-RAM&amp;quot; installations. The installation procedure for Alpine Linux &#039;&#039;&#039;requires basic understanding of the three modes&#039;&#039;&#039; explained in brief below: &lt;br /&gt;
&lt;br /&gt;
==== Diskless Mode ====&lt;br /&gt;
{{Main|Diskless Mode}}&lt;br /&gt;
In Diskless mode the entire operating system with all applications are first loaded into RAM and then only run from there. This mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear.  Alpine Linux uses this method to boot the .iso installation images. The [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] script configures the installed system to continue to boot like this if &amp;quot;disk=none&amp;quot; is specified.&lt;br /&gt;
&lt;br /&gt;
==== Data Disk Mode ====&lt;br /&gt;
{{Main|Data Disk Mode}}&lt;br /&gt;
In Data Disk mode also the operating system  runs from system RAM, thus it enjoys the same accelerated operation speed as &amp;quot;diskless&amp;quot; mode. However, swap storage and the entire {{Path|/var}} directory tree get mounted from a persistent storage device. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size. &lt;br /&gt;
&lt;br /&gt;
==== System Disk Mode ====&lt;br /&gt;
{{Main|System Disk Mode}}&lt;br /&gt;
System or &#039;&#039;&#039;sys&#039;&#039;&#039; Disk Mode is the traditional hard-disk install. Alpine Linux can be installed to an [[#setup-alpine based System Disk Install|&#039;&#039;&#039;entire hard disk&#039;&#039;&#039; using &#039;&#039;setup-alpine&#039;&#039;]] script or to a [[System Disk Mode|&#039;&#039;&#039;partition&#039;&#039;&#039; using &#039;&#039;setup-disk&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== General course of action ===&lt;br /&gt;
&lt;br /&gt;
It is really helpful for many use cases to [[#Preparing for the installation|prepare]] and complete the [[#Installation Step Details|installation]] until the [[#Base configuration|base configuration]] step, then proceed with installation of the target system with any one of the various [[#Alternative courses of action|alternative]] courses of action.&lt;br /&gt;
&lt;br /&gt;
=== Alternative courses of action ===&lt;br /&gt;
&lt;br /&gt;
Examples of preparation options:&lt;br /&gt;
&lt;br /&gt;
* Download specific driver to configure [[Alpine_kernel_module_support#List_of_out-of-tree_kernel_module_packages|hardware]], if the [[Kernels#Firmware|firmware]] does not have it and/or install some software tool that may be missing in the live system by using the Alpine package manager &amp;lt;code&amp;gt;[[Alpine Package Keeper|apk]]&amp;lt;/code&amp;gt;.  &lt;br /&gt;
* Do a [[Setting up disks manually#Manual partitioning|manual partitioning]] of the hard disk that avoids overwrite of an entire disk.&lt;br /&gt;
&lt;br /&gt;
Examples of such options:&lt;br /&gt;
&lt;br /&gt;
* To install Alpine Linux on an &#039;&#039;&#039;entire hard disk&#039;&#039;&#039; with optional [[Alpine setup scripts#Environment Variables|environment variables]], proceed to [[#setup-alpine based System Disk Install|setup-alpine based System Disk Install]].&lt;br /&gt;
* Use {{ic|setup-disk}} script to complete a [[System Disk Mode|traditional hard disk installation]] on a partition or to [[Dualbooting|dualboot]] or to configure [[Setting up disks manually#RAID|RAID]], [[Setting up disks manually#Encryption|encryption]] or [[Setting up disks manually#LVM|LVM]] for [[#System Disk Mode|&amp;quot;system&amp;quot;]] disk mode or to add a [[#Data Disk Mode|&amp;quot;data&amp;quot;]] mode partition.&lt;br /&gt;
* Create a [[Create a Bootable Device#Using setup-bootable|customizable boot media]] i.e a boot device with a writable filesystem for &#039;&#039;&#039;[[#Diskless Mode|diskless]]&#039;&#039;&#039; or &#039;&#039;&#039;[[#Data Disk Mode|data]]&#039;&#039;&#039; disk-mode.&lt;br /&gt;
* Configure a [[Diskless Mode#Using an internal disk for persistent storage|internal disk for persistent storage]] to save the local configuration state and local package cache for the [[#Diskless Mode|diskless]] system or &#039;&#039;&#039;[[#Data Disk Mode|data]]&#039;&#039;&#039; disk-mode.&lt;br /&gt;
&lt;br /&gt;
There are many more [[Alpine setup scripts|setup-scripts]] available. All these tools may also be run later to adjust specific configurations. For example, to set up a graphical environment as covered under [[#Post-Installation|Post-Installation]] below.&lt;br /&gt;
&lt;br /&gt;
== Preparing for the installation ==&lt;br /&gt;
&lt;br /&gt;
=== Downloading installation image ===&lt;br /&gt;
&lt;br /&gt;
Installation image files are available in the &#039;&#039;&#039;iso&#039;&#039;&#039;, &#039;&#039;&#039;tar.gz&#039;&#039;&#039;, and &#039;&#039;&#039;img.gz&#039;&#039;&#039; formats. Download the [https://alpinelinux.org/downloads/ stable release installation image file] for the target computer&#039;s architecture with the corresponding &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum and &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature files. &lt;br /&gt;
{{Tip|Only download the &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum and &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature files from the [https://alpinelinux.org/downloads/ official site] and not from mirrors.}}&lt;br /&gt;
&lt;br /&gt;
Now you have three files in the following format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alpine-standard-*.iso&lt;br /&gt;
alpine-standard-*.iso.sha256&lt;br /&gt;
alpine-standard-*.iso.asc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;alpine-standard-{{AlpineLatest}}-x86_64.iso&amp;lt;/code&amp;gt; is the &#039;&#039;&#039;standard&#039;&#039;&#039; image file for version &#039;&#039;&#039;{{AlpineLatest}}&#039;&#039;&#039; and the &#039;&#039;&#039;x86_64&#039;&#039;&#039; architecture in the &#039;&#039;&#039;iso&#039;&#039;&#039; format.&lt;br /&gt;
&lt;br /&gt;
=== Verifying downloaded image ===&lt;br /&gt;
&lt;br /&gt;
From Security point of view, verify the downloaded image file for both checksum and GPG signature before proceeding further. The three required utilities i.e &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;curl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;gpg&amp;lt;/code&amp;gt; or their equivalents are available in every operating system including Linux, windows, Mac and BSD derivaties. &lt;br /&gt;
&lt;br /&gt;
{{Tip|Ensure that all the three downloaded files remain in the same folder. If not, adjust the commands accordingly.}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sha256&amp;lt;/code&amp;gt; checksum verifies the integrity of the downloaded image i.e no modifications occurred during download.&lt;br /&gt;
{{Cmd|sha256sum -c alpine-*.iso.&#039;&#039;&#039;sha256&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;GPG&amp;lt;/code&amp;gt; signature verifies the link between the downloaded image to the individual who signed it. Signature verification involves two steps:&lt;br /&gt;
&lt;br /&gt;
Step 1. Download and import the gpg signature from official website &lt;br /&gt;
{{Cmd|curl https://alpinelinux.org/keys/ncopa.asc &amp;amp;#124; gpg --import ;}}&lt;br /&gt;
&lt;br /&gt;
Step 2. Verify that the image signature matches with the one downloaded in Step 1.&lt;br /&gt;
{{Cmd|gpg --verify alpine-*.iso.&#039;&#039;&#039;asc&#039;&#039;&#039; alpine-*.&#039;&#039;&#039;iso&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
=== Preparing installation media  ===&lt;br /&gt;
{{Seealso|Burning ISOs}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|All data currently on the installation media will be &#039;&#039;&#039;erased&#039;&#039;&#039;, when Alpine Linux installation image is written on it. Correctly identify the device name for the installation media using commands &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;blkid&amp;lt;/code&amp;gt;.}} &lt;br /&gt;
If downloaded image file is in &#039;&#039;&#039;img.gz&#039;&#039;&#039; format, unzip it using the command {{ic|gunzip alpine-rpi-{{AlpineLatest}}-aarch64.img.gz}} to {{ic|alpine-rpi-{{AlpineLatest}}-aarch64.img}} first before using with {{ic|dd}} command. In Linux {{ic|dd}} command can be used to write image files in both &#039;&#039;&#039;iso&#039;&#039;&#039; and &#039;&#039;&#039;img&#039;&#039;&#039; format to the installation media. &lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;tar.gz&#039;&#039;&#039; format image file is downloaded, follow the [[Create a Bootable Device#Manually copying Alpine files|instructions]] to create the installation media.&lt;br /&gt;
&lt;br /&gt;
Modify the input file(&#039;&#039;&#039;if&#039;&#039;&#039;)  of the {{ic|dd}} command according to the name and path to your image file and and the target device i.e output file(&#039;&#039;&#039;of&#039;&#039;&#039;) should be a device name &#039;&#039;&#039;/dev/sdX&#039;&#039;&#039; instead of partition like &#039;&#039;&#039;/dev/sdbXY&#039;&#039;&#039;:{{Cmd|# dd if{{=}}alpine-standard-{{AlpineLatest}}-x86_64.iso of{{=}}/dev/sdX bs{{=}}4M status{{=}}progress; eject /dev/sdX}}&lt;br /&gt;
&lt;br /&gt;
If your version of &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt; does not support the option &amp;quot;status=progress&amp;quot;, remove it. The &amp;lt;code&amp;gt;eject&amp;lt;/code&amp;gt; command removes the target device from the system and ensures the write cache is completely flushed.&lt;br /&gt;
&lt;br /&gt;
In Windows and Mac OS, [https://www.balena.io/etcher/  Etcher] can be used to create an installation media.&lt;br /&gt;
&lt;br /&gt;
===  Verifying Installation media ===&lt;br /&gt;
&lt;br /&gt;
After detaching and re-attaching the device, a bit-wise comparison can verify the data written to the device (instead of just data buffered in RAM). If the comparison terminates with an end-of-file error on the .iso file side, all the contents from the image have been written (and re-read) successfully:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# cmp ~/Downloads/alpine-standard-{{AlpineLatest}}-x86_64.iso /dev/sdX &lt;br /&gt;
 cmp: EOF on alpine-standard-{{AlpineLatest}}-x86_64.iso&amp;lt;/Code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Booting Installation Media ===&lt;br /&gt;
&lt;br /&gt;
Insert the [[#Preparing_installation_media|Installation media]] to a proper drive or port of the computer and turn the machine on, or restart it, if already running.&lt;br /&gt;
{{Note| To successfully boot and install Alpine Linux, disable [[UEFI#Secure boot|secure boot]] in the BIOS. Once Alpine Linux is installed, this can be [[UEFI_Secure_Boot|enabled]].}}&lt;br /&gt;
If the computer does not automatically boot from the desired device, one needs to bring up the boot menu and choose the media to boot from. Depending on the computer, the menu may be accessed by repeatedly pressing a key quickly when booting starts. Some computers require that you press the button &#039;&#039;before&#039;&#039; starting the computer and hold it down while the computer boots. Typical keys are:  {{key|F9}}-{{key|F12}}, sometimes {{key|F7}} or {{key|F8}}. If these don&#039;t bring up the boot menu, it may be necessary to enter the BIOS configuration and adjust the boot settings, for which typical keys are: {{key|Del}} {{key|F1}} {{key|F2}} {{key|F6}} or {{key|Esc}}.&lt;br /&gt;
&lt;br /&gt;
== Installation Step Details ==&lt;br /&gt;
&lt;br /&gt;
=== Boot Process ===&lt;br /&gt;
&lt;br /&gt;
The boot process of the alpine installation image first copies the entire operating system into the RAM memory, and then starts a complete Alpine Linux system from there. It will initially only provide a basic command line environment that does not depend on reading from any (possibly slow) initial boot media, anymore.&lt;br /&gt;
&lt;br /&gt;
Local log-in is possible as the user &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;. Initially, the &#039;&#039;&#039;root&#039;&#039;&#039; user has no password.&lt;br /&gt;
&lt;br /&gt;
At the command prompt, an interactive script named [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] is available to configure and install Alpine Linux. The script can be customized by the optional [[Alpine_setup_scripts#Environment_Variables|environment variables]], in case of [[Installation#Data_Disk_Mode|&#039;&#039;&#039;&amp;quot;data&amp;quot;&#039;&#039;&#039;]] or [[Installation#System_Disk_Mode|&#039;&#039;&#039;&amp;quot;sys&amp;quot;&#039;&#039;&#039;]] mode. For e.g {{Codeline|&amp;lt;code&amp;gt;USE_EFI{{=}}1 BOOT_SIZE{{=}}512 setup-alpine&amp;lt;/code&amp;gt;}}, sets the disklabel type to gpt, creates 512MB &#039;&#039;&#039;/boot&#039;&#039;&#039; partition with &#039;&#039;&#039;vfat&#039;&#039;&#039; filesystem and uses &amp;lt;code&amp;gt;grub&amp;lt;/code&amp;gt; as bootloader.&lt;br /&gt;
&lt;br /&gt;
=== Base configuration ===&lt;br /&gt;
&lt;br /&gt;
Launch the Alpine Linux Installation by running the [[Alpine_setup_scripts#setup-alpine|&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt;]] script :&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# setup-alpine}}&lt;br /&gt;
&lt;br /&gt;
The question-and-answer dialog of &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; takes care of the base configuration. It sets up a network connection to access Internet to configure the system to boot into one of three different Alpine Linux &amp;quot;disk&amp;quot; modes:  [[Installation#Diskless_Mode|&#039;&#039;&#039;&amp;quot;diskless&amp;quot;&#039;&#039;&#039;(none)]],  [[Installation#Data_Disk_Mode|&#039;&#039;&#039;&amp;quot;data&amp;quot;&#039;&#039;&#039;]]  or [[Installation#System_Disk_Mode|&#039;&#039;&#039;&amp;quot;sys&amp;quot;&#039;&#039;&#039;]]. If you choose to edit any option, the relevant file is opened in [[BusyBox#vi| &#039;&#039;&#039;vi&#039;&#039;&#039; editor]] for editing.&lt;br /&gt;
&lt;br /&gt;
{{Tip| If you have access to a wired network, consider using [https://docs.alpinelinux.org/user-handbook/0.1a/Installing/setup_alpine.html#_setup_alpine_q Quick Mode], to complete the base configuration quickly.}}&lt;br /&gt;
&lt;br /&gt;
[[File:Installation-alpine-alpine-setup-3-setup-scripts.png|350px|thumb|right|Example &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; session]]&lt;br /&gt;
 &lt;br /&gt;
The &amp;lt;code&amp;gt;[[Alpine_setup_scripts#setup-alpine|setup-alpine]]&amp;lt;/code&amp;gt; script offers the following configuration options:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Keyboard Layout&#039;&#039;&#039; (Local keyboard language and usage mode, e.g. &#039;&#039;us&#039;&#039; and variant of &#039;&#039;us-nodeadkeys&#039;&#039;.)&lt;br /&gt;
# &#039;&#039;&#039;Hostname&#039;&#039;&#039; (The name for the computer.)&lt;br /&gt;
# &#039;&#039;&#039;Network &#039;&#039;&#039; (Set up network connection to access Internet.)&lt;br /&gt;
#* Available interfaces are: &#039;&#039;&#039;eth0&#039;&#039;&#039; &#039;&#039;&#039;wlan0&#039;&#039;&#039;.(List depends on your hardware.)&lt;br /&gt;
#* Which one do you want to initialize? (or &#039;?&#039; or &#039;done&#039;) [eth0] (Enter &#039;done&#039; after configuring &#039;&#039;&#039;atleast&#039;&#039;&#039; one interface for Internet access.) &lt;br /&gt;
#* Do you want to do any manual network configuration? (y/n) [n] (Default uses &amp;quot;DHCP&amp;quot;.)  &lt;br /&gt;
# &#039;&#039;&#039;DNS Servers&#039;&#039;&#039; (If none of the interfaces configured in previous step uses dhcp, set DNS server. If unsure, leave DNS domain name blank and using &amp;lt;code&amp;gt;[https://quad9.net/ 9.9.9.9 2620:fe::fe]&amp;lt;/code&amp;gt; for DNS is typically adequate.)&lt;br /&gt;
# &#039;&#039;&#039;Root password&#039;&#039;&#039; (the password used to login to the root account)&lt;br /&gt;
# &#039;&#039;&#039;Timezone&#039;&#039;&#039; (Optionally display times/dates in your local time zone)&lt;br /&gt;
# &#039;&#039;&#039;HTTP/FTP Proxy&#039;&#039;&#039; (Proxy server to use for accessing the web/ftp. Use &amp;quot;none&amp;quot; for direct connections to websites and FTP servers.)&lt;br /&gt;
# &#039;&#039;&#039;Mirror&#039;&#039;&#039; (From where to download packages. Choose the organization you trust giving your usage patterns to.)&lt;br /&gt;
# &#039;&#039;&#039;Set up a user&#039;&#039;&#039; (Setting up a regular user account)&lt;br /&gt;
# &#039;&#039;&#039;NTP&#039;&#039;&#039; (Network Time Protocol client used for keeping the system clock in sync with a time server. Default is &amp;quot;busybox&amp;quot;.)&lt;br /&gt;
# &#039;&#039;&#039;SSH&#039;&#039;&#039; (Secure SHell remote access server. &amp;quot;OpenSSH&amp;quot; is part of the default install image. Use &amp;quot;none&amp;quot; to disable remote login, e.g. on laptops.)&lt;br /&gt;
# In most cases, either one of following line(s) is displayed as follows: &lt;br /&gt;
#: &#039;&#039;&#039;No disks found.&#039;&#039;&#039; or &#039;&#039;&#039; Available disks are: sda (128.0 GB JMicron  Tech )&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;Disk Mode&#039;&#039;&#039; ( A pre-setup of the &amp;quot;diskless&amp;quot; system or base configuration is completed by answering &amp;quot;none&amp;quot; when asked for the following questions.) &lt;br /&gt;
#* Which disk(s) would you like to use? (or &#039;?&#039; for help or &#039;none&#039;) &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
#* Enter where to store configs (/media/ or &#039;none&#039;) &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
#* The location of the package cache &#039;&#039;&#039;none&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Base configuration is complete with the above step. Refer to the [[#Alternative courses of action|alternative courses of action]] to proceed further.&lt;br /&gt;
&lt;br /&gt;
=== setup-alpine based System Disk Install ===  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script based system disk installation, needs an &#039;&#039;&#039; entire hard disk(s)&#039;&#039;&#039; for Alpine Linux and uses a partitioning layout with (/)root partition, /boot partition and a swap partition, where [[Alpine_setup_scripts#Environment_Variables|environment variables]] determine filesystem, size of the boot partition and the bootloader used.  If your use case matches the above, at the final step of [[#Base configuration|base configuration]], type the appropriate hard disk &#039;&#039;&#039;device name&#039;&#039;&#039; instead of &#039;&#039;&#039;none&#039;&#039;&#039;. If multiple disks are chosen, [[Alpine_setup_scripts#RAID|RAID]] is used.&lt;br /&gt;
 &lt;br /&gt;
* At the &#039;&#039;&#039;Disk Mode&#039;&#039;&#039; stage, &#039;&#039;&#039;sda&#039;&#039;&#039; or relevant disk(s) must be chosen in the below screen:&lt;br /&gt;
** Which disk(s) would you like to use? (or &#039;?&#039; for help or &#039;none&#039;) &#039;&#039;&#039;sda&#039;&#039;&#039;&lt;br /&gt;
** Confirmation for the chosen disk(s) appears. &#039;&#039;The following disk is selected:&#039;&#039; &#039;&#039;&#039;sda    (128.0 GB JMicron  Tech ).&#039;&#039;&#039; &lt;br /&gt;
{{Warning|Pay close attention to the disk name and size. If you enter &#039;&#039;&#039;sys&#039;&#039;&#039; in the next step, no further questions will be asked and data on the chosen disk(s) will be overwritten!. Enter {{key|Ctrl}}+{{key|c}} to abort the installation process. Proceed only if you are 100% sure.}}&lt;br /&gt;
* How would you like to use it? (&#039;sys&#039;, &#039;data&#039;, &#039;lvm&#039; or &#039;?&#039; for help) &#039;&#039;&#039;sys&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;sys&#039;&#039;&#039; is chosen, the &amp;lt;code&amp;gt;setup-alpine&amp;lt;/code&amp;gt; script will complete the traditional hard-disk installation of Alpine Linux on the chosen disk(s) without further questions.  Once the installation is complete, you can skip the next steps and proceed to [[#Reboot|reboot]] the system to boot into the newly installed Alpine Linux and [[Installation#Post-Installation|configure]] further.&lt;br /&gt;
&lt;br /&gt;
=== Custom partitioning  ===&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_disks_manually#Manual_partitioning|Manual partitioning]] of the harddisk may be needed to prepare the harddisk for &amp;quot;sys&amp;quot; mode install using [[System Disk Mode|&amp;lt;code&amp;gt;setup-disk&amp;lt;/code&amp;gt;]] script and for storing the config file using [[Alpine_local_backup|&amp;lt;code&amp;gt;lbu commit&amp;lt;/code&amp;gt;]] and package cache for [[Diskless Mode|Diskless]] and for &#039;&#039;&#039;/var&#039;&#039;&#039; mount for [[Data Disk Mode|Data disk]] mode installs. Refer [[Setting up disks manually|Setting up disks manually]] page for specific configurations related to [[Setting_up_disks_manually#RAID|RAID]], [[Setting_up_disks_manually#Encryption|encryption]], [[Setting_up_disks_manually#LVM|LVM]], etc...&lt;br /&gt;
&lt;br /&gt;
=== Preparing for the first boot ===&lt;br /&gt;
&lt;br /&gt;
If [[#System_Disk_Mode|System Disk Mode]] of installation was performed, ignore this section and proceed to [[#Reboot|reboot]].&lt;br /&gt;
&lt;br /&gt;
If the new local system was configured to run in &amp;quot;diskless&amp;quot; or &amp;quot;data&amp;quot; mode, and you do not want keep booting from the initial (and possibly read-only) [[Installation#Preparing_installation_media|installation media]], create a  [[Create_a_Bootable_Device|customizable boot device]]. Once everything is in place, save your customized configuration with {{ic|lbu commit}} before rebooting.&lt;br /&gt;
&lt;br /&gt;
=== Reboot ===&lt;br /&gt;
&lt;br /&gt;
First, remove the initial installation media from the boot drive, or detach it from the port it&#039;s connected to. The system may now be power-cycled or rebooted to confirm everything is working correctly. The relevant commands for this are {{ic|poweroff}} or {{ic|reboot}}. Login into the new system with the root account.&lt;br /&gt;
&lt;br /&gt;
=== Completing the installation ===&lt;br /&gt;
&lt;br /&gt;
The installation script installs only the base operating system. &#039;&#039;&#039;No&#039;&#039;&#039; applications e.g. web server, mail server, desktop environment, or web browsers are installed.&lt;br /&gt;
&lt;br /&gt;
Please look at [[Installation#Post-Installation|Post-Installation]], for some common things to do after installation.&lt;br /&gt;
&lt;br /&gt;
== Custom Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- COMMENT FOR EDITORS&lt;br /&gt;
Specific topics should be kept on separate pages and manageable category-pages only must get listed with direct reference on this general page.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[Installation on a headless host]]&lt;br /&gt;
* [[Kernels]] &#039;&#039;(kernel selection, e.g. for VMs or RPi)&#039;&#039;&lt;br /&gt;
* [[How to make a custom ISO image with mkimage]] &#039;&#039;(installation media with its own configuration)&#039;&#039;&lt;br /&gt;
* [[Directly booting an ISO file]] &#039;&#039;(without flashing it to a disk or device)&#039;&#039;&lt;br /&gt;
* [[Alpine Linux in a chroot]]&lt;br /&gt;
* [[Netboot Alpine Linux using iPXE]]&lt;br /&gt;
* [[:Category:Virtualization|Virtualization]]&lt;br /&gt;
* [[Using an answerfile with setup-alpine]]&lt;br /&gt;
&lt;br /&gt;
Also see other [[:Category:Installation|Installation category]] pages.&lt;br /&gt;
&lt;br /&gt;
== Post-Installation ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux packages stay close to the upstream design. Therefore, all upstream documentation about configuring a software package, as well as good configuration guides from other distributions that stay close to upstream, e.g. those in the [https://wiki.archlinux.org/ ArchWiki], or [https://wiki.gentoo.org/wiki/ Gentoo wiki] are to a large degree, also applicable to configuring the software on Alpine Linux, thus can be very useful.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- COMMENT FOR EDITORS&lt;br /&gt;
If you edit Post-Install,&lt;br /&gt;
&lt;br /&gt;
  * Consider that there are already [[Tutorials_and_Howtos#Post-Install]], [[Developer_Documentation#Package_management]] [[Daily driver guide]] and the Handbook, please work towards reducing duplication and providing an overview, and maintaining topic details of considerable size on their own pages.&lt;br /&gt;
  * Here, only the most relevant jumping off points are listed, not exact list duplicates!!!&lt;br /&gt;
  * Keep short-list of links here, as overview to more detailed topic specific pages.&lt;br /&gt;
  * Don&#039;t aggregate different topics at yet another place.&lt;br /&gt;
Any topic related to configuring Alpine as Desktop workstation i.e as a daily driver must go to the [[Daily driver guide]] or [[Tutorials_and_Howtos#Desktop|Desktop]]section. Links to Tutorial and How To&#039;s should be added to [[Tutorials_and_Howtos]] and not added here.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[Tutorials_and_Howtos#Desktop|Desktop &#039;How To&#039;]] - Alpine Linux as a desktop OS&lt;br /&gt;
* [[Tutorials_and_Howtos#Services|Hosting services]] - Such as mail/web/ssh/Firewall/VPN servers &lt;br /&gt;
* [[Tutorials_and_Howtos#Virtualization|Virtualization]] guide - For using Alpine Linux as both guest and host&lt;br /&gt;
* Guide to [[OpenRC|OpenRC]] - Init system used to configure services&lt;br /&gt;
* Create and maintain a [[Rescue disk]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Tutorials and Howtos]]&lt;br /&gt;
* [[Comparison with other distros]] &#039;&#039;(how common things are done on Alpine)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Rescue_disk&amp;diff=32015</id>
		<title>Rescue disk</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Rescue_disk&amp;diff=32015"/>
		<updated>2026-02-05T05:16:05Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: moved content from Installation page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A Rescue disk also known as repair disk allows to easily repair an installation that may become faulty due to a package conflict or misconfiguration. To preempt this, a wise precaution would be to prepare and maintain a rescue disk. A rescue disk provides a platform to execute commands using [[chroot]].  &lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
* Alpine linux [[Installation#Preparing_installation_media|installation media]] could be retained for this purpose. &lt;br /&gt;
* A [[Create a Bootable Device|customizable boot device]] for Alpine Linux, e.g. a USB-Stick/CompactFlash/SDCard or SSD/NVMe harddisk based boot device with a writable filesystem i.e, non-iso9660 is also a very good fit for this purpose. &lt;br /&gt;
&lt;br /&gt;
For additional flexibility, rescue disk could be installed on an alternative media (another SD card, USB pendrive, CD-ROM, etc) containing either:-&lt;br /&gt;
::(a) a different Alpine Linux version to your workstation&#039;s i.e. current-stable vs Edge or vice-versa in case your current impasse is due to a temporary conflict, say, in Edge, it may not manifest in current-stable&lt;br /&gt;
::(b) a different distribution&lt;br /&gt;
This would be handy as a fallback workstation operating system to investigate the issue&lt;br /&gt;
&lt;br /&gt;
== Maintenance ==&lt;br /&gt;
&lt;br /&gt;
Remember to copy over working {{Path|.config}} files, user guides, etc. from your current system onto the rescue disk beforehand. &lt;br /&gt;
&lt;br /&gt;
{{Tip|Update the rescue disk periodically, particularly if major changes are made to your system.}}&lt;br /&gt;
&lt;br /&gt;
== Troubelshooting ==&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Fix_my_Gentoo Gentoo recovery page]&lt;br /&gt;
* [[Alpine rescue|List of useful packages]]&lt;br /&gt;
* [https://www.system-rescue.org/ Systemrescue CD] &lt;br /&gt;
&lt;br /&gt;
[[Category:System Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Mumble&amp;diff=32007</id>
		<title>Talk:Mumble</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Mumble&amp;diff=32007"/>
		<updated>2026-02-02T04:02:34Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: suggested about the advantages of moving a page over copying the contents to a new page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Mumble page created with contents of of Murmur page ==&lt;br /&gt;
#Murmur was the old name for the {{Pkg|mumble-server}} package, and &#039;&#039;&#039;Mumble&#039;&#039;&#039; is the preferred naming of the joint client/server program upstream.&lt;br /&gt;
#Expanded Beginning section to describe distinction between the client and server.&lt;br /&gt;
#Updated &amp;quot;murmur&amp;quot; package and service to their renamed version: &amp;quot;mumble-server&amp;quot;.&lt;br /&gt;
#Indicated that installing &amp;quot;murmur&amp;quot; will install &amp;quot;mumble-server&amp;quot; due to the &amp;quot;Provides&amp;quot; directive, etc.&lt;br /&gt;
#Added that Alpine Linux v3.21 and earlier still retain the original &amp;quot;murmur&amp;quot; package &amp;amp; service naming.&lt;br /&gt;
#Added that the {{Pkg|mumble-server-openrc}} package would be installed automatically on Alpine Linux&#039;s default openrc init installations&lt;br /&gt;
#Added command prompts and doas.&lt;br /&gt;
#Added &#039;&#039;See also&#039;&#039;: [[Generating SSL certs with ACF]].&lt;br /&gt;
#Style/grammar amendments. &lt;br /&gt;
[[User:John3-16|John3-16]] ([[User talk:John3-16|talk]]) 04:55, 1 February 2026 (UTC)&lt;br /&gt;
: Dear [[User:John3-16|John3-16]], Thanks for updating the wiki.  For examples like this Murmur-&amp;gt;Mumble, you may want to consider &#039;&#039;&#039;moving a page&#039;&#039;&#039; instead of creating a new page as that will provide an option to preserve all the previous editing history. Moving a page will add also the redirect tag automatically. Thanks again for your contributions. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 04:02, 2 February 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=31997</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=31997"/>
		<updated>2026-01-28T09:17:11Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added Note template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. &lt;br /&gt;
&lt;br /&gt;
{{Note|If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, local packages are upgraded or downgraded back to a repository version.}}&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=31996</id>
		<title>Alpine Package Keeper</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Package_Keeper&amp;diff=31996"/>
		<updated>2026-01-28T08:36:01Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: documented the hash convention in world file and their replacement as per https://gitlab.alpinelinux.org/alpine/apk-tools/-/commit/74b620c&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--For searching: apk, APK--&amp;gt;&lt;br /&gt;
{{TOC right}}&lt;br /&gt;
This page documents the Alpine Package Keeper(APK), the package manager in Alpine Linux. Refer to the excellent guide [https://docs.alpinelinux.org/user-handbook/0.1a/Working/apk.html Working with APK] from Alpine Linux documentation project to learn the basics quickly. &lt;br /&gt;
&lt;br /&gt;
[[Software management#Graphical software manager|Graphical software managers]] can be used for certain basic package management tasks like adding/removing and upgrading packages.&lt;br /&gt;
&lt;br /&gt;
Package management in RAM-based installs like [[Installation#Diskless_Mode|Diskless]] mode and [[Data Disk Mode|Data disk]] mode require [[#Package management in Diskless mode|additional step using lbu]]. &lt;br /&gt;
&lt;br /&gt;
== apk v3 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Add {{Pill_Clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}} in every section which deals with apk v3 only feature.This section and associated pill templates are needed until v3.22 reaches EOL on 2027-05-01. --&amp;gt;&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Release Notes for Alpine 3.23.0#apk-tools_v3}}&lt;br /&gt;
With the release of Alpine Linux [[Release Notes for Alpine 3.23.0|v3.23]], the Alpine package manager has transitioned to [https://gitlab.alpinelinux.org/alpine/apk-tools/-/releases/v3.0.0 apk-tools v3], but the index and package formats are still at v2. apk v3 targets backwards compatibility and new features are flagged on the relevant sections of this page as seen on the right side. The diff output of the documentation between V2 and V3 is [[Apk/apkv3 doc diff|available here]] for reference.&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The {{pkg|apk-tools}} provides &#039;&#039;&#039;apk&#039;&#039;&#039; and it supports the following operations:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;width:100%; border:1px #0771a6 solid; background:#f9f9f9; text-align:left; border-collapse:collapse;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Package installation and removal&lt;br /&gt;
|-&lt;br /&gt;
|[[#Add a Package|add]]  || Add or modify constraints in [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Remove a Package|del]] || Remove constraints from [[#World|WORLD]] and commit changes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |System maintenance&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk fix|fix ]]    || Fix, reinstall or upgrade packages without modifying [[#World|WORLD]]&lt;br /&gt;
|-&lt;br /&gt;
|[[#Update Package list|update]]|| Update repository indexes&lt;br /&gt;
|-&lt;br /&gt;
|[[#Upgrade a Running System|upgrade]]|| Install upgrades available from repositories&lt;br /&gt;
|-&lt;br /&gt;
|[[#Local Cache|cache]]  || Manage the local package cache&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Querying package information&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk query|query]]   || Query information about packages by various criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#Listing installed packages|list]] || List packages matching a pattern or other criteria&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk dot|dot]]   || Render dependencies as [https://graphviz.org/ graphviz] graphs&lt;br /&gt;
|-&lt;br /&gt;
|[[#apk policy|policy]]|| Show repository policy for packages&lt;br /&gt;
|-&lt;br /&gt;
|[[#Search for Packages|search]]  || Search for packages by name or description&lt;br /&gt;
|-&lt;br /&gt;
|[[#Information on Packages|info]]  || Give detailed information about packages or repositories&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Repository and package maintenance&lt;br /&gt;
|-&lt;br /&gt;
|mkndx    || Create repository index (v3) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|mkpkg  || Create package (v3)&lt;br /&gt;
|-&lt;br /&gt;
|index   || Create repository index (v2) file from packages&lt;br /&gt;
|-&lt;br /&gt;
|fetch  || Download packages from repositories to a local directory&lt;br /&gt;
|-&lt;br /&gt;
|manifest|| Show checksums of package contents&lt;br /&gt;
|-&lt;br /&gt;
|extract || Extract package file contents&lt;br /&gt;
|-&lt;br /&gt;
|verify   || Verify package integrity and signature&lt;br /&gt;
|-&lt;br /&gt;
|adbsign || Sign, resign or recompress v3 packages and indexes&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;background:black; color:white&amp;quot;  colspan=2 align=center |Miscellaneous&lt;br /&gt;
|-&lt;br /&gt;
|audit|| Audit system for changes&lt;br /&gt;
|-&lt;br /&gt;
|stats  || Show statistics about repositories and installations&lt;br /&gt;
|-&lt;br /&gt;
|version|| Compare package versions or perform tests on version strings&lt;br /&gt;
|-&lt;br /&gt;
|adbdump|| Dump v3 files in textual representation&lt;br /&gt;
|-&lt;br /&gt;
|adbgen  || Generate v3 files from text representation&lt;br /&gt;
|-&lt;br /&gt;
|convdb  || Convert v2 installed database to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|convndx || Convert v2 indexes to v3 format&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packages and Repositories  ==&lt;br /&gt;
{{Main|Repositories}}&lt;br /&gt;
Official software packages for Alpine Linux have the extension &amp;lt;code&amp;gt;.apk&amp;lt;/code&amp;gt;, and are often called &amp;quot;a-packs&amp;quot;. Packages in Alpine Linux are organized into [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] and are defined in the {{Path|/etc/apk/repositories}} file. [[Apk spec#Package Format V2|apk v2]] packages are digitally signed tar.gz archives containing programs, configuration files, and dependency metadata. &lt;br /&gt;
&lt;br /&gt;
=== Subpackages ===&lt;br /&gt;
&lt;br /&gt;
In Alpine Linux, software packages are thinned out and split into subpackages to give more control over what features are installed and keeps the installation as small and efficient as possible. &lt;br /&gt;
&lt;br /&gt;
Subpackages related to service files, documentation and shell completions are installed automatically by the package manager using &#039;&#039;&#039;auto-install&#039;&#039;&#039; rule based on [[APKBUILD_Reference#install_if|install_if]] directive. For example, if {{pkg|zsh}} is already installed, on installing any package with {{pkg|*zsh-completion*}} subpackage, apk automatically installs the associated subpackage. The {{pkg|docs}} meta package for pulling in [[Alpine_Linux:FAQ#Why_don&#039;t_I_have_man_pages_or_where_is_the_&#039;man&#039;_command?|all documentation]] works the same way.&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://pkgs.alpinelinux.org package database] page shows the list of available subpackages for any package.&lt;br /&gt;
&lt;br /&gt;
== World ==&lt;br /&gt;
&lt;br /&gt;
At {{Path|/etc/apk/world}}, apk maintains the world, that is, a list of constraints the package selection needs to fulfill. World describes the desired system state. {{Path|/etc/apk/world}} is a plaintext file with one constraint using dependency notation per line. Each line has the format:&amp;lt;br&amp;gt; &lt;br /&gt;
&amp;lt;code&amp;gt;[!]NAME{@tag}{[&amp;lt;&amp;gt;~=]version}&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
There can be only one line with a given package NAME in the file and except the package NAME, all the other options are optional.&lt;br /&gt;
&lt;br /&gt;
*  &#039;&#039;&#039;!&#039;&#039;&#039; is used for [[#Masking a specific package|masking a specific package]] &lt;br /&gt;
*  &#039;&#039;&#039;@tag&#039;&#039;&#039; allows apk to use the [[Repositories#Tagged_repository|tagged repository]] for the named package &lt;br /&gt;
*  &#039;&#039;&#039;[&amp;lt;&amp;gt;~=]version&#039;&#039;&#039; are used for [[#Package pinning|package pinning]].&lt;br /&gt;
&lt;br /&gt;
The commands {{ic|apk add foo}} and {{ic|apk del bar}} manipulate the desired state by adding or removing packages &amp;lt;code&amp;gt;foo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; respectively as a dependency constraint in {{Path|/etc/apk/world}}. If the {{Path|/etc/apk/world}} is edited manually, run the command [[#apk fix|apk fix]] to apply the changes. &lt;br /&gt;
&lt;br /&gt;
Every constraint listed in {{Path|/etc/apk/world}} must be solvable in order for the system to be considered correct, and no transaction may be committed that is incorrect. If apk cannot verify the correctness of the requested change, it will back out adding the constraint before attempting to change what packages are actually installed on the system. Thus apk will never [[#ERROR:_unsatisfiable_constraints|commit]] a change to the system that leaves it unbootable. &lt;br /&gt;
&lt;br /&gt;
{{Warning| The option {{ic|force-broken-world}}, will delete world constraints until a solution without conflicts is found to boot. This does not allow installation of packages with unjustifiable dependencies. Using this will likely result in unexpected removal of some packages.}}&lt;br /&gt;
&lt;br /&gt;
== Update Package list ==&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [[Repositories|&#039;&#039;&#039;repositories&#039;&#039;&#039;]] change as packages are added and upgraded. To get the latest list of available packages, use the &#039;&#039;update&#039;&#039; command.  This command downloads the {{Path|APKINDEX.tar.gz}} from each repository and stores it in the local cache, typically {{Path|/var/cache/apk/}}, {{Path|/var/lib/apk/}} or {{Path|/etc/apk/cache/}}. {{Cmd|# apk update}}&lt;br /&gt;
&lt;br /&gt;
Adding the &amp;lt;code&amp;gt;--update-cache&amp;lt;/code&amp;gt;, or for short &amp;lt;code&amp;gt;-U&amp;lt;/code&amp;gt; switch to another apk command, as in &amp;lt;code&amp;gt;apk --update-cache upgrade&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;apk -U add ...&amp;lt;/code&amp;gt;, the command has the same effect as first running &amp;lt;code&amp;gt;apk update&amp;lt;/code&amp;gt; before the other apk command.&lt;br /&gt;
&lt;br /&gt;
It is a good idea to always do an &#039;&#039;&#039;update&#039;&#039;&#039; right &#039;&#039;&#039;before&#039;&#039;&#039; doing an &#039;&#039;&#039;upgrade or add&#039;&#039;&#039; command. That way the command will install the latest available packages from the repositories.&lt;br /&gt;
&lt;br /&gt;
== Add a Package ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;add&#039;&#039;&#039; to install packages from a [[Repositories|&#039;&#039;&#039;repository&#039;&#039;&#039;]]. Any necessary dependencies are also installed. If you have multiple repositories, the &#039;&#039;&#039;add&#039;&#039;&#039; command installs the newest package. {{Cmd|&amp;lt;nowiki&amp;gt;# apk add openssh&lt;br /&gt;
# apk add openssh openntp vim &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Packages from a [[Repositories#Tagged repository|tagged repository]] can be installed by adding tags to them:{{cmd|# apk add wireguard-go@testing}}&lt;br /&gt;
&lt;br /&gt;
A specific package can also be [[#Package pinning|held back or pinned]] at a specific level or version. &lt;br /&gt;
&lt;br /&gt;
=== Add a local Package ===&lt;br /&gt;
&lt;br /&gt;
To install a locally available apk package, for example if this device has no internet access but you can upload apk packages directly to it, use the &#039;&#039;&#039;--allow-untrusted&#039;&#039;&#039; flag: {{cmd|# apk add --allow-untrusted /path/to/file.apk}}&lt;br /&gt;
&lt;br /&gt;
Note that multiple packages can be given.  When installing a local package, all dependencies should also be specified. For example:&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add --allow-untrusted /var/tig-2.2-r0.apk /var/git-2.11.1-20.apk}}&lt;br /&gt;
&lt;br /&gt;
When a non-repository package is added, a version constraint is added with the package identity hash in the World file. If {{ic|&#039;&#039;&#039;--available&#039;&#039;&#039;}} option is used with [[#Upgrade a Running System|apk upgrade]] command, such local packages are upgraded or downgraded back to a repository version.&lt;br /&gt;
&lt;br /&gt;
== Remove a Package  ==&lt;br /&gt;
&lt;br /&gt;
Use &#039;&#039;&#039;del&#039;&#039;&#039; to remove a package along with dependencies that are no longer needed.{{cmd|&amp;lt;nowiki&amp;gt;# apk del openssh&lt;br /&gt;
# apk del openssh openntp vim&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Upgrade a Running System ==&lt;br /&gt;
{{Seealso|Upgrading Alpine Linux to a new release branch}}&lt;br /&gt;
To get the latest security upgrades and bugfixes available for all the installed packages from the [[Repositories#Release_Branches|current release branch]] of a running system, always [[#Update Package list| update the packages list]] before issuing the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command as shown below:{{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Or, combining the same into one single command:{{cmd|# apk -U upgrade}}&lt;br /&gt;
&lt;br /&gt;
To upgrade only &#039;&#039;specific&#039;&#039; packages, use the &#039;&#039;&#039;upgrade&#039;&#039;&#039; command and specify them: {{cmd|&amp;lt;nowiki&amp;gt;# apk update&lt;br /&gt;
# apk upgrade busybox&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the package manager may create &amp;lt;var&amp;gt;apk-new&amp;lt;/var&amp;gt; files to avoid overwriting configuration files. Once the packages are updated, remember to [[#Handling apk-new files|handle such &amp;lt;var&amp;gt;apk-new&amp;lt;var&amp;gt;]] files.&lt;br /&gt;
&lt;br /&gt;
Here is an example, showing the procedure on a system that has [[Repositories#Using testing repository|testing repository tagged]]:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
 # apk update&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 fetch &amp;lt;nowiki&amp;gt;https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-191-gf98d79930f &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/main]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.2-190-ga5d68c47df &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/v3.6/community]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 v3.6.0-4624-g11f1b9c8ab &amp;lt;nowiki&amp;gt;[https://dl-3.alpinelinux.org/alpine/edge/testing]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 OK: 20118 distinct packages available&lt;br /&gt;
 &lt;br /&gt;
 # apk upgrade&lt;br /&gt;
 (1/2) Upgrading extra-cmake-modules@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 (2/2) Upgrading extra-cmake-modules-doc@testing (5.38.0-r0 -&amp;gt; 5.39.0-r0)&lt;br /&gt;
 Executing mdocml-apropos-1.14.1-r0.trigger&lt;br /&gt;
 OK: 2635 MiB in 803 packages&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs ===&lt;br /&gt;
&lt;br /&gt;
When upgrading packages, the kernel and firmware packages are &#039;&#039;&#039;not&#039;&#039;&#039; upgraded. Upgrading them requires [[Diskless Mode#update-kernel script|&#039;&#039;&#039;update-kernel&#039;&#039;&#039;]] script.&lt;br /&gt;
&lt;br /&gt;
=== Handling apk-new files ===&lt;br /&gt;
&lt;br /&gt;
apk avoids overwriting configuration files in the {{path|/etc}} directory. Whenever apk installs a file there, but realizes a potentially edited one is already present, it will write its file to that filename with {{path|.apk-new}} appended. When upgrading, you see a message like below: {{Cmd|# apk upgrade &lt;br /&gt;
(1/2) Upgrading openrc-user-pam (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
(2/2) Upgrading openrc (0.62.2-r2 -&amp;gt; 0.62.2-r3)&lt;br /&gt;
openrc-0.62.2-r3: installing file to etc/rc.conf.apk-new&lt;br /&gt;
openrc-0.62.2-r3.post-upgrade: Executing script}} &lt;br /&gt;
&lt;br /&gt;
You may handle these by hand, or use the [[Alpine configuration management scripts#update-conf|update-conf]] utility:- &lt;br /&gt;
&lt;br /&gt;
* To list files where changes to configurations from the new packages exist: {{Cmd|# update-conf -l}}&lt;br /&gt;
:Paths appear to locations, possibly using double-slash (&#039;&#039;&amp;quot;//&amp;quot;&#039;&#039;) unix notation, where both the old file and the new file with the {{Path|.apk-new}} extension exist.&lt;br /&gt;
* Simply invoking {{ic|update-conf}} will present you with the difference between the two files and offer various choices for dealing with the conflicts.{{Cmd|# update-conf}}&lt;br /&gt;
:&#039;&#039;&#039;Be very careful&#039;&#039;&#039; not to choose &#039;&#039;&amp;quot;u&amp;quot;&#039;&#039; to &#039;&#039;use&#039;&#039; the new file versions for files such as {{Path|passwd}}, {{Path|doas.conf}}, {{Path|shadow}}, {{Path|hosts}}, etc., because otherwise the existing password hashes, user doas settings, etc. &#039;&#039;&#039;&#039;&#039;would be wiped, and lockouts would occur!&#039;&#039;&#039;&#039;&#039; Instead, one could choose to compare the new lines (shown with a &#039;&#039;&amp;quot;+&amp;quot;&#039;&#039;) with the lines that would be removed (&#039;&#039;&amp;quot;-&amp;quot;&#039;&#039;) and edit (&#039;&#039;&amp;quot;e&amp;quot;&#039;&#039;) the files if so wished, or zap (&#039;&#039;&amp;quot;z&amp;quot;&#039;&#039;) the new version – i.e. delete the new version – if no essential changes are required. &lt;br /&gt;
:Therefore, &#039;&#039;&#039;update-conf&#039;&#039;&#039; does not currently have a merge function set up by default to preserve essential data unlike, say, Debian&#039;s &#039;&#039;&#039;update-passwd&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Editors - there is a need to elaborate on update-conf merge rules functionality that is reportedly available;  this could be elaborated under Alpine_configuration_management_scripts#update-conf --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Autoupdate tool for apk ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux [https://github.com/jirutka/apk-autoupdate tool for automatic updates] is available as {{pkg|apk-autoupdate}} package. It can be used with [[Cron]] to enable unattended, automatic upgrades of packages.&lt;br /&gt;
&lt;br /&gt;
== Package management in Diskless mode ==&lt;br /&gt;
&lt;br /&gt;
Besides using [[#Local Cache|Local Cache]], all package management tasks in [[Diskless Mode|diskless]] and [[Data Disk Mode|Data disk]] mode systems like adding, removing and [[#Upgrading &amp;quot;diskless&amp;quot; and &amp;quot;data&amp;quot; disk mode installs|upgrading]] packages requires running the command: {{Cmd|&#039;&#039;&#039;# [[Alpine_local_backup#Committing changes|lbu commit]]&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
Only when the above command is run, the changes will take effect on next reboot.&lt;br /&gt;
&lt;br /&gt;
== apk query ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
The query applet is a superset of [[#Information on Packages|info]], [[#Listing installed packages|list]] and [[#Search for Packages|search]] commands to interrogate the installed database and indexes for information related to packages. The command outputs human readable format in addition to json and yaml output.&lt;br /&gt;
&lt;br /&gt;
== Search for Packages ==&lt;br /&gt;
&lt;br /&gt;
{{Tip|Alpine Linux provides a specialized [https://pkgs.alpinelinux.org web interface] dedicated to looking through various available packages.}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;search&#039;&#039;&#039; command searches the repository Index files for installable packages. &lt;br /&gt;
&lt;br /&gt;
The return format is &#039;&#039;&#039;Package&#039;&#039;&#039;-&#039;&#039;&#039;Version&#039;&#039;&#039;. Omit &#039;&#039;&#039;Version&#039;&#039;&#039; for &#039;&#039;apk add &#039;&#039;&#039;Package&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* To list all packages available, along with their descriptions: {{cmd|$ apk search -v}}&lt;br /&gt;
* To list all packages are part of the ACF system: {{cmd|$ apk search -v &#039;acf*&#039; }}&lt;br /&gt;
* To list all packages that list NTP as part of their description, use the &#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039; option: {{cmd|$ apk search -v --description &#039;NTP&#039; }}&lt;br /&gt;
* To list all packages that provide the &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; command: {{cmd|$ apk search -v &#039;cmd:git&#039;}}&lt;br /&gt;
&lt;br /&gt;
== Information on Packages ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command provides information on the contents of packages, their dependencies, and which files belong to a package.&lt;br /&gt;
&lt;br /&gt;
For a given package, each element can be chosen (for example, &#039;&#039;-w&#039;&#039; to show just the webpage information), or all information displayed with the &#039;&#039;-a&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
Example: {{cmd|$ apk info -a zlib}}&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 description:&#039;&#039;&#039;&lt;br /&gt;
 A compression/decompression Library&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 webpage:&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;https://zlib.net&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 installed size:&#039;&#039;&#039;&lt;br /&gt;
 94208&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 depends on:&#039;&#039;&#039;&lt;br /&gt;
 libc0.9.32&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 is required by:&#039;&#039;&#039;&lt;br /&gt;
 libcrypto1.0-1.0.0-r0&lt;br /&gt;
 apk-tools-2.0.2-r4&lt;br /&gt;
 openssh-client-5.4_p1-r2&lt;br /&gt;
 openssh-5.4_p1-r2&lt;br /&gt;
 libssl1.0-1.0.0-r0&lt;br /&gt;
 freeswitch-1.0.6-r6&lt;br /&gt;
 atop-1.25-r0 &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 contains:&#039;&#039;&#039;&lt;br /&gt;
 lib/libz.so.1.2.5&lt;br /&gt;
 lib/libz.so.1&lt;br /&gt;
 lib/libz.so &lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;zlib-1.2.5-r1 triggers:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As shown in the example you can determine&lt;br /&gt;
* The &#039;&#039;&#039;description&#039;&#039;&#039; of the package (&#039;&#039;-d&#039;&#039; or &#039;&#039;--description&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;webpage&#039;&#039;&#039; where the application is hosted (&#039;&#039;-w&#039;&#039; or &#039;&#039;--webpage&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;size&#039;&#039;&#039; the package will require once installed (in bytes) (&#039;&#039;-s&#039;&#039; or &#039;&#039;--size&#039;&#039;)&lt;br /&gt;
* What packages are required to use this one  (&#039;&#039;&#039;depends&#039;&#039;&#039;) (&#039;&#039;-R&#039;&#039; or &#039;&#039;--depends&#039;&#039;)&lt;br /&gt;
* What packages require this one to be installed (&#039;&#039;&#039;required by&#039;&#039;&#039;) (&#039;&#039;-r&#039;&#039; or &#039;&#039;--rdepends&#039;&#039;)&lt;br /&gt;
* The &#039;&#039;&#039;contents&#039;&#039;&#039; of the package, that is, which files it installs (&#039;&#039;-L&#039;&#039; or &#039;&#039;--contents&#039;&#039;)&lt;br /&gt;
* Any &#039;&#039;&#039;triggers&#039;&#039;&#039; this package sets. (&#039;&#039;-t&#039;&#039; or &#039;&#039;--triggers&#039;&#039;) Listed here are directories that are watched; if a change happens to the directory, then the trigger script is run at the end of the apk add/delete. For example, doing a depmod once after installing all packages that add kernel modules.&lt;br /&gt;
&lt;br /&gt;
===  Check file ownership ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command is also useful to determine which package a file belongs to.  For example: {{cmd|$ apk info --who-owns /sbin/lbu}} &lt;br /&gt;
will display&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/sbin/lbu is owned by alpine-conf-x.x-rx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===  Check Dependencies ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;info&#039;&#039;&#039; command specific to check package dependency and reverse dependency is explained below:&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-R&#039;&#039;&#039; or &#039;&#039;&#039;--depends&#039;&#039;&#039; lists the dependencies of the package: {{Cmd|$ apk info --depends pipewire}} &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 depends on:&lt;br /&gt;
/bin/sh&lt;br /&gt;
so:libc.musl-x86_64.so.1&lt;br /&gt;
so:libpipewire-0.3.so.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The option &#039;&#039;&#039;-r&#039;&#039;&#039; or  &#039;&#039;&#039;--rdepends&#039;&#039;&#039; lists the  reverse dependencies of the package (all other packages which depend on the package). {{Cmd|$ apk info --rdepends pipewire}}  &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pipewire-1.0.6-r1 is required by:&lt;br /&gt;
xdg-desktop-portal-wlr-0.7.1-r0&lt;br /&gt;
pipewire-pulse-1.0.6-r1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Listing installed packages ===&lt;br /&gt;
&lt;br /&gt;
To list all installed packages, use: {{Cmd|$ apk info}}&lt;br /&gt;
&lt;br /&gt;
To list all installed packages in alphabetical order, with a description of each, do:{{Cmd|$ apk -vv info|sort}}&lt;br /&gt;
&lt;br /&gt;
To list packages locally installed that are not longer available in repositories, use {{Cmd|$ apk list --orphaned}}&lt;br /&gt;
&lt;br /&gt;
To browse details of installed package in a &amp;quot;TUI&amp;quot; with:{{Cmd|&amp;lt;nowiki&amp;gt;$ apk list --installed -q | fzf --preview &#039;apk query {1}&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To list subpackages for a package, for e.g {{pkg|util-linux}}:{{Cmd|$ apk list --quiet --origin util-linux}}&lt;br /&gt;
&lt;br /&gt;
The apk tool does not have a subcommand to list manually-installed packages that do not have reverse dependencies. To get this information on a traditional system that is not using [[Alpine local backup|lbu]], try this script. Note that this approach will also list core packages like alpine-base that should not be removed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
apk info | grep -ve &#039;-doc$&#039; | sort | while read pkg&lt;br /&gt;
        do&lt;br /&gt;
                rdep=`apk info -qr &amp;quot;$pkg&amp;quot;`&lt;br /&gt;
                [ -z &amp;quot;$rdep&amp;quot; ] &amp;amp;&amp;amp; echo $pkg&lt;br /&gt;
        done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Local Cache ==&lt;br /&gt;
{{Seealso|Local APK cache}}&lt;br /&gt;
APK can keep a cache of installed packages on a local disk. HDD or [[Installation#System_Disk_Mode|sys mode]] installs don&#039;t need an apk cache, it still allows to serve packages over the network, though, e.g. to get installed by other local machines.&lt;br /&gt;
&lt;br /&gt;
{{Note|For [[Diskless Mode|diskless]] installations, [[Local APK cache|local package cache]] is needed to automatically (re-)install packages when booting.}} &lt;br /&gt;
&lt;br /&gt;
When newer packages are added to the cache over time, the older versions of the packages default to remain in the cache directory.  The older versions of packages can be removed with the &#039;&#039;&#039;clean&#039;&#039;&#039; command.  {{cmd|# apk cache clean}} Or to see what is deleted include the verbose switch: {{cmd|# apk -v cache clean}}&lt;br /&gt;
&lt;br /&gt;
If packages got deleted accidentally from the cache directory, then use the &#039;&#039;&#039;download&#039;&#039;&#039; command, {{cmd|# apk cache download}}&lt;br /&gt;
&lt;br /&gt;
The above two steps can be combined  into one with the &#039;&#039;&#039;sync&#039;&#039;&#039; command - this cleans out old packages and downloads missing packages. {{cmd|# apk cache -v sync}}&lt;br /&gt;
&lt;br /&gt;
== apk dot ==&lt;br /&gt;
&lt;br /&gt;
The dot option renders package dependencies as {{pkg|graphviz}} graphs.[[File:Seatd dependencies.png|800px|center|alt=Seatd dependencies|Seatd dependencies]] Steps to use the dot option is documented below:&lt;br /&gt;
# Save the output of apk dot option to a dot file.{{Cmd|$ apk dot seatd &amp;gt; seatd_dependencies.dot}}&lt;br /&gt;
# Use &amp;lt;code&amp;gt;dot&amp;lt;/code&amp;gt; utility from {{pkg|graphviz}} package to convert the {{Path|seatd_dependencies.dot}} file into a graphical format such as PNG, PDF, or SVG. {{Cmd|$ dot -Tpng seatd_dependencies.dot -o seatd_dependencies.png}}&lt;br /&gt;
&lt;br /&gt;
== apk fix ==&lt;br /&gt;
&lt;br /&gt;
If a package is specified, the &#039;&#039;&#039;fix&#039;&#039;&#039; subcommand applies repair strategies to correct errors in the installation of the specified packages. If no packages are specified, this command synchronizes all the installed packages with the [[#World|desired system state]].&lt;br /&gt;
&lt;br /&gt;
== apk policy ==&lt;br /&gt;
&lt;br /&gt;
To display the repository a package was installed from and will be updated from, plus any [[#Repository_pinning|tagged]] or enabled repositories where it is also offered, if any, for this architecture - its &#039;&#039;&#039;policy&#039;&#039;&#039;: {{Cmd|$ apk policy &#039;&#039;package&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $ apk policy vlc&lt;br /&gt;
 vlc policy:&lt;br /&gt;
  2.2.6-r1:&lt;br /&gt;
    lib/apk/db/installed&lt;br /&gt;
    https://dl-3.alpinelinux.org/alpine/v3.7/community&lt;br /&gt;
  3.0.0_rc2-r1:&lt;br /&gt;
    @edgecommunity https://dl-3.alpinelinux.org/alpine/edge/community&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuration file ==&lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
Support for config file for setting  default global options has been enabled. The user defined config file {{path|/etc/config/apk}}, if present overrides the {{path|/lib/apk/config}}, intended for distribution default options. To override the default config file name, the environment variable {{ic|APK_CONFIG}} can be used.&lt;br /&gt;
&lt;br /&gt;
The configuration file contains one long option per line as shown here for reference:{{Cat|/etc/config/apk|no-cache &lt;br /&gt;
timeout 120}}&lt;br /&gt;
&lt;br /&gt;
The following aliases are available: {{ic|cache}} equals {{ic|cache yes}} and {{ic|no-cache}} equals {{ic|cache no}}.&lt;br /&gt;
&lt;br /&gt;
== Transaction logs == &lt;br /&gt;
{{Pill_clickable||v3 only|green|palegreen|right|Alpine Package Keeper#apk_v3}}&lt;br /&gt;
All apk commands which modify the database i.e write transactions are logged to {{Path|/var/log/apk.log}}. To disable the writing of the log file, the configuration option {{ic|logfile}} in the [[#Configuration file|configuration file]] must be set as follows:{{Cat|/etc/config/apk|logfile no}}&lt;br /&gt;
&lt;br /&gt;
== Advanced APK Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Commandline repository options ===&lt;br /&gt;
&lt;br /&gt;
By default, the &#039;&#039;&#039;apk&#039;&#039;&#039; utility will use the system repositories for all operations. This behavior can be overridden by the following options:&lt;br /&gt;
{|&lt;br /&gt;
| --repositories-file REPOFILE&lt;br /&gt;
| Override the system repositories by specifying a repositories file.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;nowiki&amp;gt;-X|--repository REPO&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
| Specify a supplemental repository that will be used in addition to the system repositories. This option can be provided multiple times.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{cmd|# apk add cherokee --update-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
=== apk Command Line Parsing ===&lt;br /&gt;
&lt;br /&gt;
==== Use of Single Quotes ====&lt;br /&gt;
Advanced use of &#039;&#039;&#039;apk&#039;&#039;&#039; could require the use of single quotes around its argument (e.g. {{ic|apk &amp;lt;var&amp;gt;add&amp;lt;/var&amp;gt; &#039;&amp;lt;var&amp;gt;argument&amp;lt;/var&amp;gt;&#039;}}) when certain characters are being employed, since Unix shells – including the default &#039;&#039;&#039;sh&#039;&#039;&#039; (&#039;&#039;&#039;ash&#039;&#039;&#039;/&#039;&#039;&#039;busybox&#039;&#039;&#039;) shell, &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039;/&#039;&#039;&#039;fish&#039;&#039;&#039; – will attempt to interpret the argument if it is not enveloped in single quotes:-&lt;br /&gt;
* {{ic|&amp;lt;}} in an argument would be unintendedly interpreted as &amp;quot;input redirection&amp;quot;; {{ic|asterisk&amp;lt;1.6.1}} without quotes would prompt the shell to attempt to read from an {{Path|asterisk}} file;   similarly, {{ic|&amp;gt;}} would be interpreted unintendedly as &amp;quot;output redirection&amp;quot;&lt;br /&gt;
* {{ic|~}} would attempt to expand the argument to include the user’s home directory path&lt;br /&gt;
* {{ic|*}}, {{ic|?}}, {{ic|[0-9]}} without single quotes around the argument could cause globbing, meaning that the shell would try to expand the package name using the meaning of those characters ({{ic|*}} meaning any string of alphanumeric characters, for example) and then try to apply &#039;&#039;&#039;apk&#039;&#039;&#039; to any &#039;&#039;file&#039;&#039; fitting that name in the current working directory as an unintended interpretation&lt;br /&gt;
* {{ic|!}} in a &#039;&#039;&#039;bash&#039;&#039;&#039; or &#039;&#039;&#039;zsh&#039;&#039;&#039; shell without using quotes would be interpreted as &amp;quot;history expansion&amp;quot; as opposed to [[#Package_masking|&amp;quot;negate installation&amp;quot;]], as intended.   Note that, if using &#039;&#039;&#039;ash&#039;&#039;&#039; (Alpine Linux’s default), the lack of single quotes is not problematic there as that shell does not support history expansion.  History expansion is &#039;&#039;disabled by default&#039;&#039; in &#039;&#039;&#039;fish&#039;&#039;&#039;.&lt;br /&gt;
Therefore, the use of single quotes is typically required in various shells to enclose the package name/version, with or with any &#039;!&#039; symbol, to be handed directly to the &#039;&#039;&#039;apk&#039;&#039;&#039; tool so that it is not attempted to be interpreted by the shell.&lt;br /&gt;
&lt;br /&gt;
=== Package pinning ===&lt;br /&gt;
{{Seealso|Repositories#Tagged repository}}&lt;br /&gt;
&lt;br /&gt;
In certain cases, you may want to upgrade a system, but keep a specific package at a specific level or version by pinning a Package. It is possible to add &amp;quot;sticky&amp;quot; or versioned dependencies. &lt;br /&gt;
&lt;br /&gt;
{{Warning| If you desire deterministic, repeatable package installation (such as with containerized environments) via package pinning, it is important to understand your package repo&#039;s version retention rules. Always pin to a package version that is intended for your [[Repositories#Release_Branches|release branch]]. Pinning to a version on the [[Repositories#Edge|edge]] branch may stop working after the package version is revoked from the repo.}}&lt;br /&gt;
&lt;br /&gt;
For instance, to hold the &#039;&#039;asterisk&#039;&#039; package to the 1.6.2 level or lower:{{cmd|&amp;lt;nowiki&amp;gt;# apk add asterisk=1.6.0.21-r0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
or – note the need for [[#Use_of_Single_Quotes|single quotes]]:{{cmd|# apk add &#039;asterisk&amp;lt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
To upgrade the entire system, keeping the asterisk package at the 1.6.0 or lower level:{{cmd|# apk upgrade}}&lt;br /&gt;
&lt;br /&gt;
To later upgrade to the current version, and ensure that 1.6.1 is the minimum version used. {{cmd|# apk add &#039;asterisk&amp;gt;1.6.1&#039;}}&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;fuzzy&amp;quot; version matching to pin the version to a major/minor release. To match any version of asterisk that starts with 1.6 (such as 1.6.0.21-r0 or 1.6.9.31-r9) use the command: {{cmd|&amp;lt;nowiki&amp;gt;# apk add &#039;asterisk=~1.6&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Holding a specific package back ====&lt;br /&gt;
See [[#Package pinning|Package pinning]]&lt;br /&gt;
&lt;br /&gt;
=== Package masking ===&lt;br /&gt;
&lt;br /&gt;
In case a package is pulled in yet is superfluous or unwanted, or if it were to be installed and conflict with another, one could &#039;&#039;mask&#039;&#039; it i.e. &#039;&#039;exclude it&#039;&#039; from being installed unless &#039;&#039;&#039;apk&#039;&#039;&#039; is later instructed &#039;&#039;explicitly&#039;&#039; to add it.  To mask/exclude an unwanted package hypothetically called &#039;&#039;foo&#039;&#039;:&lt;br /&gt;
{{Cmd|# apk add &#039;!foo&#039;}}&lt;br /&gt;
Beforehand, ensure that the &#039;&#039;&#039;&#039;&#039;package is not installed&#039;&#039;&#039;&#039;&#039;.  If so, &#039;&#039;uninstall it first&#039;&#039;, as otherwise, it would become an &#039;&#039;&amp;quot;orphaned package&amp;quot;&#039;&#039;:  installed, yet not being managed by the &#039;&#039;&#039;apk&#039;&#039;&#039; package keeper, which could cause an obfuscated problem(s) if it or its dependencies linger and later conflict with another package;  it could be harder to trace the issue(s) then.&lt;br /&gt;
&lt;br /&gt;
The exclamation mark (!) is often used in logic and IT to express negation.&lt;br /&gt;
&lt;br /&gt;
As [[#Use_of_Single_Quotes|detailed above]], be sure to employ the single quotes (&#039;) if using certain shells &#039;&#039;other than&#039;&#039; the unaffected &#039;&#039;&#039;ash&#039;&#039;&#039; shell so as to avoid an unintended interpretation by the shell interpreter.&lt;br /&gt;
&lt;br /&gt;
The package then appears negated in &#039;&#039;world&#039;&#039;:&lt;br /&gt;
{{Cat|/etc/apk/world|fon&lt;br /&gt;
!foo&lt;br /&gt;
fop}}&lt;br /&gt;
&lt;br /&gt;
==== Unmasking a specific package ====&lt;br /&gt;
&lt;br /&gt;
Simply install it &#039;&#039;explicitly&#039;&#039; using &#039;&#039;&#039;apk&#039;&#039;&#039;.  Say:&lt;br /&gt;
{{Cmd|# apk add foo}}&lt;br /&gt;
Uninstall it afterwards, if not required.&amp;lt;/br&amp;gt;&lt;br /&gt;
Alternatively, delete the line in {{Path|/etc/apk/world}} where the package is negated.  Be sure not to leave any spurious character.&lt;br /&gt;
&lt;br /&gt;
=== Commit hooks ===&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like to trigger an action or run a certain script on every commit made by apk, there&#039;s a built-in method for that. On every commit apk looks for executables located in the &amp;quot;/etc/apk/commit_hooks.d/&amp;quot; directory, and executes them both before and after the commit. To provide some way to selectively run hooks either before or after a change is commited by apk, the scripts are called with &amp;quot;pre-commit&amp;quot; or &amp;quot;post-commit&amp;quot; as argument 1.&lt;br /&gt;
This is an example of a hook to do different things before and after commit:&lt;br /&gt;
&lt;br /&gt;
{{cmd|1=#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;pre-commit&amp;quot; ]; then&lt;br /&gt;
    do_something&lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$1&amp;quot; = &amp;quot;post-commit&amp;quot; ]; then&lt;br /&gt;
    do_something_else&lt;br /&gt;
fi}}&lt;br /&gt;
&lt;br /&gt;
Commit hooks are $PATH-aware, so for the sake of security it&#039;s recommended to specify absolute paths to executables.&lt;br /&gt;
&lt;br /&gt;
==  Rosetta Stone ==&lt;br /&gt;
	&lt;br /&gt;
[[Comparison with other distros#Comparison chart/Rosetta Stone|Rosetta Stone]] or a Comparison chart shows how standard things related to package management are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages ===&lt;br /&gt;
&lt;br /&gt;
This error typically indicates that the package manager cannot find a suitable package to install. On issuing a command to add a package for eg: {{ic|# apk add labwc}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
 labwc (no such package):&lt;br /&gt;
 required by: world[labwc]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error indicates {{pkg|labwc}} does not exist in the [[Repositories|repositories]] currently configured in {{Path|/etc/apk/repositories}}. Ensure that &amp;lt;code&amp;gt;community&amp;lt;/code&amp;gt; repository is [[Repositories#Managing_repositories|enabled]], as by default only &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; repository is enabled. You may also want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and the [[Repositories|repository]] in which the package is available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  so:libxml2.so.2 (no such package):&lt;br /&gt;
    required by: llvm19-libs-19.1.7-r1[so:libxml2.so.2]&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above error message may occur in [[Edge|Edge]] branch in certain other situations, even if all the necessary [[Repositories|repositories]] are enabled. Temporary non-availability of the packages from the repositories can occur, when software packages are [https://build.alpinelinux.org/ rebuilt]. You may want to wait for some time to try again.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unsatisfiable constraints === &lt;br /&gt;
&lt;br /&gt;
This error signifies a dependency conflict. It means that the package you&#039;re trying to install has dependencies that cannot be simultaneously satisfied within the current package repository. &lt;br /&gt;
&lt;br /&gt;
You may want to check [https://pkgs.alpinelinux.org/packages packages database] to identify the correct package name and version and the [[Repositories|repository]] in which the package is available. &lt;br /&gt;
&lt;br /&gt;
=== WARNING: This apk-tools is OLD! ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;apk update&#039;&#039;&#039;, &#039;&#039;&#039;apk upgrade&#039;&#039;&#039; or &#039;&#039;&#039;apk add&#039;&#039;&#039; may report the following: &lt;br /&gt;
 WARNING: This apk-tools is OLD! Some packages might not function properly&lt;br /&gt;
&lt;br /&gt;
This may happen if you are running Alpine Linux stable version with a [[Repositories#Edge|Edge]] package(s) also installed.  One resolution is to consider upgrading {{pkg|apk-tools}}. If edge/main is already [[Repositories#Tagged repository|tagged]] as &#039;&#039;@edgemain&#039;&#039; in your {{Path|/etc/apk/repositories}} file, then try: {{Cmd|# apk add --upgrade apk-tools@edgemain}}&lt;br /&gt;
&lt;br /&gt;
=== ERROR:  UNTRUSTED signature ===&lt;br /&gt;
&lt;br /&gt;
This happens when the release version changes. You need to update the local apk keys.&lt;br /&gt;
&lt;br /&gt;
If you have already updated your repositories, allow them to update without the trusted key:&lt;br /&gt;
{{Cmd|# apk update --allow-untrusted}}&lt;br /&gt;
&lt;br /&gt;
Then install the keys upgrade:&lt;br /&gt;
{{Cmd|# apk fix --upgrade --allow-untrusted alpine-keys}}&lt;br /&gt;
&lt;br /&gt;
Now updates and upgrades should proceed normally.&lt;br /&gt;
&lt;br /&gt;
Alternative, the updated alpine-keys package may be obtained, verified, installed directly, as covered earlier, prior to a repository update.&lt;br /&gt;
&lt;br /&gt;
=== ERROR: unable to select packages: breaks: world ===&lt;br /&gt;
&lt;br /&gt;
{{Cmd|&amp;lt;nowiki&amp;gt;# apk add vim&lt;br /&gt;
ERROR: unable to select packages:&lt;br /&gt;
  vim-common-9.1.1566-r0:&lt;br /&gt;
    breaks: world[!vim-common]&lt;br /&gt;
    satisfies: vim-9.1.1566-r0[vim-common=9.1.1566-r0]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
When issuing package management commands, the above error will arise, if the command cannot be solved without breaking the [[#World|World]]. &amp;lt;!-- This probaly has to be added to it&#039;s own section for package exclusion&lt;br /&gt;
If the {{Path|/etc/apk/world}} file has a constraint {{ic|!vim-common}}, then issuing the command to install {{pkg|vim}} will fail, as {{pkg|vim}} has a dependency on {{pkg|vim-common}} as shown [[#ERROR: unable to select packages: breaks: world|below]]. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== World updated but the following packages are not removed === &lt;br /&gt;
&lt;br /&gt;
On issuing a command to remove a package for eg: {{ic|# apk del btrfs-progs}}, you may receive below error message:&lt;br /&gt;
&amp;lt;Pre&amp;gt;&lt;br /&gt;
World updated, but the following packages are not removed due to:&lt;br /&gt;
  btrfs-progs: btrbk&lt;br /&gt;
&amp;lt;/Pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the removal of package {{Pkg|btrfs-progs}} affects another package {{Pkg|btrbk}} in the constraints file [[#World|/etc/apk/world]]. So the package {{Pkg|btrfs-progs}} will be removed from the constraints file, but not removed from the system. The {{Pkg|btrfs-progs}} will remain in the system, until the constraint i.e {{Pkg|btrbk}} which depends on {{Pkg|btrfs-progs}} is removed. &lt;br /&gt;
&lt;br /&gt;
If {{ic|apk del btrbk}} is issued, the package {{Pkg|btrfs-progs}} will be automatically removed from system as the constraint {{Pkg|btrfs-progs}} does not exist in {{Path|/etc/apk/world}}.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk.8.scd Manual for apk(8)]&lt;br /&gt;
* [https://git.alpinelinux.org/apk-tools/tree/doc/apk-world.5.scd Manual for apk-world(5)]&lt;br /&gt;
* [https://pkgs.alpinelinux.org Official web interface for packages] &lt;br /&gt;
* [[Software management]]&lt;br /&gt;
* [https://ariadne.space/2021/04/24/why-apktools-is-different-than.html  Why apk-tools is different than other package managers]&lt;br /&gt;
* [https://ariadne.space/2021/10/30/spelunking-through-the-apktools-dependency.html spelunking through the apk-tools dependency solver]&lt;br /&gt;
* [https://whynothugo.nl/journal/2023/02/18/in-praise-of-alpine-and-apk/ In praise of alpine and apk]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/10-alpine-linux-apk-command-examples/ 10 Alpine Linux apk Command Examples]&lt;br /&gt;
[[Category:Package Manager]]&lt;br /&gt;
[[Category:System_Administration]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Software_management&amp;diff=31990</id>
		<title>Software management</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Software_management&amp;diff=31990"/>
		<updated>2026-01-25T13:49:18Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added Accuracy template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents various ways to [[#Running glibc programs|run software compiled with glibc]] and to manage software using [[#Graphical software manager|graphical software managers]] in Alpine Linux. There are pages elsewhere regarding compiling [[Compile software from source|software from source]] and for creating a [[Custom Kernel|custom kernel]].&lt;br /&gt;
&lt;br /&gt;
== Alpine package keeper ==&lt;br /&gt;
{{Main|Alpine Package Keeper}}&lt;br /&gt;
The official package manager in Alpine Linux, [[Alpine Package Keeper|Alpine Package Keeper(apk)]], is a &#039;&#039;cli&#039;&#039; tool. [[Comparison_with_other_distros#Comparison_chart/Rosetta_Stone|Rosetta stone]] shows how standard package management tasks are done in Alpine Linux compared to other popular distributions. &lt;br /&gt;
&lt;br /&gt;
== Graphical software manager ==&lt;br /&gt;
&lt;br /&gt;
The following graphical tools are available to manage official software packages from Alpine Linux [[Repositories|repositories]] and [[#Flatpak|flatpaks]] instead of using the [[#Alpine Package Keeper|cli-based apk tool]].&lt;br /&gt;
&lt;br /&gt;
=== GNOME software ===&lt;br /&gt;
&lt;br /&gt;
[[GNOME#Configuration|GNOME software]] can be used as a GUI front end for apk to manage official software packages and flatpaks.&lt;br /&gt;
&lt;br /&gt;
=== KDE Discover ===&lt;br /&gt;
&lt;br /&gt;
[[KDE#Discover|KDE Discover]] can be used as a GUI front end for apk to manage official software packages and flatpaks.&lt;br /&gt;
&lt;br /&gt;
== AppImage ==&lt;br /&gt;
{{Main|AppImage}}&lt;br /&gt;
{{Accuracy|Many AppImages does not work compared to Flatpaks.|section=AppImage}}&lt;br /&gt;
AppImages are by far the easiest method for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. Refer to the [[AppImage]] page for prerequisites and for detailed instructions to run them in Alpine Linux. &lt;br /&gt;
&lt;br /&gt;
== Flatpak ==&lt;br /&gt;
{{Main|Flatpak}}&lt;br /&gt;
&lt;br /&gt;
[[Flatpak#Installing_Flatpak|Flatpak]] is an alternative to [[AppImage|AppImages]] for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. To use flatpaks, ensure that the [[Flatpak#Installing_Flatpak|Flathub repository]] is enabled.&lt;br /&gt;
&lt;br /&gt;
== Coldbrew ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Coldbrew&#039;&#039;&#039; is a package manager that can install Alpine Linux aports Edge packages without needing root access, somewhat similar to &#039;&#039;&#039;brew&#039;&#039;&#039;.  This is particularly useful on immutable operating systems such as with [https://postmarketos.org/blog/2025/10/12/pmOS-update-2025-09/#immutable-postmarketos PostmarketOS&#039;s duranium image].  &#039;&#039;&#039;Coldbrew&#039;&#039;&#039; is available in Alpine Linux Edge testing repository as of January 2026;  the testing repository is [[Repositories#Using_testing_repository|recommended to be tagged]] if installing &#039;&#039;&#039;coldbrew&#039;&#039;&#039; on any supported Alpine Linux release.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Coldbrew&#039;&#039;&#039; replaces the [https://github.com/kcxt/iced &#039;&#039;&#039;iced&#039;&#039;&#039;] package on Alpine Linux, which used the {{Pkg|mkosi-sandbox}};   packages run inside a chroot using &#039;&#039;&#039;bubblewrap&#039;&#039;&#039; instead.  They have access to the home directory, but have only controlled access to all other files through explicit bind mounts.  Packages installed using &#039;&#039;&#039;coldbrew&#039;&#039;&#039; are referred to as tools.  See [https://gitlab.postmarketos.org/postmarketOS/coldbrew further details upstream].&lt;br /&gt;
&lt;br /&gt;
To install &#039;&#039;&#039;coldbrew&#039;&#039;&#039;:&lt;br /&gt;
{{Cmd|$ doas apk add coldbrew@testing}}&lt;br /&gt;
&lt;br /&gt;
To install a tool to be run by &#039;&#039;&#039;coldbrew&#039;&#039;&#039;, say, {{Pkg|corepad}}:&lt;br /&gt;
{{Cmd|$ coldbrew install corepad}}&lt;br /&gt;
&lt;br /&gt;
Note that even though the output ends...&lt;br /&gt;
&lt;br /&gt;
 Installed binary /usr/bin/corepad&lt;br /&gt;
&lt;br /&gt;
...the path being referred to exists within a new mount namespace using bind mounts in the &#039;&#039;&#039;bubblewrap&#039;&#039;&#039; sandbox.&lt;br /&gt;
&lt;br /&gt;
A wrapper program is installed to {{Path|~/.local/bin}} on Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
To run the tool under &#039;&#039;&#039;coldbrew&#039;&#039;&#039;:&lt;br /&gt;
{{Cmd|$ coldbrew run corepad}}&lt;br /&gt;
&lt;br /&gt;
To remove the tool:&lt;br /&gt;
{{Cmd|$ coldbrew remove corepad}}&lt;br /&gt;
&lt;br /&gt;
All installed tools can be listed through the {{ic|$ coldbrew ls}} command.&lt;br /&gt;
&lt;br /&gt;
== Running glibc programs ==&lt;br /&gt;
&lt;br /&gt;
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. &lt;br /&gt;
&lt;br /&gt;
For simpler binaries, you can install [[#gcompat|gcompat]], which is a compatibility layer;  or you could do it the easy way and use [[#Flatpak|Flatpaks]] or [[#AppImage|AppImages]]. See [[#Containers|containers]] or the [[#Chroot|chroot]] section for ways to run glibc programs, including graphical ones such as {{ic|VSCode}}, {{ic|google-chrome}}, {{ic|obsidian}}, etc.&lt;br /&gt;
&lt;br /&gt;
=== gcompat ===&lt;br /&gt;
&lt;br /&gt;
[https://git.adelielinux.org/adelie/gcompat gcompat] is a library that provides glibc-compatible APIs for use on musl libc systems such as Alpine Linux. To install, issue the command: {{cmd|$ doas apk add {{pkg|gcompat}}}}&lt;br /&gt;
After that, you run your binaries as normally.&lt;br /&gt;
&lt;br /&gt;
For an usage example, refer to the [[Firefox#DRM_content_using_Widevine_workaround|Firefox]] page where gcompat is used to run the glibc-compiled Widevine binary.&lt;br /&gt;
&lt;br /&gt;
== Chroot ==&lt;br /&gt;
{{Main|Chroot}}&lt;br /&gt;
&lt;br /&gt;
An option that is easier to generalize to other glibc applications is to install a glibc-based distribution into a chroot. You can then either chroot into it, or use a symlink and some configuration to make its glibc (and associated libraries) usable from Alpine.&lt;br /&gt;
&lt;br /&gt;
{{Tip|The most reliable way to enter a chroot is to use the [[Chroot#Enter_chroot|start-chroot]] script.}}&lt;br /&gt;
&lt;br /&gt;
After setting up a chroot using any of the methods described below, the loader can be set up in Alpine as follows (these instructions are for a Debian chroot in {{Path|/var/chroots/debian}}, on x86_64, but can be adapted to other systems by using the appropriate paths):&lt;br /&gt;
&lt;br /&gt;
{{cmd|$ doas mkdir -p /lib64&lt;br /&gt;
$ doas ln -s /var/chroots/debian/lib/x86_64-linux-gnu/ld-2.33.so /lib64&lt;br /&gt;
$ doas printf &#039;/var/chroots/debian/lib/x86_64-linux-gnu\n/var/chroots/debian/usr/lib/x86_64-linux-gnu\n&#039; &amp;gt; /etc/ld.so.conf&lt;br /&gt;
$ doas /var/chroots/debian/sbin/ldconfig}}&lt;br /&gt;
&lt;br /&gt;
=== Gentoo Linux ===&lt;br /&gt;
&lt;br /&gt;
Select a &#039;&#039;stage3&#039;&#039; from [https://www.gentoo.org/downloads/ here] and the &#039;&#039;portage&#039;&#039; latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.&lt;br /&gt;
&lt;br /&gt;
First,{{cmd|$ doas apk add {{pkg|xz}}}}&lt;br /&gt;
&lt;br /&gt;
Enter the chroot:&lt;br /&gt;
{{cmd|$ doas mkdir ~/chroot&lt;br /&gt;
$ doas cd ~/chroot&lt;br /&gt;
$ doas tar -xvf stage3-*.tar.xz&lt;br /&gt;
$ doas tar -xvf portage-latest.tar.xz&lt;br /&gt;
$ doas mv portage usr&lt;br /&gt;
$ doas mount --bind /dev dev&lt;br /&gt;
$ doas mount --bind /sys sys&lt;br /&gt;
$ doas mount -t proc proc proc&lt;br /&gt;
$ doas cp /etc/resolv.conf etc&lt;br /&gt;
$ doas chroot . /bin/bash}}&lt;br /&gt;
&lt;br /&gt;
And voilà, you have your working Gentoo chroot!&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo&#039;s Handbook] to find out how you can configure and install your system, or simply extract/copy the program that you need to run in your chroot enviroment, and then execute it.&lt;br /&gt;
&lt;br /&gt;
Here is a wrapper script that is similar to {{ic|arch-chroot}} when you frequently reuse this chroot.  Also, create an account with the same username as host current user to the chroot, or make changes to the {{ic|userspec}} option to chroot line:&lt;br /&gt;
&lt;br /&gt;
{{Cat|gentoo-chroot.sh|&amp;lt;nowiki&amp;gt;#!/bin/bash&lt;br /&gt;
CHROOT_PATH=&amp;quot;/home/$USER/chroot&amp;quot;&lt;br /&gt;
cd $CHROOT_PATH&lt;br /&gt;
mount | grep $CHROOT_PATH/dev || doas mount --bind /dev dev&lt;br /&gt;
mount | grep $CHROOT_PATH/sys || doas mount --bind /sys sys&lt;br /&gt;
mount | grep $CHROOT_PATH/proc || doas mount -t proc proc proc&lt;br /&gt;
cp /etc/resolv.conf etc&lt;br /&gt;
doas chroot --userspec=$USER:users . /bin/bash&lt;br /&gt;
echo &amp;quot;You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc.&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Do {{ic|$ chmod +x gentoo-chroot.sh}} to make it executable.&lt;br /&gt;
&lt;br /&gt;
=== Arch Linux ===&lt;br /&gt;
&lt;br /&gt;
{{Seealso|Installing ArchLinux inside an Alpine chroot}}&lt;br /&gt;
Either use &#039;&#039;&#039;pacstrap&#039;&#039;&#039; (included with the arch-install-scripts package) or an Arch bootstrap image:&lt;br /&gt;
&lt;br /&gt;
{{cmd|$ doas apk add {{pkg|arch-install-scripts}}&lt;br /&gt;
$ mkdir ~/chroot &amp;amp;&amp;amp; cd ~/chroot&lt;br /&gt;
$ curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.zst&lt;br /&gt;
$ doas tar -x --zstd -f archlinux-bootstrap-x86_64.tar.zst &amp;amp;&amp;amp; rm archlinux-bootstrap-x86_64.tar.zst&lt;br /&gt;
$ doas sed -i &#039;/evowise/s/^#//&#039; root.x86_64/etc/pacman.d/mirrorlist&lt;br /&gt;
$ doas sed -i &#039;/CheckSpace/s/^/#/&#039; root.x86_64/etc/pacman.conf&lt;br /&gt;
$ doas arch-chroot root.x86_64&lt;br /&gt;
[chroot]# pacman-key --init&lt;br /&gt;
[chroot]# pacman-key --populate archlinux}}&lt;br /&gt;
&lt;br /&gt;
Once that is done, update the system and install the desired package(s) (denoted by &#039;&#039;&amp;quot;foo&amp;quot;&#039;&#039; in this example):&lt;br /&gt;
  &lt;br /&gt;
{{cmd|[chroot]# pacman -Syu &amp;lt;var&amp;gt;foo&amp;lt;/var&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Debian ===&lt;br /&gt;
&lt;br /&gt;
Alpine Linux provides the {{pkg|debootstrap}} package to create the Debian chroot. Here are the steps: {{cmd|$ doas apk add debootstrap&lt;br /&gt;
$ doas mkdir -p /var/chroots/debian&lt;br /&gt;
$ doas debootstrap --arch amd64 stable /var/chroots/debian/ https://deb.debian.org/debian}}&lt;br /&gt;
&lt;br /&gt;
The {{ic|--arch}} is optional, depending on your needs.&lt;br /&gt;
&lt;br /&gt;
For updating the chroot, or for installing packages and their dependencies using {{ic|apt-get}}, mount it, and then login as root:&lt;br /&gt;
{{cmd|$ doas mount --bind /dev /var/chroots/debian/dev&lt;br /&gt;
$ doas mount --bind /proc /var/chroots/debian/proc&lt;br /&gt;
$ doas mount --bind /dev/pts /var/chroots/debian/dev/pts&lt;br /&gt;
$ doas chroot /var/chroots/debian /bin/bash&lt;br /&gt;
[chroot]# apt update &amp;amp;&amp;amp; apt upgrade}}&lt;br /&gt;
&lt;br /&gt;
After installing the necessary applications and whatever else you might do, exit the chroot:&lt;br /&gt;
{{cmd|[chroot]# exit}}&lt;br /&gt;
&lt;br /&gt;
Then, unmount the binds for /dev/pts, dev and proc to avoid issues:&lt;br /&gt;
{{cmd|$ doas umount /var/chroots/debian/dev/pts&lt;br /&gt;
$ doas umount /var/chroots/debian/dev&lt;br /&gt;
$ doas umount /var/chroots/debian/proc}}&lt;br /&gt;
&lt;br /&gt;
== Containers ==&lt;br /&gt;
&lt;br /&gt;
=== Distrobox + Podman ===&lt;br /&gt;
&lt;br /&gt;
[[Distrobox]], combined with [[Podman|podman]] container running in rootless mode, allows to easily run [[Distrobox#Running_graphical_programs|glibc-compiled graphical programs]]. This will not require root privileges once set up.&lt;br /&gt;
&lt;br /&gt;
=== Bubblewrap + Chroot ===&lt;br /&gt;
&lt;br /&gt;
{{ic|glibc}} and {{ic|glibcX11}} shell aliases are defined interactively using bwrap to create a container with [[Bubblewrap]], using a [[#Debian|Debian chroot]] as its content. It&#039;s not just a chroot anymore:  it&#039;s a bubblewrap-powered isolated environment. This allows for easily running graphical programs and does not require root privileges once installed.&lt;br /&gt;
&lt;br /&gt;
[[Install]] the {{pkg|bubblewrap}} package.&lt;br /&gt;
&lt;br /&gt;
Set up [[#Debian|Debian chroot]] at {{path|/var/chroots/debian}} and install necessary glibc applications using {{ic|apt-get}}.&lt;br /&gt;
&lt;br /&gt;
Create a {{ic|glibc}} alias using bwrap in the Alpine Linux host in order to start applications from the [[#Debian|Debian chroot]]:&lt;br /&gt;
{{cmd|$ alias glibc{{=}}&amp;quot;LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
To run programs that use X11/Xorg, you can use: &lt;br /&gt;
{{cmd|$ alias glibcX11{{=}}&amp;quot;LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 --setenv DISPLAY :0&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
In this case, you might need to use {{ic|xhost}} on the Alpine Linux host in order to allow local connections.  For example:{{cmd|# xhost + local:}}&lt;br /&gt;
&lt;br /&gt;
Now we can invoke glibc-built binaries using the alias from the Alpine Linux host, as follows:&lt;br /&gt;
{{cmd|$ glibc ./binary}} or {{cmd|$ glibcX11 ./binary}} &lt;br /&gt;
&lt;br /&gt;
When a [[Wayland]] desktop such as [[Sway]] runs without XWayland on the Alpine Linux host, Electron apps need to be started with Ozone Wayland support:&lt;br /&gt;
&lt;br /&gt;
* For VS Code (note the use of the {{ic|code}} command):&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;glibc code --enable-features=UseOzonePlatform --ozone-platform=wayland&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
* For Google Chrome, etc:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;glibc google-chrome --enable-features=UseOzonePlatform --ozone-platform=wayland&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The flags enforce Wayland rendering, thus avoiding XWayland and improving display, particularly if fractional scaling is also used.&lt;br /&gt;
&lt;br /&gt;
== See also == &lt;br /&gt;
&lt;br /&gt;
* [[Alpine Package Keeper]]&lt;br /&gt;
* [[Installing ArchLinux inside an Alpine chroot]]&lt;br /&gt;
* [[Compile software from source]]&lt;br /&gt;
* [[Kernels]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Package Manager]] [[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Software_management&amp;diff=31989</id>
		<title>Talk:Software management</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Software_management&amp;diff=31989"/>
		<updated>2026-01-25T13:43:03Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: /* AppImage */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Please add the following if pertinent:&lt;br /&gt;
https://github.com/sgerrand/alpine-pkg-glibc/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[Help:Signature|unsigned]] comment added by [[User:Mekineer|Mekineer]] ([[User talk:Mekineer|{{int:talkpagelinktext}}]] • [[Special:Contributions/Mekineer|{{int:contribslink}}]]) 11:04, 26 February 2024‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I thought about the MegaCli wrapper.&lt;br /&gt;
It should be possible to make it read the name it was called by and then launch the respective program&lt;br /&gt;
(i.e. symlink any to-be-wrapped command to /var/lib/glibcstuff ...)&lt;br /&gt;
&lt;br /&gt;
that way you get along with one wrapper script and symlinks to it in /usr/bin.&lt;br /&gt;
&lt;br /&gt;
Another thing I couldnt figure is if it&#039;s important to use all 32bit versions?&lt;br /&gt;
&lt;br /&gt;
And the download links for archlinux are not working because they forward wget to an https url.&lt;br /&gt;
maybe this is some limitation in the default wget version. If i figure it out i&#039;ll do updates on this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
this is my /usr/bin/MegaCli now, using a minimal Debian install in /debian.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
KEYS=&amp;quot;kernel.grsecurity.chroot_caps kernel.grsecurity.chroot_deny_chmod \&lt;br /&gt;
kernel.grsecurity.chroot_deny_chroot kernel.grsecurity.chroot_deny_fchdir \&lt;br /&gt;
kernel.grsecurity.chroot_deny_mknod kernel.grsecurity.chroot_deny_mount \&lt;br /&gt;
kernel.grsecurity.chroot_deny_pivot kernel.grsecurity.chroot_deny_shmat \&lt;br /&gt;
kernel.grsecurity.chroot_deny_sysctl kernel.grsecurity.chroot_deny_unix \&lt;br /&gt;
kernel.grsecurity.chroot_enforce_chdir kernel.grsecurity.chroot_findtask \&lt;br /&gt;
kernel.grsecurity.chroot_restrict_nice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for key in $KEYS ; do&lt;br /&gt;
   sysctl -w ${key}=0 1&amp;gt;/dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
export CHROOT=/debian&lt;br /&gt;
user=$(whoami)&lt;br /&gt;
if [ &amp;quot;$user&amp;quot; != &amp;quot;root&amp;quot; ];then&lt;br /&gt;
echo &amp;quot;This script needs root access&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
fi&lt;br /&gt;
mount -t proc proc $CHROOT/proc/&lt;br /&gt;
mount --bind /dev/ $CHROOT/dev/&lt;br /&gt;
mount --bind /sys/ $CHROOT/sys/&lt;br /&gt;
#we may need dev and maybe proc too to use this program&lt;br /&gt;
chroot $CHROOT /opt/MegaRAID/MegaCli/MegaCli $@&lt;br /&gt;
umount $CHROOT/proc&lt;br /&gt;
umount $CHROOT/dev&lt;br /&gt;
umount $CHROOT/sys&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[Help:Signature|unsigned]] comment added by [[User:Darkfader|Darkfader]] ([[User talk:Darkfader|{{int:talkpagelinktext}}]] • [[Special:Contributions/Darkfader|{{int:contribslink}}]]) 15:32, 11 July 2014‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
If you know how to relax grsecurity without using vanilla on Gentoo to allow PAM to not trigger a postinst error, you should edit the Gentoo section.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;autosigned&amp;quot;&amp;gt;—&amp;amp;nbsp;Preceding [[Help:Signature|unsigned]] comment added by [[User:Orson Teodoro|Orson Teodoro]] ([[User talk:Orson Teodoro|{{int:talkpagelinktext}}]] • [[Special:Contributions/Orson Teodoro|{{int:contribslink}}]]) 13:12, 3 February 2018‎&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I&#039;m unsure, if it&#039;s OK to add the following to page: will leave it here for reference:&lt;br /&gt;
Here are the steps to run vscode, If running [[Sway]] on Alpine Linux.&lt;br /&gt;
# From your Alpine Linux host, download Visual Studio Code from the official website https://code.visualstudio.com/docs/?dv=linux64_deb to your home folder.&lt;br /&gt;
# Install the vscode as follows: {{Cmd|$ distrobox enter my-debian --sudo apt-get install -f /home/&amp;lt;Username&amp;gt;/code_&amp;lt;version_number&amp;gt;_amd64.deb}}&lt;br /&gt;
# Run vscode as follows: {{Cmd|&amp;lt;nowiki&amp;gt;$ distrobox enter my-debian -- code --ozone-platform=wayland&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
--[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 11:10, 2 June 2025 (UTC)&lt;br /&gt;
&lt;br /&gt;
== AppImage ==&lt;br /&gt;
&lt;br /&gt;
Dear [[User:John3-16|John3-16]], your [https://wiki.alpinelinux.org/w/index.php?title=Software_management&amp;amp;diff=prev&amp;amp;oldid=31876 edit] changed the preferred method of running glibc applications from [[Flatpak]] to [[AppImage]]. Flathub is a known repository with a lot of applications that is guaranteed to work in Alpine Linux. I&#039;m not aware of an equivalent reliable i.e trusted source for AppImages that is guaranteed to work in Alpine Linux. &lt;br /&gt;
I tested a few from http://www.appimagehub.com and many did not work. &lt;br /&gt;
&lt;br /&gt;
Please reconsider the above edit and consider restoring the Flatpak suggestion, until AppImages consistently work in Alpine Linux. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 13:43, 25 January 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppImage&amp;diff=31988</id>
		<title>AppImage</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppImage&amp;diff=31988"/>
		<updated>2026-01-25T13:12:24Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: removed the external website&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft|work in progress}}&lt;br /&gt;
&lt;br /&gt;
[https://appimage.org AppImages] allow a simple executable-like experience, but the problem is that many AppImages require glibc, and Alpine Linux uses [[musl]].&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
First you need {{Pkg|fuse}} for AppImages to work;  then, modprobe it.&lt;br /&gt;
{{Cmd|# apk add fuse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; modprobe fuse}}&lt;br /&gt;
Optional, but recommended:  install {{pkg|gcompat}} package for [[Software_management#Running_glibc_programs|glibc compatibility]].&lt;br /&gt;
{{Cmd|# apk add gcompat}}&lt;br /&gt;
&lt;br /&gt;
== Download AppImage ==&lt;br /&gt;
&lt;br /&gt;
Download your AppImage to the user&#039;s directory. The {{Path|~/.local/bin}} location is suitable, further to [https://specifications.freedesktop.org/basedir/latest/#variables XDG Base Directory Specifications].  {{Path|~/bin}} is another common location. {{Warning|Downloading or launching AppImages as root is a &#039;&#039;&#039;security risk&#039;&#039;&#039; and should be avoided.}}&lt;br /&gt;
&lt;br /&gt;
Create the above mentioned directory, if necessary.  It is good practice to ensure that the location for your AppImages appears in the user&#039;s {{Path|$PATH}} for executables so that the AppImages could be launched from a shell (aka &#039;terminal&#039;) without needing to specify their path.  To check, from a user&#039;s prompt: {{Cmd|$ echo $PATH}}&lt;br /&gt;
&lt;br /&gt;
For AppImages to appear in an app launcher, additionally, a {{Path|.desktop}} file with the AppImage&#039;s name would need to be created or found upstream and used if licence permits, placing it in {{Path|~/.local/share/applications}}.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
You have to make the downloaded AppImage executable so that you can launch it: {{Cmd|$ chmod +x &amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
To execute it, for example, when the current working directory of your user prompt is the directory where the AppImage is stored, then you can instruct your shell that the AppImage to be launched is located in that same directory by using the prefix {{ic|./}}:{{Cmd|$ ./&amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
If the AppImage was stored in the user&#039;s {{Path|$PATH}} for executables, neither navigating to the shell to use the {{ic|./}} prefix nor stating the path as a prefix would be necessary to execute it:{{Cmd|$ &amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=AppImage&amp;diff=31987</id>
		<title>AppImage</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=AppImage&amp;diff=31987"/>
		<updated>2026-01-25T13:07:59Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added warning, link to external site with appimages built for musl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft|work in progress}}&lt;br /&gt;
&lt;br /&gt;
[https://appimage.org AppImages] allow a simple executable-like experience, but the problem is that many AppImages require glibc, and Alpine Linux uses [[musl]].&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
First you need {{Pkg|fuse}} for AppImages to work;  then, modprobe it.&lt;br /&gt;
{{Cmd|# apk add fuse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; modprobe fuse}}&lt;br /&gt;
Optional, but recommended:  install {{pkg|gcompat}} package for [[Software_management#Running_glibc_programs|glibc compatibility]].&lt;br /&gt;
{{Cmd|# apk add gcompat}}&lt;br /&gt;
&lt;br /&gt;
== Download AppImage ==&lt;br /&gt;
&lt;br /&gt;
Download your AppImage to the user&#039;s directory. The {{Path|~/.local/bin}} location is suitable, further to [https://specifications.freedesktop.org/basedir/latest/#variables XDG Base Directory Specifications].  {{Path|~/bin}} is another common location. {{Warning|Downloading or launching AppImages as root is a &#039;&#039;&#039;security risk&#039;&#039;&#039; and should be avoided.}}&lt;br /&gt;
&lt;br /&gt;
Create the above mentioned directory, if necessary.  It is good practice to ensure that the location for your AppImages appears in the user&#039;s {{Path|$PATH}} for executables so that the AppImages could be launched from a shell (aka &#039;terminal&#039;) without needing to specify their path.  To check, from a user&#039;s prompt: {{Cmd|$ echo $PATH}}&lt;br /&gt;
&lt;br /&gt;
For AppImages to appear in an app launcher, additionally, a {{Path|.desktop}} file with the AppImage&#039;s name would need to be created or found upstream and used if licence permits, placing it in {{Path|~/.local/share/applications}}.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
You have to make the downloaded AppImage executable so that you can launch it: {{Cmd|$ chmod +x &amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
To execute it, for example, when the current working directory of your user prompt is the directory where the AppImage is stored, then you can instruct your shell that the AppImage to be launched is located in that same directory by using the prefix {{ic|./}}:{{Cmd|$ ./&amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
If the AppImage was stored in the user&#039;s {{Path|$PATH}} for executables, neither navigating to the shell to use the {{ic|./}} prefix nor stating the path as a prefix would be necessary to execute it:{{Cmd|$ &amp;lt;var&amp;gt;Example&amp;lt;/var&amp;gt;.AppImage}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://xplshn.github.io/AppBundleHUB/ - AppImages that run on Musl]] &lt;br /&gt;
&lt;br /&gt;
[[Category:Software]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=31986</id>
		<title>Zero-To-Awall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=31986"/>
		<updated>2026-01-24T17:06:03Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added wikilink&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This [https://git.alpinelinux.org/awall/about/ Alpine Wall] howto is aimed at users with no or little experience with iptables and other firewall framework. [[How-To Alpine Wall]] page is aimed at users familiar with shorewall and [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide] is the official source for details about the syntax. &lt;br /&gt;
&lt;br /&gt;
== Base policies ==&lt;br /&gt;
&lt;br /&gt;
Be aware that all configuration files are stored as JSON files. JSON is not a human friendly standard, for instance it does not support comments so you will have to move them outside of the json structure.&lt;br /&gt;
&lt;br /&gt;
Beginners should use a decent text editor with JSON highlight support which will make your life easier. Recent versions of Alpine Wall support using yaml instead of json but this is out of scope of this howto.&lt;br /&gt;
&lt;br /&gt;
Creating zones depends on the function of your firewall. Is it installed on a endpoint (server) or will it act as a router and filter/forward.&lt;br /&gt;
&lt;br /&gt;
For this howto we assume you are going to setup a router and use NAT to forward services (ports) to different hosts on your network.&lt;br /&gt;
&lt;br /&gt;
For each interface on router we will setup a zone and assign it a zone name. We do this by creating the following file: /etc/awall/private/base.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Base zones and policies&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;WAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;LAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; },&lt;br /&gt;
    &amp;quot;VPN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;tun+&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;out&amp;quot;:  &amp;quot;WAN&amp;quot; , &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;clamp-mss&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets break this down into sections&lt;br /&gt;
&lt;br /&gt;
=== description ===&lt;br /&gt;
&lt;br /&gt;
The description is here just for reference and will be used by &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== zone ===&lt;br /&gt;
&lt;br /&gt;
This is where our zones are defined. Zones are defined based on a interface and assigned a name to be used in your policies.&lt;br /&gt;
In our example you can see that we have two real interfaces eth0 and eth1 and one or more virtual interfaces tun+ (the plus sign stands for any digit like tun0 tun1 and so on). In case you are installing awall on an endpoint (a server) then you will most probably not have the eth1 interfaces and can leave it out. In our example the tun+ interface is added as it is very commonly used like when using openvpn.&lt;br /&gt;
&lt;br /&gt;
=== policy ===&lt;br /&gt;
&lt;br /&gt;
These are our main policies. It will tell our firewall what to do with when a packet enters or leaves from one of the zones (interfaces).&lt;br /&gt;
You will notice a special &amp;lt;code&amp;gt;_fw&amp;lt;/code&amp;gt; name which means the internal firewall (the local machine) which means the packet does not leave the firewall via another interface but should be send to one of the local services.&lt;br /&gt;
You can see that we by default do not filter any package coming from or going to our VPN zone/interface. You could instead change the default action to drop all packets and create separate policies to allow specific traffic but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
=== snat ===&lt;br /&gt;
&lt;br /&gt;
Apply source nat for outgoing packets. This is only needed if your firewall acts as a router and traffic behind the router needs a modified source address (translate from local ip to public ip).&lt;br /&gt;
&lt;br /&gt;
=== clamp-mss ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/alpinelinux/awall#mss-clamping-rules&lt;br /&gt;
&lt;br /&gt;
== Service policies ==&lt;br /&gt;
&lt;br /&gt;
Now that we have the base firewall in place we can start to define specific policies so our services will be reachable from the outside world.\&lt;br /&gt;
By default we are blocking all traffic coming in on our WAN interface (action=drop). The first thing we want to open is our SSH port/service. To do this we need to create a new policy inside the &amp;quot;optional&amp;quot; directory.&lt;br /&gt;
You could be wondering why the optional name, thats is because mandatory policies are stored in &amp;lt;code&amp;gt;/usr/share/awall/mandatory&amp;lt;/code&amp;gt; and not to be touched and our optional policies can be enabled/disabled on the run.&lt;br /&gt;
&lt;br /&gt;
=== SSH service ===&lt;br /&gt;
&lt;br /&gt;
To add our SSH policies we create a new file: /etc/awall/optional/ssh.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited SSH on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ssh&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== description ====&lt;br /&gt;
&lt;br /&gt;
This is similar for any policy&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
This is the actual filter that is currently set to drop the packets arriving or leaving the interface.&lt;br /&gt;
&lt;br /&gt;
===== in =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets arrive on, in this case its the WAN interface.&lt;br /&gt;
&lt;br /&gt;
===== out =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets leave on, in this case its _fw which means it does not leave our firewall/device and is targeted at our local SSH service.&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
This is the service definition provided by awall or a custom service which we will discuss later on.&lt;br /&gt;
&lt;br /&gt;
===== action =====&lt;br /&gt;
&lt;br /&gt;
The action on the packet, this inverts the default action of drop and accepts the packets.&lt;br /&gt;
&lt;br /&gt;
===== conn-limit =====&lt;br /&gt;
&lt;br /&gt;
This is a special feature of our firewall/iptables to allow only a certain amount of packets in a certain amount of time. For more information please check our awall manual.&lt;br /&gt;
&lt;br /&gt;
=== SSH to another Host ===&lt;br /&gt;
&lt;br /&gt;
edit the following file: /etc/awall/optional/ssh-to-hostname.json&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Forward SSH to hostname&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;dnat&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$SERVER&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;to-port&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets discuss the differences between this policy and the previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
Because port 22 is already in use by our own firewall, we need to listen on a different port. In this example we listen on port 22001.&lt;br /&gt;
And because we are not using the default port 22 we need to define our own service specification.&lt;br /&gt;
&lt;br /&gt;
==== dnat ====&lt;br /&gt;
&lt;br /&gt;
Also known as destination NAT.&lt;br /&gt;
&lt;br /&gt;
===== dest =====&lt;br /&gt;
&lt;br /&gt;
The destination the packet will be forwarded to. In this case we are using a variable named $HOSTNAME. Anywhere in your policies you can define your own variables and use them.&lt;br /&gt;
In our case we have used a file in /etc/awall/private/aliases.json more on this topic later on.&lt;br /&gt;
&lt;br /&gt;
===== to-port =====&lt;br /&gt;
&lt;br /&gt;
This is the destination target port number. The packet will be forwarded from 22001 to 22 on the $hostname&lt;br /&gt;
&lt;br /&gt;
=== OpenVPN Service ===&lt;br /&gt;
&lt;br /&gt;
This is the most generic config available. It does nothing more then opening port(s) defined for our openvpn service in {{path|/etc/awall/private/custom-services.json}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;Allow local OpenVPN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;filter&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
            &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
            &amp;quot;service&amp;quot;: &amp;quot;openvpn&amp;quot;,&lt;br /&gt;
            &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow ping on WAN ===&lt;br /&gt;
&lt;br /&gt;
Allow rate-limited ping on WAN. Which has the same kind of flow limit as our previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited ping on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ping&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;flow-limit&amp;quot;: { &amp;quot;count&amp;quot;: 10, &amp;quot;interval&amp;quot;: 6 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using aliases and custom services ==&lt;br /&gt;
&lt;br /&gt;
=== Aliases ===&lt;br /&gt;
&lt;br /&gt;
To make life easier when your firewall rules increase, it can be nice to map specific hosts to names.&lt;br /&gt;
Awall supports something called [https://github.com/alpinelinux/awall#variable-expansion variable expansion] which is a mapping between a value and a variable.&lt;br /&gt;
When you have many devices behind your firewall/router, your policies can be harder to read. Also when one of your devices IP address change you will have to update all of your policies.&lt;br /&gt;
With awalls variables you can assign the ip address of a device to a variable name. Edit the following file: &amp;lt;code&amp;gt;/etc/awall/private/aliases.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Hostname aliases&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;PRINTER&amp;quot;: &amp;quot;192.168.1.1&amp;quot;,&lt;br /&gt;
    &amp;quot;SERVER&amp;quot;: &amp;quot;192.168.1.2&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look in the example above where $SERVER is used to forward port 22001 to port 22.&lt;br /&gt;
&lt;br /&gt;
NOTE: You are not limited to assigning only IP addresses to variables. You can use it however you like. More information can be found in the awall manual.&lt;br /&gt;
&lt;br /&gt;
=== Custom services ===&lt;br /&gt;
&lt;br /&gt;
Awall includes a predefined list of [https://raw.githubusercontent.com/alpinelinux/awall/master/mandatory/services.json services]. If the service you try to define in your policy does not exist in awalls services list you can define services yourself.&lt;br /&gt;
&lt;br /&gt;
Create the file: {{path|/etc/awall/private/custom-services.json}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;service&amp;quot;: {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;mqtt&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1883 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1883 }&lt;br /&gt;
        ],&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;openvpn&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
        ]&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: although you are free to name your policy files however you want, you cannot name this file &amp;lt;code&amp;gt;services.json&amp;lt;/code&amp;gt; because this policy name is already in use by the included services.json of awall.&lt;br /&gt;
&lt;br /&gt;
== Using our policies ==&lt;br /&gt;
&lt;br /&gt;
You should now have two directories in your awall config directory named optional and private with multiple json files. The biggest difference between these two directories is the ability to enable and disable policies located in the optional directory. When you enable a policy by using &amp;lt;code&amp;gt;awall enable policy-name&amp;lt;/code&amp;gt; awall will generate a symlink in your awall config directory and will automatically load them when you activate the firewall. To be able to also use the files in the private directory we will need to include them in one of our optional policies. You can name the file however you like as long it doesn&#039;t conflict with existing policies names (including the ones in private directory and awall&#039;s system policies). Example names would be hostname.json main.json firewall.json. For this example we will use main.json.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/optional/main.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Main firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;import&amp;quot;: [ &amp;quot;base&amp;quot;, &amp;quot;aliases&amp;quot;, &amp;quot;custom-services&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of your awall directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall&lt;br /&gt;
│&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
└── private&lt;br /&gt;
    ├── aliases.json&lt;br /&gt;
    ├── base.json&lt;br /&gt;
    └── custom-services.json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enabling optional policies ===&lt;br /&gt;
&lt;br /&gt;
Lets enable our created policies. First we list them by running &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt; which would show something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openvpn         disabled  Allow local OpenVPN&lt;br /&gt;
main            disabled  Main firewall&lt;br /&gt;
ping            disabled  Allow rate-limited ping on WAN&lt;br /&gt;
ssh             disabled  Allow rate-limited SSH on WAN&lt;br /&gt;
ssh-to-hostname disabled  Forward SSH to hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these needs to be enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall enable openvpn&lt;br /&gt;
awall enable main&lt;br /&gt;
awall enable ping&lt;br /&gt;
awall enable ssh&lt;br /&gt;
awall enable ssh-to-hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of your awall directory should now look like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall/&lt;br /&gt;
├── main.json -&amp;gt; ./optional/main.json&lt;br /&gt;
├── openvpn.json -&amp;gt; ./optional/openvpn.json&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ping.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
├── ping.json -&amp;gt; ./optional/ping.json&lt;br /&gt;
├── private&lt;br /&gt;
│   ├── aliases.json&lt;br /&gt;
│   ├── base.json&lt;br /&gt;
│   └── custom-services.json&lt;br /&gt;
├── ssh-to-hostname.json -&amp;gt; ./optional/ssh-to-hostname.json&lt;br /&gt;
└── ssh.json -&amp;gt; ./optional/ssh.json&lt;br /&gt;
&lt;br /&gt;
2 directories, 13 files&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing policies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall translate --verify&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if everything goes well the output should be null.&lt;br /&gt;
&lt;br /&gt;
=== Activating the firewall ===&lt;br /&gt;
&lt;br /&gt;
Now that all our policies are verified for proper json we can activate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall activate&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load the firewall rules and show you a message to confirm. If by accident you made a mistake and lock yourself out you just have to wait for awall to disable itself again.&lt;br /&gt;
&lt;br /&gt;
== Finishing up ==&lt;br /&gt;
&lt;br /&gt;
=== Activating firewall rules at boot ===&lt;br /&gt;
&lt;br /&gt;
When awall has been properly activated it will generate a file with all iptables rules which iptables will read when its is started via openrc.&lt;br /&gt;
Make sure you have added iptables to an openrc runlevel. If using snat, also enable ipset for the masquerade set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add ipset&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow IPv4 forwarding ===&lt;br /&gt;
&lt;br /&gt;
To allow iptables to forward packets from one zone to the other we need to enable this at the iptables level.&lt;br /&gt;
&lt;br /&gt;
==== On the fly ====&lt;br /&gt;
&lt;br /&gt;
To enable it on the fly:&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -w net.ipv4.ip_forward=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enable within iptables tools (at boot) ====&lt;br /&gt;
&lt;br /&gt;
Add the following to:&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/conf.d/iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Enable/disable IPv4 forwarding with the rules&lt;br /&gt;
IPFORWARD=&amp;quot;yes&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[How-To Alpine Wall]]&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31985</id>
		<title>How-To Alpine Wall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31985"/>
		<updated>2026-01-24T16:56:34Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added wikilink and simplified introduction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page shows how to configure Alpine Wall(awall) as compared to {{pkg|Shorewall}} firewall. This comparison is meant to help readers who are familiar with Shorewall learn AWall. Awall users should follow the AWall configuration examples. Use the Shorewall examples as contextual references, or ignore them, if unfamiliar with Shorewall. &lt;br /&gt;
&lt;br /&gt;
[[Zero-To-Awall]] howto page is meant for users with no firewall experience and [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide] is the official source for details about the syntax. &lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
	&lt;br /&gt;
Install the {{pkg|awall}} package by running the following command:{{cmd|# apk add iptables awall}}&lt;br /&gt;
&lt;br /&gt;
Note that awall requires {{pkg|iptables}} but works with both backends [[nftables]] and legacy [[iptables]]. It does not interact with nftables directly.&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
The easier method for performing initial steps for running awall: {{cmd|# awall activate}} &lt;br /&gt;
The above command has special handling for the first run, when firewall is not yet enabled in the kernel. It performs the  below manual steps and also updates the default runlevel and files in {{Path|/etc/conf.d}}&lt;br /&gt;
&lt;br /&gt;
Use the below commands for performing initial setup manually. &lt;br /&gt;
* To update /etc/iptables: {{cmd|# awall translate}}&lt;br /&gt;
* To start the [[OpenRC]] services for iptables and load modules and rules for IPv4 and IPv6 {{cmd|&amp;lt;nowiki&amp;gt;# rc-service iptables start  &lt;br /&gt;
# rc-service ip6tables start &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration files ===&lt;br /&gt;
&lt;br /&gt;
Your [[Alpine Wall]] configuration files go in {{Path|/etc/awall/optional}}. From version 0.2.12 and later, Awall will look for &#039;&#039;Policy&#039;&#039; files in both the former and {{Path|/usr/share/awall/optional}}&lt;br /&gt;
Each such file is called a &#039;&#039;Policy&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may have multiple &#039;&#039;Policy&#039;&#039; files. It is useful to have separate files for eg. HTTP, FTP, etc.&lt;br /&gt;
The &#039;&#039;Policy(s)&#039;&#039; can be enabled or disabled by using the command: {{cmd|&amp;lt;nowiki&amp;gt;# awall [enable|disable]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An AWall &#039;&#039;Policy&#039;&#039; can contain definitions of:&lt;br /&gt;
* variables &#039;&#039;(like {{Path|/etc/shorewall/params}})&#039;&#039;&lt;br /&gt;
* zones &#039;&#039;(like {{Path|/etc/shorewall/zones}})&#039;&#039;&lt;br /&gt;
* interfaces &#039;&#039;(like {{Path|/etc/shorewall/interfaces}})&#039;&#039;&lt;br /&gt;
* policies &#039;&#039;(like {{Path|/etc/shorewall/policy}})&#039;&#039;&lt;br /&gt;
* filters and NAT rules &#039;&#039;(like {{Path|/etc/shorewall/rules}})&#039;&#039;&lt;br /&gt;
* services &#039;&#039;(like {{Path|/usr/share/shorewall/macro.HTTP}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Basic home firewall configuration ==&lt;br /&gt;
&lt;br /&gt;
The examples below show how to configure a basic home firewall using AWall. Note that AWall Policy files differ substantially from Shorewall&#039;s policy files in syntax and layout.&lt;br /&gt;
&lt;br /&gt;
=== Shorewall configuration ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have the following Shorewall configuration files in {{Path|/etc/shorewall/}}, which you want to convert to a [[#AWall configuration|configuration for AWall]].  {{cat|/etc/shorewall/zones|inet  ipv4&lt;br /&gt;
loc   ipv4}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/interfaces|inet  eth0&lt;br /&gt;
loc   eth1}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/policy|fw   all  ACCEPT&lt;br /&gt;
loc  inet ACCEPT&lt;br /&gt;
all  all  DROP}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/masq|eth0  0.0.0.0/0}}&lt;br /&gt;
&lt;br /&gt;
=== AWall configuration ===&lt;br /&gt;
&lt;br /&gt;
The equivalent AWall configuration that does the same thing as the above [[#Shorewall configuration|Shorewall example]] is given below.&lt;br /&gt;
&lt;br /&gt;
Create a new file called {{Path|/etc/awall/optional/home-policy.json}} and add the following content {{Cat|/etc/awall/optional/home-policy.json|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Home firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;inet&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;loc&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [&lt;br /&gt;
    { &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot; }&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The above configuration will:&lt;br /&gt;
* Create a description of your &#039;&#039;Policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;zones&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;snat&#039;&#039; &#039;&#039;(to masqurade the outgoing traffic)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;snat&#039;&#039;&#039; means &amp;quot;source NAT&amp;quot;. It does &amp;lt;u&amp;gt;not&amp;lt;/u&amp;gt; mean &amp;quot;static NAT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Tip| AWall has a built-in zone named &amp;quot;_fw&amp;quot; which is the &amp;quot;firewall itself&amp;quot;. This corresponds to the Shorewall &amp;quot;fw&amp;quot; zone.}}&lt;br /&gt;
&lt;br /&gt;
=== Activating/Applying a Policy ===&lt;br /&gt;
&lt;br /&gt;
After saving the &#039;&#039;Policy&#039;&#039; you can run the following commands to activate your firewall settings.&lt;br /&gt;
To listing available &#039;Policy(s)&#039; {{cmd|# awall list}} &lt;br /&gt;
To enable the &#039;Policy&#039; created in the previous section:{{cmd|# awall enable home-policy}}    &lt;br /&gt;
To generate firewall configuration from the &#039;Policy&#039; file and enable it i.e start the firewall: {{Cmd|# awall activate}}              &lt;br /&gt;
&lt;br /&gt;
If you have multiple policies, after enabling or disabling them, you need to always run {{Codeline|&#039;&#039;&#039;awall activate&#039;&#039;&#039;}} in order to update the iptables rules.&lt;br /&gt;
&lt;br /&gt;
== Advanced configuration ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have your {{Path|/etc/awall/optional/home-policy.json}} with your &amp;quot;Basic home firewall&amp;quot; settings, you could choose to modify that file to test the below examples. You could also create new files in {{Path|/etc/awall/optional/}} for testing some of the below examples.&lt;br /&gt;
&lt;br /&gt;
AWall already has a &amp;quot;service&amp;quot; definition list for several services like HTTP, FTP, SNMP, etc. &#039;&#039; in the file {{Path|/usr/share/awall/mandatory/services.json}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are adding the sample content given in this section to an already existing policy file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
AWall will &#039;&#039;(since v0.2.7)&#039;&#039; automatically log dropped packets.&lt;br /&gt;
&lt;br /&gt;
You could add the following row to the &amp;quot;policy&amp;quot; section in your &#039;&#039;Policy&#039;&#039; file in order to see the dropped packets.&lt;br /&gt;
&amp;lt;pre&amp;gt;{ &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Port forwarding ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have a local web server (192.168.1.10) that you want to make accessible from the &amp;quot;inet&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
With Shorewall you would have a rule like this in your {{Cat|/etc/shorewall/rules|&amp;lt;nowiki&amp;gt;#ACTION  SOURCE  DEST               PROTO  DEST PORT(S)    SOURCEPORT(S)    ORIGINALDEST&lt;br /&gt;
DNAT     inet     loc:192.168.1.10  tcp    80&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Lets configure our AWall &#039;&#039;Policy&#039;&#039; file likewise by adding the following content.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;APACHE&amp;quot;: &amp;quot;192.168.1.10&amp;quot;,&lt;br /&gt;
    &amp;quot;STATIC_IP&amp;quot;: &amp;quot;1.2.3.4&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;, &lt;br /&gt;
      &amp;quot;dnat&amp;quot;: &amp;quot;$APACHE&amp;quot; &lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see in the above example, we create a&lt;br /&gt;
* &amp;quot;variable&amp;quot; section where we specify some IP-addresses&lt;br /&gt;
* &amp;quot;filter&amp;quot; section where we do the actual port-forwarding (using the variables we just created and using some preexisting &amp;quot;services&amp;quot; definitions)&lt;br /&gt;
&lt;br /&gt;
If you need to forward to a different port (e.g. 8080) you can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dnat&amp;quot;: [&lt;br /&gt;
  {&amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &amp;quot;to-addr&amp;quot;: &amp;quot;$APACHE&amp;quot;, &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &amp;quot;to-port&amp;quot;: 8080 }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create your own service definitions ===&lt;br /&gt;
&lt;br /&gt;
{{Note| You can not override a &amp;quot;service&amp;quot; definition that comes from {{Path|/usr/share/awall/mandatory/services.json}}}}&lt;br /&gt;
&lt;br /&gt;
You can add your own service definitions into your &#039;&#039;Policy&#039;&#039; files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;service&amp;quot;: {  &lt;br /&gt;
  &amp;quot;openvpn&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inherit services or variables === &lt;br /&gt;
&lt;br /&gt;
You can import a &#039;&#039;Policy&#039;&#039; into other &#039;&#039;Policy&#039;&#039; files for inheriting services or variables definitions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;import&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Customize policy loading order ===&lt;br /&gt;
&lt;br /&gt;
By default policies are loaded on alphabetical order. The load order can be changed with the keywords &amp;quot;before&amp;quot; and &amp;quot;after&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;before&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;quot;after&amp;quot;: &amp;quot;someotherpolicy&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you end up in some kind of trouble, you might find some commands useful when debugging:&lt;br /&gt;
{{cmd|awall                 # (With no parameters) Shows some basic help about awall application&lt;br /&gt;
awall dump            # Dump definitions like zones and variables&lt;br /&gt;
iptables -L -n        # Show what&#039;s in &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
* [[Zero-To-Awall]]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-awall-on-alpine-linux/ How To Set Up a Firewall with Awall on Alpine Linux]&lt;br /&gt;
&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=31984</id>
		<title>Zero-To-Awall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=31984"/>
		<updated>2026-01-24T16:45:40Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: fixed heading level and introduction page, added wikilink&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This [https://git.alpinelinux.org/awall/about/ Alpine Wall] howto is aimed at users with no or little experience with iptables and other firewall framework. [[How-To Alpine Wall]] page is aimed at users familiar with shorewall.&lt;br /&gt;
&lt;br /&gt;
== Base policies ==&lt;br /&gt;
&lt;br /&gt;
Be aware that all configuration files are stored as JSON files. JSON is not a human friendly standard, for instance it does not support comments so you will have to move them outside of the json structure.&lt;br /&gt;
&lt;br /&gt;
Beginners should use a decent text editor with JSON highlight support which will make your life easier. Recent versions of Alpine Wall support using yaml instead of json but this is out of scope of this howto.&lt;br /&gt;
&lt;br /&gt;
Creating zones depends on the function of your firewall. Is it installed on a endpoint (server) or will it act as a router and filter/forward.&lt;br /&gt;
&lt;br /&gt;
For this howto we assume you are going to setup a router and use NAT to forward services (ports) to different hosts on your network.&lt;br /&gt;
&lt;br /&gt;
For each interface on router we will setup a zone and assign it a zone name. We do this by creating the following file: /etc/awall/private/base.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Base zones and policies&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;WAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;LAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; },&lt;br /&gt;
    &amp;quot;VPN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;tun+&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;out&amp;quot;:  &amp;quot;WAN&amp;quot; , &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;clamp-mss&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets break this down into sections&lt;br /&gt;
&lt;br /&gt;
=== description ===&lt;br /&gt;
&lt;br /&gt;
The description is here just for reference and will be used by &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== zone ===&lt;br /&gt;
&lt;br /&gt;
This is where our zones are defined. Zones are defined based on a interface and assigned a name to be used in your policies.&lt;br /&gt;
In our example you can see that we have two real interfaces eth0 and eth1 and one or more virtual interfaces tun+ (the plus sign stands for any digit like tun0 tun1 and so on). In case you are installing awall on an endpoint (a server) then you will most probably not have the eth1 interfaces and can leave it out. In our example the tun+ interface is added as it is very commonly used like when using openvpn.&lt;br /&gt;
&lt;br /&gt;
=== policy ===&lt;br /&gt;
&lt;br /&gt;
These are our main policies. It will tell our firewall what to do with when a packet enters or leaves from one of the zones (interfaces).&lt;br /&gt;
You will notice a special &amp;lt;code&amp;gt;_fw&amp;lt;/code&amp;gt; name which means the internal firewall (the local machine) which means the packet does not leave the firewall via another interface but should be send to one of the local services.&lt;br /&gt;
You can see that we by default do not filter any package coming from or going to our VPN zone/interface. You could instead change the default action to drop all packets and create separate policies to allow specific traffic but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
=== snat ===&lt;br /&gt;
&lt;br /&gt;
Apply source nat for outgoing packets. This is only needed if your firewall acts as a router and traffic behind the router needs a modified source address (translate from local ip to public ip).&lt;br /&gt;
&lt;br /&gt;
=== clamp-mss ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/alpinelinux/awall#mss-clamping-rules&lt;br /&gt;
&lt;br /&gt;
== Service policies ==&lt;br /&gt;
&lt;br /&gt;
Now that we have the base firewall in place we can start to define specific policies so our services will be reachable from the outside world.\&lt;br /&gt;
By default we are blocking all traffic coming in on our WAN interface (action=drop). The first thing we want to open is our SSH port/service. To do this we need to create a new policy inside the &amp;quot;optional&amp;quot; directory.&lt;br /&gt;
You could be wondering why the optional name, thats is because mandatory policies are stored in &amp;lt;code&amp;gt;/usr/share/awall/mandatory&amp;lt;/code&amp;gt; and not to be touched and our optional policies can be enabled/disabled on the run.&lt;br /&gt;
&lt;br /&gt;
=== SSH service ===&lt;br /&gt;
&lt;br /&gt;
To add our SSH policies we create a new file: /etc/awall/optional/ssh.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited SSH on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ssh&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== description ====&lt;br /&gt;
&lt;br /&gt;
This is similar for any policy&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
This is the actual filter that is currently set to drop the packets arriving or leaving the interface.&lt;br /&gt;
&lt;br /&gt;
===== in =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets arrive on, in this case its the WAN interface.&lt;br /&gt;
&lt;br /&gt;
===== out =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets leave on, in this case its _fw which means it does not leave our firewall/device and is targeted at our local SSH service.&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
This is the service definition provided by awall or a custom service which we will discuss later on.&lt;br /&gt;
&lt;br /&gt;
===== action =====&lt;br /&gt;
&lt;br /&gt;
The action on the packet, this inverts the default action of drop and accepts the packets.&lt;br /&gt;
&lt;br /&gt;
===== conn-limit =====&lt;br /&gt;
&lt;br /&gt;
This is a special feature of our firewall/iptables to allow only a certain amount of packets in a certain amount of time. For more information please check our awall manual.&lt;br /&gt;
&lt;br /&gt;
=== SSH to another Host ===&lt;br /&gt;
&lt;br /&gt;
edit the following file: /etc/awall/optional/ssh-to-hostname.json&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Forward SSH to hostname&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;dnat&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$SERVER&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;to-port&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets discuss the differences between this policy and the previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
Because port 22 is already in use by our own firewall, we need to listen on a different port. In this example we listen on port 22001.&lt;br /&gt;
And because we are not using the default port 22 we need to define our own service specification.&lt;br /&gt;
&lt;br /&gt;
==== dnat ====&lt;br /&gt;
&lt;br /&gt;
Also known as destination NAT.&lt;br /&gt;
&lt;br /&gt;
===== dest =====&lt;br /&gt;
&lt;br /&gt;
The destination the packet will be forwarded to. In this case we are using a variable named $HOSTNAME. Anywhere in your policies you can define your own variables and use them.&lt;br /&gt;
In our case we have used a file in /etc/awall/private/aliases.json more on this topic later on.&lt;br /&gt;
&lt;br /&gt;
===== to-port =====&lt;br /&gt;
&lt;br /&gt;
This is the destination target port number. The packet will be forwarded from 22001 to 22 on the $hostname&lt;br /&gt;
&lt;br /&gt;
=== OpenVPN Service ===&lt;br /&gt;
&lt;br /&gt;
This is the most generic config available. It does nothing more then opening port(s) defined for our openvpn service in {{path|/etc/awall/private/custom-services.json}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;Allow local OpenVPN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;filter&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
            &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
            &amp;quot;service&amp;quot;: &amp;quot;openvpn&amp;quot;,&lt;br /&gt;
            &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow ping on WAN ===&lt;br /&gt;
&lt;br /&gt;
Allow rate-limited ping on WAN. Which has the same kind of flow limit as our previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited ping on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ping&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;flow-limit&amp;quot;: { &amp;quot;count&amp;quot;: 10, &amp;quot;interval&amp;quot;: 6 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using aliases and custom services ==&lt;br /&gt;
&lt;br /&gt;
=== Aliases ===&lt;br /&gt;
&lt;br /&gt;
To make life easier when your firewall rules increase, it can be nice to map specific hosts to names.&lt;br /&gt;
Awall supports something called [https://github.com/alpinelinux/awall#variable-expansion variable expansion] which is a mapping between a value and a variable.&lt;br /&gt;
When you have many devices behind your firewall/router, your policies can be harder to read. Also when one of your devices IP address change you will have to update all of your policies.&lt;br /&gt;
With awalls variables you can assign the ip address of a device to a variable name. Edit the following file: &amp;lt;code&amp;gt;/etc/awall/private/aliases.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Hostname aliases&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;PRINTER&amp;quot;: &amp;quot;192.168.1.1&amp;quot;,&lt;br /&gt;
    &amp;quot;SERVER&amp;quot;: &amp;quot;192.168.1.2&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look in the example above where $SERVER is used to forward port 22001 to port 22.&lt;br /&gt;
&lt;br /&gt;
NOTE: You are not limited to assigning only IP addresses to variables. You can use it however you like. More information can be found in the awall manual.&lt;br /&gt;
&lt;br /&gt;
=== Custom services ===&lt;br /&gt;
&lt;br /&gt;
Awall includes a predefined list of [https://raw.githubusercontent.com/alpinelinux/awall/master/mandatory/services.json services]. If the service you try to define in your policy does not exist in awalls services list you can define services yourself.&lt;br /&gt;
&lt;br /&gt;
Create the file: {{path|/etc/awall/private/custom-services.json}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;service&amp;quot;: {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;mqtt&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1883 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1883 }&lt;br /&gt;
        ],&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;openvpn&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
        ]&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: although you are free to name your policy files however you want, you cannot name this file &amp;lt;code&amp;gt;services.json&amp;lt;/code&amp;gt; because this policy name is already in use by the included services.json of awall.&lt;br /&gt;
&lt;br /&gt;
== Using our policies ==&lt;br /&gt;
&lt;br /&gt;
You should now have two directories in your awall config directory named optional and private with multiple json files. The biggest difference between these two directories is the ability to enable and disable policies located in the optional directory. When you enable a policy by using &amp;lt;code&amp;gt;awall enable policy-name&amp;lt;/code&amp;gt; awall will generate a symlink in your awall config directory and will automatically load them when you activate the firewall. To be able to also use the files in the private directory we will need to include them in one of our optional policies. You can name the file however you like as long it doesn&#039;t conflict with existing policies names (including the ones in private directory and awall&#039;s system policies). Example names would be hostname.json main.json firewall.json. For this example we will use main.json.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/optional/main.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Main firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;import&amp;quot;: [ &amp;quot;base&amp;quot;, &amp;quot;aliases&amp;quot;, &amp;quot;custom-services&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of your awall directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall&lt;br /&gt;
│&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
└── private&lt;br /&gt;
    ├── aliases.json&lt;br /&gt;
    ├── base.json&lt;br /&gt;
    └── custom-services.json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enabling optional policies ===&lt;br /&gt;
&lt;br /&gt;
Lets enable our created policies. First we list them by running &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt; which would show something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openvpn         disabled  Allow local OpenVPN&lt;br /&gt;
main            disabled  Main firewall&lt;br /&gt;
ping            disabled  Allow rate-limited ping on WAN&lt;br /&gt;
ssh             disabled  Allow rate-limited SSH on WAN&lt;br /&gt;
ssh-to-hostname disabled  Forward SSH to hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these needs to be enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall enable openvpn&lt;br /&gt;
awall enable main&lt;br /&gt;
awall enable ping&lt;br /&gt;
awall enable ssh&lt;br /&gt;
awall enable ssh-to-hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of your awall directory should now look like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall/&lt;br /&gt;
├── main.json -&amp;gt; ./optional/main.json&lt;br /&gt;
├── openvpn.json -&amp;gt; ./optional/openvpn.json&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ping.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
├── ping.json -&amp;gt; ./optional/ping.json&lt;br /&gt;
├── private&lt;br /&gt;
│   ├── aliases.json&lt;br /&gt;
│   ├── base.json&lt;br /&gt;
│   └── custom-services.json&lt;br /&gt;
├── ssh-to-hostname.json -&amp;gt; ./optional/ssh-to-hostname.json&lt;br /&gt;
└── ssh.json -&amp;gt; ./optional/ssh.json&lt;br /&gt;
&lt;br /&gt;
2 directories, 13 files&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing policies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall translate --verify&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if everything goes well the output should be null.&lt;br /&gt;
&lt;br /&gt;
=== Activating the firewall ===&lt;br /&gt;
&lt;br /&gt;
Now that all our policies are verified for proper json we can activate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall activate&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load the firewall rules and show you a message to confirm. If by accident you made a mistake and lock yourself out you just have to wait for awall to disable itself again.&lt;br /&gt;
&lt;br /&gt;
== Finishing up ==&lt;br /&gt;
&lt;br /&gt;
=== Activating firewall rules at boot ===&lt;br /&gt;
&lt;br /&gt;
When awall has been properly activated it will generate a file with all iptables rules which iptables will read when its is started via openrc.&lt;br /&gt;
Make sure you have added iptables to an openrc runlevel. If using snat, also enable ipset for the masquerade set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add ipset&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow IPv4 forwarding ===&lt;br /&gt;
&lt;br /&gt;
To allow iptables to forward packets from one zone to the other we need to enable this at the iptables level.&lt;br /&gt;
&lt;br /&gt;
==== On the fly ====&lt;br /&gt;
&lt;br /&gt;
To enable it on the fly:&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -w net.ipv4.ip_forward=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enable within iptables tools (at boot) ====&lt;br /&gt;
&lt;br /&gt;
Add the following to:&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/conf.d/iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Enable/disable IPv4 forwarding with the rules&lt;br /&gt;
IPFORWARD=&amp;quot;yes&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[How-To Alpine Wall]]&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=31983</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=31983"/>
		<updated>2026-01-24T16:35:38Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: added redirect link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [https://git.alpinelinux.org/awall/about/ Alpine Wall User&#039;s Guide]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31982</id>
		<title>How-To Alpine Wall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31982"/>
		<updated>2026-01-24T16:21:16Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: additional changes by rewording sentence based on email from W. Michael Petullo &amp;lt;mike@flyn.org&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide shows how to configure a firewall using Alpine Wall (awall), a Linux firewall configuration tool, providing various benefits over plain iptables. [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide] is the official source for details about the syntax. &lt;br /&gt;
&lt;br /&gt;
The purpose of this page is to illustrate Alpine Wall (AWall) by example. This page explains AWall from the viewpoint of  {{pkg|Shorewall}}, a firewall configuration tool used in many applications. This comparison is meant to help readers who are familiar with Shorewall learn AWall. You should follow the AWall configuration examples. Use the Shorewall examples as contextual references, or ignore them, if unfamiliar with Shorewall.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
	&lt;br /&gt;
Install the {{pkg|awall}} package by running the following command:{{cmd|# apk add iptables awall}}&lt;br /&gt;
&lt;br /&gt;
Note that awall requires {{pkg|iptables}} but works with both backends [[nftables]] and legacy [[iptables]]. It does not interact with nftables directly.&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
The easier method for performing initial steps for running awall: {{cmd|# awall activate}} &lt;br /&gt;
The above command has special handling for the first run, when firewall is not yet enabled in the kernel. It performs the  below manual steps and also updates the default runlevel and files in {{Path|/etc/conf.d}}&lt;br /&gt;
&lt;br /&gt;
Use the below commands for performing initial setup manually. &lt;br /&gt;
* To update /etc/iptables: {{cmd|# awall translate}}&lt;br /&gt;
* To start the [[OpenRC]] services for iptables and load modules and rules for IPv4 and IPv6 {{cmd|&amp;lt;nowiki&amp;gt;# rc-service iptables start  &lt;br /&gt;
# rc-service ip6tables start &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration files ===&lt;br /&gt;
&lt;br /&gt;
Your [[Alpine Wall]] configuration files go in {{Path|/etc/awall/optional}}. From version 0.2.12 and later, Awall will look for &#039;&#039;Policy&#039;&#039; files in both the former and {{Path|/usr/share/awall/optional}}&lt;br /&gt;
Each such file is called a &#039;&#039;Policy&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may have multiple &#039;&#039;Policy&#039;&#039; files. It is useful to have separate files for eg. HTTP, FTP, etc.&lt;br /&gt;
The &#039;&#039;Policy(s)&#039;&#039; can be enabled or disabled by using the command: {{cmd|&amp;lt;nowiki&amp;gt;# awall [enable|disable]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An AWall &#039;&#039;Policy&#039;&#039; can contain definitions of:&lt;br /&gt;
* variables &#039;&#039;(like {{Path|/etc/shorewall/params}})&#039;&#039;&lt;br /&gt;
* zones &#039;&#039;(like {{Path|/etc/shorewall/zones}})&#039;&#039;&lt;br /&gt;
* interfaces &#039;&#039;(like {{Path|/etc/shorewall/interfaces}})&#039;&#039;&lt;br /&gt;
* policies &#039;&#039;(like {{Path|/etc/shorewall/policy}})&#039;&#039;&lt;br /&gt;
* filters and NAT rules &#039;&#039;(like {{Path|/etc/shorewall/rules}})&#039;&#039;&lt;br /&gt;
* services &#039;&#039;(like {{Path|/usr/share/shorewall/macro.HTTP}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Basic home firewall configuration ==&lt;br /&gt;
&lt;br /&gt;
The examples below show how to configure a basic home firewall using AWall. Note that AWall Policy files differ substantially from Shorewall&#039;s policy files in syntax and layout.&lt;br /&gt;
&lt;br /&gt;
=== Shorewall configuration ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have the following Shorewall configuration files in {{Path|/etc/shorewall/}}, which you want to convert to a [[#AWall configuration|configuration for AWall]].  {{cat|/etc/shorewall/zones|inet  ipv4&lt;br /&gt;
loc   ipv4}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/interfaces|inet  eth0&lt;br /&gt;
loc   eth1}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/policy|fw   all  ACCEPT&lt;br /&gt;
loc  inet ACCEPT&lt;br /&gt;
all  all  DROP}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/masq|eth0  0.0.0.0/0}}&lt;br /&gt;
&lt;br /&gt;
=== AWall configuration ===&lt;br /&gt;
&lt;br /&gt;
The equivalent AWall configuration that does the same thing as the above [[#Shorewall configuration|Shorewall example]] is given below.&lt;br /&gt;
&lt;br /&gt;
Create a new file called {{Path|/etc/awall/optional/home-policy.json}} and add the following content {{Cat|/etc/awall/optional/home-policy.json|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Home firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;inet&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;loc&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [&lt;br /&gt;
    { &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot; }&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The above configuration will:&lt;br /&gt;
* Create a description of your &#039;&#039;Policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;zones&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;snat&#039;&#039; &#039;&#039;(to masqurade the outgoing traffic)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;snat&#039;&#039;&#039; means &amp;quot;source NAT&amp;quot;. It does &amp;lt;u&amp;gt;not&amp;lt;/u&amp;gt; mean &amp;quot;static NAT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Tip| AWall has a built-in zone named &amp;quot;_fw&amp;quot; which is the &amp;quot;firewall itself&amp;quot;. This corresponds to the Shorewall &amp;quot;fw&amp;quot; zone.}}&lt;br /&gt;
&lt;br /&gt;
=== Activating/Applying a Policy ===&lt;br /&gt;
&lt;br /&gt;
After saving the &#039;&#039;Policy&#039;&#039; you can run the following commands to activate your firewall settings.&lt;br /&gt;
To listing available &#039;Policy(s)&#039; {{cmd|# awall list}} &lt;br /&gt;
To enable the &#039;Policy&#039; created in the previous section:{{cmd|# awall enable home-policy}}    &lt;br /&gt;
To generate firewall configuration from the &#039;Policy&#039; file and enable it i.e start the firewall: {{Cmd|# awall activate}}              &lt;br /&gt;
&lt;br /&gt;
If you have multiple policies, after enabling or disabling them, you need to always run {{Codeline|&#039;&#039;&#039;awall activate&#039;&#039;&#039;}} in order to update the iptables rules.&lt;br /&gt;
&lt;br /&gt;
== Advanced configuration ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have your {{Path|/etc/awall/optional/home-policy.json}} with your &amp;quot;Basic home firewall&amp;quot; settings, you could choose to modify that file to test the below examples. You could also create new files in {{Path|/etc/awall/optional/}} for testing some of the below examples.&lt;br /&gt;
&lt;br /&gt;
AWall already has a &amp;quot;service&amp;quot; definition list for several services like HTTP, FTP, SNMP, etc. &#039;&#039; in the file {{Path|/usr/share/awall/mandatory/services.json}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are adding the sample content given in this section to an already existing policy file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
AWall will &#039;&#039;(since v0.2.7)&#039;&#039; automatically log dropped packets.&lt;br /&gt;
&lt;br /&gt;
You could add the following row to the &amp;quot;policy&amp;quot; section in your &#039;&#039;Policy&#039;&#039; file in order to see the dropped packets.&lt;br /&gt;
&amp;lt;pre&amp;gt;{ &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Port forwarding ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have a local web server (192.168.1.10) that you want to make accessible from the &amp;quot;inet&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
With Shorewall you would have a rule like this in your {{Cat|/etc/shorewall/rules|&amp;lt;nowiki&amp;gt;#ACTION  SOURCE  DEST               PROTO  DEST PORT(S)    SOURCEPORT(S)    ORIGINALDEST&lt;br /&gt;
DNAT     inet     loc:192.168.1.10  tcp    80&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Lets configure our AWall &#039;&#039;Policy&#039;&#039; file likewise by adding the following content.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;APACHE&amp;quot;: &amp;quot;192.168.1.10&amp;quot;,&lt;br /&gt;
    &amp;quot;STATIC_IP&amp;quot;: &amp;quot;1.2.3.4&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;, &lt;br /&gt;
      &amp;quot;dnat&amp;quot;: &amp;quot;$APACHE&amp;quot; &lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see in the above example, we create a&lt;br /&gt;
* &amp;quot;variable&amp;quot; section where we specify some IP-addresses&lt;br /&gt;
* &amp;quot;filter&amp;quot; section where we do the actual port-forwarding (using the variables we just created and using some preexisting &amp;quot;services&amp;quot; definitions)&lt;br /&gt;
&lt;br /&gt;
If you need to forward to a different port (e.g. 8080) you can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dnat&amp;quot;: [&lt;br /&gt;
  {&amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &amp;quot;to-addr&amp;quot;: &amp;quot;$APACHE&amp;quot;, &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &amp;quot;to-port&amp;quot;: 8080 }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create your own service definitions ===&lt;br /&gt;
&lt;br /&gt;
{{Note| You can not override a &amp;quot;service&amp;quot; definition that comes from {{Path|/usr/share/awall/mandatory/services.json}}}}&lt;br /&gt;
&lt;br /&gt;
You can add your own service definitions into your &#039;&#039;Policy&#039;&#039; files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;service&amp;quot;: {  &lt;br /&gt;
  &amp;quot;openvpn&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inherit services or variables === &lt;br /&gt;
&lt;br /&gt;
You can import a &#039;&#039;Policy&#039;&#039; into other &#039;&#039;Policy&#039;&#039; files for inheriting services or variables definitions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;import&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Customize policy loading order ===&lt;br /&gt;
&lt;br /&gt;
By default policies are loaded on alphabetical order. The load order can be changed with the keywords &amp;quot;before&amp;quot; and &amp;quot;after&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;before&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;quot;after&amp;quot;: &amp;quot;someotherpolicy&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you end up in some kind of trouble, you might find some commands useful when debugging:&lt;br /&gt;
{{cmd|awall                 # (With no parameters) Shows some basic help about awall application&lt;br /&gt;
awall dump            # Dump definitions like zones and variables&lt;br /&gt;
iptables -L -n        # Show what&#039;s in &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
* [[Zero-To-Awall]]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-awall-on-alpine-linux/ How To Set Up a Firewall with Awall on Alpine Linux]&lt;br /&gt;
&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31981</id>
		<title>How-To Alpine Wall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31981"/>
		<updated>2026-01-24T06:35:17Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: updated instructions based on https://lists.alpinelinux.org/~alpine/devel/%3CaVhxrpww1wvEmBWB%40imp.flyn.org%3E#%3C7f95fffb-67ed-2ea8-95e0-e4794363bed9@alpinelinux.org%3E&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide] is the official source for details about the syntax. The purpose of this page is to illustrate Alpine Wall (AWall) by example. This page explains AWall from the viewpoint of a Shorewall user.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
	&lt;br /&gt;
Install the {{pkg|awall}} package by running the following command:{{cmd|# apk add iptables awall}}&lt;br /&gt;
&lt;br /&gt;
Note that awall requires {{pkg|iptables}} but works with both backends [[nftables]] and legacy [[iptables]]. It does not interact with nftables directly.&lt;br /&gt;
&lt;br /&gt;
== Configuration == &lt;br /&gt;
&lt;br /&gt;
The easier method for performing initial steps for running awall: {{cmd|# awall activate}} &lt;br /&gt;
The above command has special handling for the first run, when firewall is not yet enabled in the kernel. It performs the  below manual steps and also updates the default runlevel and files in {{Path|/etc/conf.d}}&lt;br /&gt;
&lt;br /&gt;
Use the below commands for performing initial setup manually. &lt;br /&gt;
* To update /etc/iptables: {{cmd|# awall translate}}&lt;br /&gt;
* To start the [[OpenRC]] services for iptables and load modules and rules for IPv4 and IPv6 {{cmd|&amp;lt;nowiki&amp;gt;# rc-service iptables start  &lt;br /&gt;
# rc-service ip6tables start &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Configuration files ===&lt;br /&gt;
&lt;br /&gt;
Your [[Alpine Wall]] configuration files go in {{Path|/etc/awall/optional}}. From version 0.2.12 and later, Awall will look for &#039;&#039;Policy&#039;&#039; files in both the former and {{Path|/usr/share/awall/optional}}&lt;br /&gt;
Each such file is called a &#039;&#039;Policy&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may have multiple &#039;&#039;Policy&#039;&#039; files. It is useful to have separate files for eg. HTTP, FTP, etc.&lt;br /&gt;
The &#039;&#039;Policy(s)&#039;&#039; can be enabled or disabled by using the command: {{cmd|&amp;lt;nowiki&amp;gt;# awall [enable|disable]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An AWall &#039;&#039;Policy&#039;&#039; can contain definitions of:&lt;br /&gt;
* variables &#039;&#039;(like {{Path|/etc/shorewall/params}})&#039;&#039;&lt;br /&gt;
* zones &#039;&#039;(like {{Path|/etc/shorewall/zones}})&#039;&#039;&lt;br /&gt;
* interfaces &#039;&#039;(like {{Path|/etc/shorewall/interfaces}})&#039;&#039;&lt;br /&gt;
* policies &#039;&#039;(like {{Path|/etc/shorewall/policy}})&#039;&#039;&lt;br /&gt;
* filters and NAT rules &#039;&#039;(like {{Path|/etc/shorewall/rules}})&#039;&#039;&lt;br /&gt;
* services &#039;&#039;(like {{Path|/usr/share/shorewall/macro.HTTP}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Basic home firewall ==&lt;br /&gt;
&lt;br /&gt;
The below example shows the &amp;quot;Basic home firewall&amp;quot; configuration for both Shorewall and AWall. Based on below example, it can be clearly seen that AWall &#039;&#039;Policy&#039;&#039; files are not equivalent to Shorewall&#039;s {{Path|/etc/shorewall/policy}} files. &lt;br /&gt;
&lt;br /&gt;
=== Shorewall configuration ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have the following Shorewall configuration: {{cat|/etc/shorewall/zones|inet  ipv4&lt;br /&gt;
loc   ipv4}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/interfaces|inet  eth0&lt;br /&gt;
loc   eth1}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/policy|fw   all  ACCEPT&lt;br /&gt;
loc  inet ACCEPT&lt;br /&gt;
all  all  DROP}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/masq|eth0  0.0.0.0/0}}&lt;br /&gt;
&lt;br /&gt;
=== AWall configuration ===&lt;br /&gt;
&lt;br /&gt;
The equivalent AWall configuration that does the same thing as the above Shorewall example is given below.&lt;br /&gt;
&lt;br /&gt;
Create a new file called {{Path|/etc/awall/optional/home-policy.json}} and add the following content {{Cat|/etc/awall/optional/home-policy.json|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Home firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;inet&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;loc&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [&lt;br /&gt;
    { &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot; }&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above configuration will:&lt;br /&gt;
* Create a description of your &#039;&#039;Policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;zones&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;snat&#039;&#039; &#039;&#039;(to masqurade the outgoing traffic)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;snat&#039;&#039;&#039; means &amp;quot;source NAT&amp;quot;. It does &amp;lt;u&amp;gt;not&amp;lt;/u&amp;gt; mean &amp;quot;static NAT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Tip| AWall has a built-in zone named &amp;quot;_fw&amp;quot; which is the &amp;quot;firewall itself&amp;quot;. This corresponds to the Shorewall &amp;quot;fw&amp;quot; zone.}}&lt;br /&gt;
&lt;br /&gt;
=== Activating/Applying a Policy ===&lt;br /&gt;
&lt;br /&gt;
After saving the &#039;&#039;Policy&#039;&#039; you can run the following commands to activate your firewall settings:&lt;br /&gt;
{{cmd|awall list                  # Listing available &#039;Policy(s)&#039; (This step is optional)&lt;br /&gt;
awall enable test-policy    # Enables the &#039;Policy&#039;&lt;br /&gt;
awall activate              # Genereates firewall configuration from the &#039;Policy&#039; files and enables it (starts the firewall)}}&lt;br /&gt;
&lt;br /&gt;
If you have multiple policies, after enabling or disabling them, you need to always run &#039;&#039;awall activate&#039;&#039; in order to update the iptables rules.&lt;br /&gt;
&lt;br /&gt;
== Advanced configuration ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have your {{Path|/etc/awall/optional/home-policy.json}} with your &amp;quot;Basic home firewall&amp;quot; settings, you could choose to modify that file to test the below examples.&lt;br /&gt;
&lt;br /&gt;
{{Tip|You could also create new files in {{Path|/etc/awall/optional/}} for testing some of the below examples}}&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
AWall will &#039;&#039;(since v0.2.7)&#039;&#039; automatically log dropped packets.&lt;br /&gt;
&lt;br /&gt;
You could add the following row to the &amp;quot;policy&amp;quot; section in your &#039;&#039;Policy&#039;&#039; file in order to see the dropped packets.&lt;br /&gt;
&amp;lt;pre&amp;gt;{ &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are adding the above content to an already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Port forwarding ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have a local web server (192.168.1.10) that you want to make accessible from the &amp;quot;inet&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
With Shorewall you would have a rule like this in your {{Path|/etc/shorewall/rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#ACTION  SOURCE  DEST               PROTO  DEST    SOURCE    ORIGINAL&lt;br /&gt;
#                                          PORT(S) PORT(S)   DEST&lt;br /&gt;
DNAT     inet     loc:192.168.1.10  tcp    80&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets configure our AWall &#039;&#039;Policy&#039;&#039; file likewise by adding the following content.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;APACHE&amp;quot;: &amp;quot;192.168.1.10&amp;quot;,&lt;br /&gt;
    &amp;quot;STATIC_IP&amp;quot;: &amp;quot;1.2.3.4&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;, &lt;br /&gt;
      &amp;quot;dnat&amp;quot;: &amp;quot;$APACHE&amp;quot; &lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see in the above example, we create a&lt;br /&gt;
* &amp;quot;variable&amp;quot; section where we specify some IP-addresses&lt;br /&gt;
* &amp;quot;filter&amp;quot; section where we do the actual port-forwarding (using the variables we just created and using some preexisting &amp;quot;services&amp;quot; definitions)&lt;br /&gt;
{{Note|If you are adding the above content to a already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
{{Tip|AWall already has a &amp;quot;service&amp;quot; definition list for several services like HTTP, FTP, SNMP, etc. &#039;&#039;(see {{Path|/usr/share/awall/mandatory/services.json}})&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
If you need to forward to a different port (e.g. 8080) you can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dnat&amp;quot;: [&lt;br /&gt;
  {&amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &amp;quot;to-addr&amp;quot;: &amp;quot;$APACHE&amp;quot;, &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &amp;quot;to-port&amp;quot;: 8080 }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create your own service definitions ===&lt;br /&gt;
&lt;br /&gt;
{{Note| You can not override a &amp;quot;service&amp;quot; definition that comes from {{Path|/usr/share/awall/mandatory/services.json}}}}&lt;br /&gt;
&lt;br /&gt;
You can add your own service definitions into your &#039;&#039;Policy&#039;&#039; files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;service&amp;quot;: {  &lt;br /&gt;
  &amp;quot;openvpn&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If you are adding the above content to a already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Inherit services or variables === &lt;br /&gt;
&lt;br /&gt;
You can import a &#039;&#039;Policy&#039;&#039; into other &#039;&#039;Policy&#039;&#039; files for inheriting services or variables definitions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;import&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Customize policy loading order ===&lt;br /&gt;
&lt;br /&gt;
By default policies are loaded on alphabetical order. The load order can be changed with the keywords &amp;quot;before&amp;quot; and &amp;quot;after&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;before&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;quot;after&amp;quot;: &amp;quot;someotherpolicy&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you end up in some kind of trouble, you might find some commands useful when debugging:&lt;br /&gt;
{{cmd|awall                 # (With no parameters) Shows some basic help about awall application&lt;br /&gt;
awall dump            # Dump definitions like zones and variables&lt;br /&gt;
iptables -L -n        # Show what&#039;s in &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
* [[Zero-To-Awall]]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-awall-on-alpine-linux/ How To Set Up a Firewall with Awall on Alpine Linux]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31980</id>
		<title>How-To Alpine Wall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=How-To_Alpine_Wall&amp;diff=31980"/>
		<updated>2026-01-24T06:04:44Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: removed wrong instructions based on email from  Kaarle Ritvanen in alpine-devel mailing list 8 days ago&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide] is the official source for details about the syntax. The purpose of this page is to illustrate Alpine Wall (AWall) by example. This page explains AWall from the viewpoint of a Shorewall user.&lt;br /&gt;
&lt;br /&gt;
== Configuration files ==&lt;br /&gt;
&lt;br /&gt;
Your [[Alpine Wall]] configuration files go in {{Path|/etc/awall/optional}}. From version 0.2.12 and later, Awall will look for &#039;&#039;Policy&#039;&#039; files in both the former and {{Path|/usr/share/awall/optional}}&lt;br /&gt;
Each such file is called a &#039;&#039;Policy&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may have multiple &#039;&#039;Policy&#039;&#039; files. It is useful to have separate files for eg. HTTP, FTP, etc.&lt;br /&gt;
The &#039;&#039;Policy(s)&#039;&#039; can be enabled or disabled by using the command: {{cmd|&amp;lt;nowiki&amp;gt;# awall [enable|disable]&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
An AWall &#039;&#039;Policy&#039;&#039; can contain definitions of:&lt;br /&gt;
* variables &#039;&#039;(like {{Path|/etc/shorewall/params}})&#039;&#039;&lt;br /&gt;
* zones &#039;&#039;(like {{Path|/etc/shorewall/zones}})&#039;&#039;&lt;br /&gt;
* interfaces &#039;&#039;(like {{Path|/etc/shorewall/interfaces}})&#039;&#039;&lt;br /&gt;
* policies &#039;&#039;(like {{Path|/etc/shorewall/policy}})&#039;&#039;&lt;br /&gt;
* filters and NAT rules &#039;&#039;(like {{Path|/etc/shorewall/rules}})&#039;&#039;&lt;br /&gt;
* services &#039;&#039;(like {{Path|/usr/share/shorewall/macro.HTTP}})&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Basic home firewall ==&lt;br /&gt;
&lt;br /&gt;
The below example shows the &amp;quot;Basic home firewall&amp;quot; configuration for both Shorewall and AWall. Based on below example, it can be clearly seen that AWall &#039;&#039;Policy&#039;&#039; files are not equivalent to Shorewall&#039;s {{Path|/etc/shorewall/policy}} files. &lt;br /&gt;
&lt;br /&gt;
=== Shorewall configuration ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have the following Shorewall configuration: {{cat|/etc/shorewall/zones|inet  ipv4&lt;br /&gt;
loc   ipv4}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/interfaces|inet  eth0&lt;br /&gt;
loc   eth1}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/policy|fw   all  ACCEPT&lt;br /&gt;
loc  inet ACCEPT&lt;br /&gt;
all  all  DROP}}&lt;br /&gt;
&lt;br /&gt;
{{cat|/etc/shorewall/masq|eth0  0.0.0.0/0}}&lt;br /&gt;
&lt;br /&gt;
=== AWall configuration ===&lt;br /&gt;
&lt;br /&gt;
The equivalent AWall configuration that does the same thing as the above Shorewall example is given below.&lt;br /&gt;
&lt;br /&gt;
Create a new file called {{Path|/etc/awall/optional/home-policy.json}} and add the following content {{Cat|/etc/awall/optional/home-policy.json|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Home firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;inet&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;loc&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [&lt;br /&gt;
    { &amp;quot;out&amp;quot;: &amp;quot;inet&amp;quot; }&lt;br /&gt;
  ]&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
The above configuration will:&lt;br /&gt;
* Create a description of your &#039;&#039;Policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;zones&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;policy&#039;&#039;&lt;br /&gt;
* Define &#039;&#039;snat&#039;&#039; &#039;&#039;(to masqurade the outgoing traffic)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;snat&#039;&#039;&#039; means &amp;quot;source NAT&amp;quot;. It does &amp;lt;u&amp;gt;not&amp;lt;/u&amp;gt; mean &amp;quot;static NAT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Tip| AWall has a built-in zone named &amp;quot;_fw&amp;quot; which is the &amp;quot;firewall itself&amp;quot;. This corresponds to the Shorewall &amp;quot;fw&amp;quot; zone.}}&lt;br /&gt;
&lt;br /&gt;
=== Activating/Applying a Policy ===&lt;br /&gt;
&lt;br /&gt;
After saving the &#039;&#039;Policy&#039;&#039; you can run the following commands to activate your firewall settings:&lt;br /&gt;
{{cmd|awall list                  # Listing available &#039;Policy(s)&#039; (This step is optional)&lt;br /&gt;
awall enable test-policy    # Enables the &#039;Policy&#039;&lt;br /&gt;
awall activate              # Genereates firewall configuration from the &#039;Policy&#039; files and enables it (starts the firewall)}}&lt;br /&gt;
&lt;br /&gt;
If you have multiple policies, after enabling or disabling them, you need to always run &#039;&#039;awall activate&#039;&#039; in order to update the iptables rules.&lt;br /&gt;
&lt;br /&gt;
== Advanced configuration ==&lt;br /&gt;
&lt;br /&gt;
Assuming you have your {{Path|/etc/awall/optional/home-policy.json}} with your &amp;quot;Basic home firewall&amp;quot; settings, you could choose to modify that file to test the below examples.&lt;br /&gt;
&lt;br /&gt;
{{Tip|You could also create new files in {{Path|/etc/awall/optional/}} for testing some of the below examples}}&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
AWall will &#039;&#039;(since v0.2.7)&#039;&#039; automatically log dropped packets.&lt;br /&gt;
&lt;br /&gt;
You could add the following row to the &amp;quot;policy&amp;quot; section in your &#039;&#039;Policy&#039;&#039; file in order to see the dropped packets.&lt;br /&gt;
&amp;lt;pre&amp;gt;{ &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;out&amp;quot;: &amp;quot;loc&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If you are adding the above content to an already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Port forwarding ===&lt;br /&gt;
&lt;br /&gt;
Let&#039;s suppose you have a local web server (192.168.1.10) that you want to make accessible from the &amp;quot;inet&amp;quot;.&amp;lt;br&amp;gt;&lt;br /&gt;
With Shorewall you would have a rule like this in your {{Path|/etc/shorewall/rules}}:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#ACTION  SOURCE  DEST               PROTO  DEST    SOURCE    ORIGINAL&lt;br /&gt;
#                                          PORT(S) PORT(S)   DEST&lt;br /&gt;
DNAT     inet     loc:192.168.1.10  tcp    80&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets configure our AWall &#039;&#039;Policy&#039;&#039; file likewise by adding the following content.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;APACHE&amp;quot;: &amp;quot;192.168.1.10&amp;quot;,&lt;br /&gt;
    &amp;quot;STATIC_IP&amp;quot;: &amp;quot;1.2.3.4&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    { &amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;, &lt;br /&gt;
      &amp;quot;dnat&amp;quot;: &amp;quot;$APACHE&amp;quot; &lt;br /&gt;
      }&lt;br /&gt;
    ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see in the above example, we create a&lt;br /&gt;
* &amp;quot;variable&amp;quot; section where we specify some IP-addresses&lt;br /&gt;
* &amp;quot;filter&amp;quot; section where we do the actual port-forwarding (using the variables we just created and using some preexisting &amp;quot;services&amp;quot; definitions)&lt;br /&gt;
{{Note|If you are adding the above content to a already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
{{Tip|AWall already has a &amp;quot;service&amp;quot; definition list for several services like HTTP, FTP, SNMP, etc. &#039;&#039;(see {{Path|/usr/share/awall/mandatory/services.json}})&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
If you need to forward to a different port (e.g. 8080) you can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;dnat&amp;quot;: [&lt;br /&gt;
  {&amp;quot;in&amp;quot;: &amp;quot;inet&amp;quot;, &amp;quot;dest&amp;quot;: &amp;quot;$STATIC_IP&amp;quot;, &amp;quot;to-addr&amp;quot;: &amp;quot;$APACHE&amp;quot;, &amp;quot;service&amp;quot;: &amp;quot;http&amp;quot;, &amp;quot;to-port&amp;quot;: 8080 }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create your own service definitions ===&lt;br /&gt;
&lt;br /&gt;
{{Note| You can not override a &amp;quot;service&amp;quot; definition that comes from {{Path|/usr/share/awall/mandatory/services.json}}}}&lt;br /&gt;
&lt;br /&gt;
You can add your own service definitions into your &#039;&#039;Policy&#039;&#039; files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;service&amp;quot;: {  &lt;br /&gt;
  &amp;quot;openvpn&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Note|If you are adding the above content to a already existing file, then make sure you add &amp;quot;,&amp;quot; signs where they are needed!}}&lt;br /&gt;
&lt;br /&gt;
=== Inherit services or variables === &lt;br /&gt;
&lt;br /&gt;
You can import a &#039;&#039;Policy&#039;&#039; into other &#039;&#039;Policy&#039;&#039; files for inheriting services or variables definitions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;import&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Customize policy loading order ===&lt;br /&gt;
&lt;br /&gt;
By default policies are loaded on alphabetical order. The load order can be changed with the keywords &amp;quot;before&amp;quot; and &amp;quot;after&amp;quot;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;before&amp;quot;: &amp;quot;myfirewall&amp;quot;&lt;br /&gt;
&amp;quot;after&amp;quot;: &amp;quot;someotherpolicy&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If you end up in some kind of trouble, you might find some commands useful when debugging:&lt;br /&gt;
{{cmd|awall                 # (With no parameters) Shows some basic help about awall application&lt;br /&gt;
awall dump            # Dump definitions like zones and variables&lt;br /&gt;
iptables -L -n        # Show what&#039;s in &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [https://git.alpinelinux.org/awall/about/ Alpine Wall User Guide]&lt;br /&gt;
* [[Zero-To-Awall]]&lt;br /&gt;
* [https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-awall-on-alpine-linux/ How To Set Up a Firewall with Awall on Alpine Linux]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Firewall]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Talk:Zram&amp;diff=31949</id>
		<title>Talk:Zram</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Talk:Zram&amp;diff=31949"/>
		<updated>2026-01-12T12:42:51Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: replied Macmpi&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; Advanced setups may also add these parameters to /etc/sysctl.conf as follows&lt;br /&gt;
Would be nice to add more explanations and references (like [https://wiki.archlinux.org/title/Zram#Optimizing_swap_on_zram this]?).&lt;br /&gt;
[[User:Macmpi|Macmpi]] ([[User talk:Macmpi|talk]]) 12:50, 11 Jan 2025 (UTC)&lt;br /&gt;
:Hi [[User:Macmpi|Macmpi]], In the past, just like this page, i moved or re-arranged existing content on the wiki from various pages. Most of these content move/changes were made by me after testing the instructions, but i was not aware of their source. I fully agree that quoting sources is quite important in technical documentation like wiki. In future, i&#039;ll add sources. Thanks for the note. -[[User:Prabuanand|Prabuanand]] ([[User talk:Prabuanand|talk]]) 12:42, 12 January 2026 (UTC)&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Prabuanand&amp;diff=31946</id>
		<title>User:Prabuanand</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Prabuanand&amp;diff=31946"/>
		<updated>2026-01-11T18:02:48Z</updated>

		<summary type="html">&lt;p&gt;Prabuanand: fixed url typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;http://git.sr.ht/~prabuanand/dotfiles&lt;br /&gt;
&lt;br /&gt;
==Stuff to watch==&lt;br /&gt;
[[Special:Patroller|Unpatrolled edits]]&lt;br /&gt;
Most recent unpatrolled new pages (ideally there should be none): {{Special:NewPages/limit=50,hidepatrolled}}&lt;br /&gt;
&lt;br /&gt;
[[Special:BrokenRedirects|List of broken redirects]] (there should be none)&lt;br /&gt;
&lt;br /&gt;
[[Special:DoubleRedirects|List of double redirects]] (there should be none)&lt;br /&gt;
&lt;br /&gt;
[[Special:ListDuplicatedFiles|List of duplicate files]] (there should be none)&lt;br /&gt;
&lt;br /&gt;
[https://wiki.alpinelinux.org/w/index.php?target=irc%3A%2F%2F*&amp;amp;title=Special%3ALinkSearch All irc:// hyperlinks]. (there should be none)&lt;br /&gt;
&lt;br /&gt;
[[Special:TrackingCategories|Pages that mediawiki has marked as broken in some way]] (there should be none)&lt;br /&gt;
&lt;br /&gt;
[[Special:RecentChanges|250 most recent wiki edits]]&lt;br /&gt;
&lt;br /&gt;
==To-do==&lt;br /&gt;
&lt;br /&gt;
[[Special:WhatLinksHere/Template:Dead_link|Pages which contain dead links]] &lt;br /&gt;
&lt;br /&gt;
[[Special:WhatLinksHere/Template:Obsolete|Obsolete pages]] (Need to go through and RfD some of these)&lt;br /&gt;
&lt;br /&gt;
[[Special:WhatLinksHere/Template:Insecure_url|Pages which contain links to unencrypted content]] (Some sites stubbornly refuse to join the current century)&lt;br /&gt;
&lt;br /&gt;
[[Special:WhatLinksHere/Template:Delete|RfDs]] (I don&#039;t have access to deal with these)&lt;br /&gt;
&lt;br /&gt;
[[Special:WantedPages|List of non-existing pages that are linked to]]&lt;br /&gt;
&lt;br /&gt;
[https://wiki.alpinelinux.org/w/index.php?target=http%3A%2F%2F*&amp;amp;title=Special%3ALinkSearch All http:// hyperlinks]. All of these need to be checked to see if they can be rewritten to https://&lt;br /&gt;
&lt;br /&gt;
[https://wiki.alpinelinux.org/w/index.php?target=ftp%3A%2F%2F*&amp;amp;title=Special%3ALinkSearch All ftp:// hyperlinks]. All of these need to be check to see if an sftp:// or https:// version is available.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.alpinelinux.org/w/index.php?target=svn%3A%2F%2F*&amp;amp;title=Special%3ALinkSearch All svn:// hyperlinks]. Old Alpine SVN links have gotta go!&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
[[Special:LinkSearch|External link seach]]&lt;br /&gt;
&lt;br /&gt;
[[Special:AllPages/Template:|List of all templates]]&lt;br /&gt;
&lt;br /&gt;
[[Special:ExpandTemplates|Template wikimarkup expansion tool]]&lt;br /&gt;
&lt;br /&gt;
[[Special:Redirect|Redirect by file, user, page, revision, or log ID]]&lt;br /&gt;
&lt;br /&gt;
[[Special:AbuseFilter|Description of automatic abuse filtering]] (because I always forget, and it would be nice to be able to explain to new wiki users why exactly their posts are getting denied)&lt;br /&gt;
&lt;br /&gt;
[[Special:Random|Go to a completely random page.]] This is both fun and useful!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Logs/Stats==&lt;br /&gt;
&lt;br /&gt;
[[Special:BlockList]]&lt;br /&gt;
&lt;br /&gt;
[[Special:AbuseLog]]&lt;br /&gt;
&lt;br /&gt;
[[Special:Statistics]]&lt;/div&gt;</summary>
		<author><name>Prabuanand</name></author>
	</entry>
</feed>