apk(8)
π apk(8) β Alpine Package Keeper πΈ
okay bestie, buckle up, because this is the page for apk itself β yes, the manual page for the whole apk(8) situation, the main character of Alpine package management. Everything else gets its own page, so think of this one as the group chat admin π
β¨ SYNOPSIS β¨
apk [<global options>...] command [<options>...] [<arguments>...]
π¦ DESCRIPTION π¦
apk manages the packages installed on your system. The whole set of top-level constraints on system packages is called the world (go read apk-world(5) for that whole lore, iykyk).
apk has a bunch of sub-commands for querying and manipulating the world and package repositories. Like, a lot of sub-commands. We'll get to them π
Every single apk command that modifies the database gets logged to /var/log/apk.log. So yes, it remembers things, no cap.
By default apk is non-interactive. If you wanna change that default to be interactive, peep the FILES section or just use --interactive.
Heads up: only global options should be given before the command. For backwards compatibility apk makes a best-effort attempt to parse applet-specific options before the command, but that's deprecated and subject to being removed. So don't get attached to it, bestie π
π COMMANDS π
Every command has its own detailed manual page, so if you're obsessed with one in particular, go read its own page for the full tea.
π PACKAGE INSTALLATION AND REMOVAL
apk-add(8)β add or modify constraints in world and commit the changes β¨apk-del(8)β remove constraints from world and commit the changes ποΈ
π§ SYSTEM MAINTENANCE
apk-fix(8)β fix, reinstall or upgrade packages without modifying worldapk-update(8)β update the repository indexesapk-upgrade(8)β install the upgrades available from repositoriesapk-cache(8)β manage the local package cache
π₯ QUERYING PACKAGE INFORMATION
apk-query(8)β query information about packages by various criteriaapk-list(8)β list packages matching a pattern or other criteriaapk-dot(8)β render dependencies as graphviz graphs (graph girlies rise π«Ά)apk-policy(8)β show repository policy for packagesapk-search(8)β search for packages by name or descriptionapk-info(8)β give detailed information about packages or repositories
π REPOSITORY AND PACKAGE MAINTENANCE
apk-mkndx(8)β create repository index (v3) file from packagesapk-mkpkg(8)β create package (v3)apk-index(8)β create repository index (v2) file from packagesapk-fetch(8)β download packages from repositories to a local directoryapk-manifest(8)β show checksums of package contentsapk-extract(8)β extract package file contentsapk-verify(8)β verify package integrity and signatureapk-adbsign(8)β sign, resign or recompress v3 packages and indexes
π MISCELLANEOUS
apk-audit(8)β audit system for changesapk-stats(8)β show statistics about repositories and installationsapk-version(8)β compare package versions or perform tests on version stringsapk-adbdump(8)β dump v3 files in textual representationapk-adbgen(8)β generate v3 files from text representationapk-convdb(8)β convert v2 installed database to v3 formatapk-convndx(8)β convert v2 indexes to v3 format
πΈ OPTION SYNTAX πΈ
okay this part is important so listen up π
The BOOL argument for options is either 'yes' or 'no'. The AUTO argument for options is 'yes', 'no' or 'auto'. What the default value actually is depends on the specific option, so it's giving "it varies."
For options that take an AUTO or BOOL argument, the argument must be given in the --option=argument format. That means the --option argument format is not supported. Sorry babe π
On top of that, these little aliases exist:
--optionequals--option=yes--no-optionequals--option=no
β GLOBAL OPTIONS β
These are available for all commands, no matter which one you pick. Slay.
--allow-untrustedβ install packages with an untrusted signature, or with no signature at all π--arch ARCHβ temporarily override architectures. The first--archyou give becomes the primary architecture, and it's used to work out the paths where package indexes get downloaded from. Any additional architectures you list specify compatible packages that are considered for installation.
When you use it together with --root, the architecture also gets saved.
--cache[=BOOL]β when disabled, prevents using any local cache paths.--cache-dir CACHEDIRβ temporarily override the cache directory.CACHEDIRis treated relative to theROOT.--cache-max-age AGEβ maxAGE(in minutes) for an index in the cache before it gets refreshed.0means always refresh.--cache-packages[=BOOL]β store a copy of packages in the cache at installation time. Enabled automatically if the/etc/apk/cachesymlink exists.--cache-predownload[=BOOL]β download the needed packages to the cache before starting to commit a transaction. Requires the cache to be configured to actually be functional. Implies--cache-packages.--check-certificate[=BOOL]β when disabled, omits validation of the HTTPS server certificate.--force,-fβ enable selected--force-*options (deprecated β οΈ).--force-binary-stdoutβ continue even if binary data is gonna get printed to the terminal.--force-broken-worldβ DANGEROUS: delete world constraints until a solution without conflicts is found. This does not allow installing packages with unsatisfiable dependencies, and it's mainly intended for initramfs boot β it's implied by--initramfs-diskless-boot. The primary purpose is to let run-from-tmpfs systems boot if the media was upgraded and some packages are no longer available in the new release.
APK will try to determine which world constraints are causing the conflicting dependencies, and start disabling world constraints in that order until a satisfiable set of constraints is left. Using this switch on a hard disk installation will likely result in unexpected removal of some packages. If you're uncertain, use it with --interactive or --simulate first. fr fr, be careful π
--force-missing-repositoriesβ continue even if some of the repository indexes aren't available.--force-no-chrootβ disable chroot for scripts. This can be used for rootfs creation when chroot isn't available. Scripts running outside a chroot environment may modify and damage the host system. π--force-non-repositoryβ continue even if packages may be lost on reboot. This can happen when running in run-from-tmpfs mode and installing a non-repository package.--force-old-apkβ continue even if packages use unsupported features.--force-overwriteβ overwrite files in other packages.--force-refreshβ do not use cached files (local or from proxy).--help,-hβ print the list of all commands with descriptions.--interactive[=AUTO]β determine if questions can be asked before performing certain operations. In auto mode, interactive mode is enabled if running on a tty. Defaults tono, orautoif/etc/apk/interactiveexists.--keys-dir KEYSDIRβ override the default system trusted keys directories. If specified, only this directory is processed. TheKEYSDIRis treated relative toROOT.--legacy-info[=BOOL]β print output from theinfoapplet in legacy format or the newqueryformat. Defaults tonocurrently, but the default is subject to change toyesin a future release.--logfile[=BOOL]β if turned off, disables the writing of the log file.--network[=BOOL]β if turned off, does not use the network. The packages from network repositories in the cache are used.--preserve-env[=BOOL]β allow passing the user environment down to scripts (excluding variables starting withAPK_, which are reserved).--pretty-print[=AUTO]β determine if output should be stylized to be human readable. Defaults toauto, which resolves toyesif running on a tty. π--preupgrade-depends DEPSβ add or modify preupgrade dependencies. The preupgrade dependencies are used to match installed packages that are eligible for preupgrade. E.g.'apk-tools'will always preupgrade the'apk-tools'package, but'baselayout<2'would preupgrade the'baselayout'only if the installed version of baselayout is less than 2 and an upgrade is available. See alsoapk-upgrade(8).--print-archβ print the default arch and exit.--progress[=AUTO]β enable or disable the progress bar. Defaults toauto, which resolves toyesif running on a tty.--progress-fd FDβ write progress to the specified file descriptor.--purge[=BOOL]β purge modified configuration and cached packages. Enables deletion of modified configuration files on package removal. On cache clean action, this enables deletion of unneeded cached packages (uninstalled packages on tmpfs installations, or all packages on disk installations).--quiet,-qβ print less information.--repositories-file REPOFILEβ override system repositories, seeapk-repositories(5). Specifying this option overrides the normal repositories file and therepositories.ddirectory processing. The givenREPOFILEis relative to the startup directory sinceapk 2.12.0_rc2.--repository,-X REPOβ specify an additional package repository.apk-repositories(5)specified commands are not parsed (use--repository-configfor that). Additionally, relative paths are accepted and interpreted relative to the startup directory.--repository-config REPOCONFIGβ specify additional package repository configuration. TheREPOCONFIGis parsed exactly the same way as if it was read from anapk-repositories(5)specified.listfile.--root,-p ROOTβ manage the file system atROOT.--root-tmpfs[=AUTO]β specify if theROOTis a temporary filesystem. Defaults toauto, which determines the filesystem type automatically.
This affects:
- reading and creation of the
'installed'index in the cache - purging of packages in cache
- safety checks to not install non-repository packages
--sync[=AUTO]β determine if filesystem caches should be committed to disk. Defaults toauto, which resolves toyesif--rootis not specified, the database is not in usermode, and it's running on the root pid namespace (so, not containerized).--timeout TIMEβ timeout network connections if no progress is made inTIMEseconds. The default is60seconds. β°--update-cache,-Uβ alias for'--cache-max-age 0'.--uvol-manager UVOLβ specify the OpenWRT uvol volume manager executable location.--verbose,-vβ print more information (can be specified twice π).--version,-Vβ print program version and exit.--wait TIMEβ wait forTIMEseconds to get an exclusive repository lock before failing.
πΎ COMMIT OPTIONS
Okay bestie, these are the options that work on every single command that commits the database. Like, if it's writing to the DB, these apply. Periodt.
--clean-protected[=BOOL]β turn this off and apk will not create those.apk-newfiles in your configuration directories. So basically it stops dropping new config files next to your old ones. Handle with care, mwah π--commit-hooks[=BOOL]β disabled means it skips the pre/post hook scripts entirely (but NOT the other scripts, so don't get it twisted π).--initramfs-diskless-bootβ this one's for initramfs when it's out there recreating the root tmpfs. It enables selected force options to minimize failure, and it disables commit hooks, among other features. Very niche, very demure β¨--overlay-from-stdinβ reads a list of overlay files from stdin. Normally this is used only during initramfs when booting a run-from-tmpfs installation. iykyk π«Ά--scripts[=BOOL]β disabled means no scripts execute at all. Super useful for extracting a system image for a different architecture on an alternative ROOT. Lowkey a lifesaver for cross-arch stuff π§--simulate[=BOOL],-sβ simulates the operation you asked for without actually changing anything π. The database gets opened in read only mode, and auto-updating of indexes is disabled. Pro tip from the manpage itself: you may want to runapk updatebefore running a simulation so you know it's working with up-to-date repository indexes. No cap, do that π
π¦ GENERATION OPTIONS
These are for all the commands that generate APKv3 files. Making files? This is your section, bestie.
--compression,-cALGORITHM[:LEVEL]` β compresses the file with the given ALGORITHM and LEVEL. The supported algorithms are honestly a whole vibe:nonedeflate(level 1-9)zstd(level 1-22)
--sign-keyKEYFILE β signs the file with a private key in the specified KEYFILE. Secure the bag π
π± ENVIRONMENT
The variables apk reads, aka the vibes it picks up from your shell:
APK_CONFIGβ overrides the default config file name. See/etc/apk/configπLANGβ used to determine if UTF-8 is supported, and sets the default progress character accordingly πSOURCE_DATE_EPOCHβ seeapk-index(8)β¨TERMβ used to determine if the terminal is dumb or not. On dumb terminals the progress bar is not enabled by default. Sad but fair π
π Variables to configure built-in libfetch
Networking bestie section, let's go:
FETCH_BIND_ADDRESSβ a local IP address that libfetch will bind all the sockets it creates to. Can be useful for source routing. Fancy πNETRCβ specifies the.netrcfile to read for authentication secrets. If you don't set it, it defaults to$HOME/.netrcπ«ΆHTTP_AUTHHTTP_REFERERHTTP_USER_AGENTβ these three let you specify a custom HTTP-level Authorization, Referer or User-Agent header. Customize away πHTTP_PROXY,http_proxyHTTPS_PROXY,https_proxyβ if set, these should contain the proxy URL for http and https connections respectively. Yes both cases, they're not out here being picky β¨HTTP_PROXY_AUTHβ specifies a HTTP Proxy-Authorization header. Used only if the connection is established through a configured HTTP proxy. Conditional queen πNO_PROXY,no_proxyβ comma-separated list of domain extensions or CIDR notation IP addresses that should never use a proxy. Important caveat incoming: this is used explicitly to test the URL hostname portion only. So specifying an IP address or CIDR block will not match a DNS name that resolves to that IP address. Read that twice, bestie πSSL_CLIENT_CERT_FILESSL_CLIENT_KEY_FILEβ override the default SSL client certificate and corresponding private key filename πSSL_NO_VERIFY_HOSTNAMEβ if set to anything at all, disables the server certificate name verification. Danger vibes, use with intention π
π§ Environment for the scripts APK executes
Normally apk executes scripts with a sanitized, minimal environment containing only PATH. See also --preserve-env if you wanna pass along extra environment variables πΈ
Before executing a script, apk sets the working directory as ROOT and performs a chroot β unless --force-no-chroot is specified. Either way, the script's working directory should be treated as the system root. Don't forget that, fr fr π«Ά
The environment variables that APK itself defines are:
APK_PACKAGEβ the package name (package scripts only) π¦APK_SCRIPTβ set to one of the package or commit script types. Use this to figure out the script hook type if you need to. And listen: the filename ($0) is not reliable, because apk prefers to execute package scripts from a memfd file. Iconic but chaotic π
π FILES
βοΈ Configuration files
/etc/apk/config/lib/apk/config
These are the default global options. Only the first file existing in the above list is read and parsed. The one in /lib is meant for distribution default options, which can then be overridden by the user with the file in /etc. See also the APK_CONFIG environment variable π
A configuration file contains one long option per line. For example:
no-cache
timeout 120
/etc/apk/interactiveβ if this file exists, it defaults--interactivetoauto. Cute little presence flag β¨
ποΈ Configuration files (relative to --root)
/etc/apk/archβ the CPU architecture for this database. Seeapk-package(5)section on package metadata fieldarchfor the list π/etc/apk/cacheβ this is expected to be a symlink to the directory that apk will use as the package cache. See also/var/cache/apkbelow, plusapk-cache(5)andapk-cache(8)π«Ά/etc/apk/commit_hooks.d/*/lib/apk/commit_hooks.d/*
Hook scripts, and they're dramatic: they run before anything has been written to the filesystem, and again after all the changes have been committed. The script gets the stage name as an argument (pre-commit or post-commit). And if the script returns failure during the pre-commit stage, the commit is aborted β no takebacks π€
See also the ENVIRONMENT section for the environment variables.
If --no-scripts or --no-commit-hooks is specified, these hook scripts are not executed. Periodt.
/etc/apk/keys/lib/apk/keys
Directories for trusted signing keys π. They're enumerated in the order above, and once a given filename is seen, any file of the same name in subsequent directories is ignored. First come, first served π
/etc/apk/protected_paths.d/*.listβ configuration files that specify how to treat changes to specified directory or file masks. The file format is further documented inapk-protected_paths(5)π/etc/apk/repositories/etc/apk/repositories.d/*.list/lib/apk/repositories.d/*.list
Configuration files that specify repositories π. These directories are enumerated in the order above, and once a given filename is seen, any file of the same name in subsequent directories is ignored. See apk-repositories(5) for details πΈ
/etc/apk/worldβ top level requirements and constraints on what should be installed. Seeapk-world(5)for details π
π Configuration files for built-in libfetch
/etc/apk/ca.pemβ the CA certificate store bundle for verifying server certificates. If it's not present, the default system CA store is used instead π/etc/apk/crl.pemβ the CRL store to check the server certificates against π/etc/apk/cert.keyβ client certificate private key ποΈ/etc/apk/cert.pemβ client certificate to use for authentication β¨
π₯οΈ System files and directories
/lib/apk/db/lockβ a lock file, there to allow only one concurrent write transaction on the system. One at a time, bestie π ββοΈ/lib/apk/db/installedβ the database of installed packages and their contents π¦/lib/apk/db/scripts.tar/lib/apk/db/scripts.tar.gz
The collection of all package scripts from currently installed packages ποΈ
/lib/apk/db/triggersβ the list of triggers rules for currently installed packages β‘/lib/apk/db-uvolβ a database symlink or a directory with a similar structure as/lib/apk/db/, but used for package content when managed using the OpenWRT uvol volume manager π/lib/apk/execβ the temporary directory for extraction and execution of package scripts and triggers π§/var/log/apk.logβ the log file for changes done to the system π/var/cache/apkβ if the/etc/apk/cachesymlink does not exist or is dangling, this directory is used as a cache for repository indices ποΈ
β NOTES
This apk has coffee making abilities.
Yes, that's literally what it says. Not me making things up, bestie β it's in the actual manual page. Iconic. Legendary. Never been done before. πββ¨
πΈ And that's a wrap on apk(8), bestie! This page is Β© the Alpine Linux project, dated 2026-11-02 β go forth and slay your packages π
ππ¦
π¦ where this page comes from
- arch rolling: apk-tools 3.0.9-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms