Skip to content

Alpine Linux

Reference guide for Alpine Linux covering package management, OpenRC service management, and user administration.

Alpine Linux Wiki

Package Management

Alpine Linux uses apk as its package manager.

Update package index
apk update
Install a package
apk add <package>
Remove a package
apk del <package>
Search for a package
apk search <keyword>
List installed packages
apk info
Upgrade all packages
apk upgrade

Service Management

Alpine Linux uses OpenRC for service management.

Enable a service at boot
rc-update add <service> default
Disable a service
rc-update del <service> default
Start a service
rc-service <service> start
Stop a service
rc-service <service> stop
Restart a service
rc-service <service> restart
Check service status
rc-service <service> status
List all services and their state
rc-status

User Management

Alpine ships with BusyBox utilities. The adduser syntax differs slightly from GNU/Linux distributions.

Create a system user with no login shell
adduser -D -g 'Full Name' username
Set a password for a user
passwd username
Unlock a user account
passwd -u username

SSH Server

Install and enable OpenSSH
apk add openssh
rc-update add sshd default
rc-service sshd start

The SSH daemon configuration is at /etc/ssh/sshd_config.

Authorized keys for a user go in ~/.ssh/authorized_keys with permissions 600, and the .ssh directory must be 700.

Set up authorized_keys for a user
mkdir -p /home/username/.ssh
chmod 700 /home/username/.ssh
echo "ssh-ed25519 AAAA... comment" >> /home/username/.ssh/authorized_keys
chmod 600 /home/username/.ssh/authorized_keys
chown -R username:username /home/username/.ssh

Timezone

Set timezone to Asia/Tokyo
apk add tzdata
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
echo "Asia/Tokyo" > /etc/timezone