rss logo

My commands and useful tips for Alpine Linux

Alpine Linux Logo

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.

Useful Commands

  • Update Alpine Linux:
root@host:~# apk add --upgrade apk-tools && apk upgrade --available
  • Install package:
root@host:~# apk add vim
  • Install python3:
root@host:~# apk add python3

Cron

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.

  • Create a /etc/periodic/5min folder:
root@host:~# mkdir /etc/periodic/5min
  • Add an entry in the /etc/crontabs/root file for the /etc/periodic/5min folder:
*/5 * * * * run-parts /etc/periodic/5min
  • Create a /etc/periodic/5min/pscript (do not use the .sh extension) shell script:
#!/bin/sh /root/script.py
  • Make the file executable :
root@host:~# chmod +x /etc/periodic/5min/pscript
  • Run a test:
root@host:~# run-parts --test /etc/periodic/5min/
  • Take into account modifications:
root@host:~# rc-service crond start && rc-update add crond

Installing VMware Tools

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.

  • Edit /etc/apk/repositories and uncomment the community line:
#/media/cdrom/apks http://dl-cdn.alpinelinux.org/alpine/v3.19/main http://dl-cdn.alpinelinux.org/alpine/v3.19/community
  • Install the open-vmtools packages:
root@host:~# apk add open-vm-tools open-vm-tools-guestinfo open-vm-tools-deploypkg
  • Start the open-vmtools service:
root@host:~# rc-service open-vm-tools start
  • Enable open-vmtools at boot:
root@host:~# rc-update add open-vm-tools boot
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address