Created
October 1, 2026 06:41
-
-
Save anthumchris/75a475db3974b38b95aa2623063b328d to your computer and use it in GitHub Desktop.
Alpine Linux apk add package without root as unprivileged user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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" "$@" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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