How to enable and start services on Alpine Linux

How do I add or delete service at boot time on an Alpine Linux? How do I enable service such as Nginx/Apache at boot time on an Alpine Linux? How do I start/stop/restart services on an Alpine Linux?

Alpine Linux comes with OpenRC init system. This tutorial shows how to use the various command on OpenRC to manage services.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Alpine Linux
Est. reading time 3 minutes

View status of all services

Type the following command:
# rc-status

Runlevel: default
 crond                                  [  started  ]
 networking                             [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual

The default run level is called default, and it started crond and networking service for us.

View service list

Type the following command:
# rc-status --list
Sample outputs:


You can change run level using the rc command:
# rc {runlevel}
# rc boot
# rc default
# rc shutdown

  1. boot – Generally the only services you should add to the boot runlevel are those which deal with the mounting of filesystems, set the initial state of attached peripherals and logging. Hotplugged services are added to the boot runlevel by the system. All services in the boot and sysinit runlevels are automatically included in all other runlevels except for those listed here.
  2. single – Stops all services except for those in the sysinit runlevel.
  3. reboot – Changes to the shutdown runlevel and then reboots the host.
  4. shutdown – Changes to the shutdown runlevel and then halts the host.
  5. default – Used if no runlevel is specified. (This is generally the runlevel you want to add services to.)

To see manually started services, run:
# rc-status --manual

To see crashed services, run:
# rc-status --crashed

How to list all available services

Type the following command:
# rc-service --list
# rc-service --list | grep -i nginx

If apache2/nginx not installed, try the apk command to install it:
# apk add apache2

How to add/enable service at boot time

The syntax is:
rc-update add {service-name} {run-level-name}
To add apache2 service at boot time, run:
# rc-update add apache2
# rc-update add apache2 default
Sample outputs:

 * service apache2 added to runlevel default

Removing service at boot time on Alpine Linux

Pass the del as follows:
rc-update del {service-name-here}
For example, remove vnstatd service:
# rc-update del vnstatd

 * service vnstatd removed from runlevel default

If you wish to add that service again, simple run:
# rc-update add vnstatd

How to start/stop/restart services on Alpine Linux

The syntax is as as follows:

How to start service

The syntax is:
# rc-service {service-name} start
# /etc/init.d/{service-name} start

How to stop service

The syntax is:
# rc-service {service-name} stop
# /etc/init.d/{service-name} stop

How to restart service

The syntax is:
# rc-service {service-name} restart
# /etc/init.d/{service-name} restart
Thus to stop, start, and restart an Apache2 service:
# rc-service apache2 stop
# rc-service apache2 start
### [ edit config file ] ###
# vi /etc/apache2/httpd.conf
### [ restart apache 2 after editing the file ] ###
# rc-service apache2 restart

Summing up

You leaned service managment when usign Alpine Linux on your cloud server/VM. For more info see Alpine Linux project.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Raj Patil Feb 22, 2021 @ 17:20

    Started using Alpine Linux I was missing systemd and systemctl command. This guide was perfect as I had no idea Alpine Linux wasn’t shipped with systemd. Much obliged.

    • markand May 11, 2021 @ 14:45

      Because systemd is an incredible piece of bloat that has more dependencies than the base system of Alpine. It also has numerous number of CVEs and is not compatible with musl (which is the Alpine’s C library).

  • Abhay Mar 2, 2021 @ 9:31

    Great tutorial!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum