Alpine Linux
Alpine Linux is a lightweight Linux distribution based on musl libc and Busybox.
This distribution is commonly found as the base OS for container images due to its small footprint. It's also an attractive option as a minimal Linux distribution since everything is kept minimalistic (no systemd).
Package Management
Packages are handled using the apk
utility.
Command | Description |
---|---|
apk update
|
Update repo metadata |
apk upgrade
|
Upgrades all installed packages on the system |
apk search $package
|
Search for a specific package |
apk add $package [$package2 ...]
|
Installs or updates the packages |
apk add --no-cache $packages
|
Install without relying on any local caches (otherwise, you may need to delete /var/cache/apk/* to maintain small container/VM images)
|
apk add --update-cache $packages
|
Update metadata first before installing or updating packages. |
apk add --virtual=$name $packages
|
Install packages under a virtual package name. All packages installed will be collected in this virtual package name. This is useful if you need to later uninstall this collection of packages as you only need to uninstall the virtual package. |
apk del $package
|
Uninstalls a package |
apk del --purge $name
|
Uninstalls packages including all configuration files and any other files from cache. |
Service Management
Command | Description |
---|---|
rc-status
|
Show the current runlevel |
rc-status --list
|
Show all available runlevels |
rc $runlevel
|
Change the current runlevel |
rc-service --list
|
List all services |
rc-update add $service [$runlevel]
|
Enable a service on the specified runlevel (or default if not given) |
rc-update del $service
|
Remove the service from the default runlevel |
rc-service $service start
|
Start a service |
rc-service $service restart
|
Restart a service |
rc-service $service stop
|
Stop a service |
Tasks
Removing unnecessary firmware files
Alpine Linux installs a bunch of unnecessary firmware packages. You can remove these by running:
# apk add linux-firmware-none
Update Kernel parameters
Edit /etc/update-extlinux.conf
, and change the value at default_kernel_opts
.
Run update-extlinux
to update grub.
Set a static IP address
Network configuration in Alpine Linux is set in /etc/network/interfaces
.
If you are using DHCP:
auto eth0
iface eth0 inet dhcp
If you want to set a static IP address:
auto eth0
iface eth0 inet static
address 10.1.2.101/22
gateway 10.1.1.1
hostname alpine-vm1
Apply changes by restarting networking:
# /etc/init.d/networking restart
## or with service
# service networking restart
See Also
- https://wiki.alpinelinux.org/wiki/Main_Page
- https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management