In this article, I'll be sharing a few tips on using Alpine Linux, a GNU/Linux distribution renowned for its small size, simplicity, and security. Unlike most other distributions, it doesn't use systemd which is quite rare these days. I've started using it for several different applications and services, and I must say I've been rather taken with its qualities. I'll be using this page as a reminder, in the hope that it will be useful to others.
root@host:~# apk add --upgrade apk-tools && apk upgrade --available
root@host:~# apk add vim
root@host:~# apk add python3
Create and activate a virtual environment:
host:~$ python -m venv .web3
host:~$ source .web3/bin/activate
Install pip in the virtual environment and check the version:
(.web3) host:~$ python -m ensurepip
(.web3) host:~$ python -m pip --version
Using Cron in Alpine Linux is quite special, especially if you're used to using Debian. Let's see how it works. For this example, let's say wa want to configure crond to run a python script (/root/script.py in this case) every 5 minutes.
root@host:~# mkdir /etc/periodic/5min
*/5 * * * * run-parts /etc/periodic/5min
#!/bin/sh
/root/script.py
root@host:~# chmod +x /etc/periodic/5min/pscript
root@host:~# run-parts --test /etc/periodic/5min/
root@host:~# rc-service crond start && rc-update add crond
If you're installing Alpine Linux in a virtual machine in a VMware ESXi environment, it's recommended to install VMware Tools for optimum performance and functionality.
#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.19/main
http://dl-cdn.alpinelinux.org/alpine/v3.19/community
root@host:~# apk add open-vm-tools open-vm-tools-guestinfo open-vm-tools-deploypkg
root@host:~# rc-service open-vm-tools start
root@host:~# rc-update add open-vm-tools boot
Let's assume we want to upgrade Alpine Linux version from 3.19 to 3.20.
root@host:~# apk add --upgrade apk-tools && apk upgrade --available
#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.20/main
http://dl-cdn.alpinelinux.org/alpine/v3.20/community
root@host:~# apk update && apk upgrade --available
root@host:~# reboot
root@host:~# apk add nftables
root@host:~# reboot
#!/usr/sbin/nft -f
# vim: set ts=4 sw=4:
# You can find examples in /usr/share/nftables/.
# Clear all prior state
flush ruleset
#IPv4
table ip filter {
chain input {
type filter hook input priority 0; policy accept;
}
chain forward {
type filter hook forward priority 0; policy accept;
}
chain output {
type filter hook output priority 0; policy accept;
}
}
#IPv6
table ip6 filter {
chain input {
type filter hook input priority 0; policy accept;
}
chain forward {
type filter hook forward priority 0; policy accept;
}
chain output {
type filter hook output priority 0; policy accept;
}
}
root@host:~# rc-update add nftables boot
Contact :