Skip to content

Instantly share code, notes, and snippets.

@anthumchris
Created October 1, 2026 06:41
Show Gist options
  • Select an option

  • Save anthumchris/75a475db3974b38b95aa2623063b328d to your computer and use it in GitHub Desktop.

Select an option

Save anthumchris/75a475db3974b38b95aa2623063b328d to your computer and use it in GitHub Desktop.
Alpine Linux apk add package without root as unprivileged user
## Install packages locally without doas/sudo
APK_LOCAL="$HOME/apk"
export PATH="$APK_LOCAL/bin:$APK_LOCAL/sbin:$APK_LOCAL/usr/bin:$APK_LOCAL/usr/sbin:$PATH"
apk-local() {
if [ ! -f "$APK_LOCAL/lib/apk/db/installed" ]; then
mkdir -p "$APK_LOCAL/etc/apk"
ln -s /etc/apk/keys "$APK_LOCAL/etc/apk/keys"
ln -s /etc/apk/repositories "$APK_LOCAL/etc/apk/repositories"
apk --root "$APK_LOCAL" --initdb --usermode add &>/dev/null
fi
apk --root "$APK_LOCAL" "$@"
}
apk-local add fastfetch
which fastfetch
fastfetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment