Ubuntu systemctl command – Manage Services in Ubuntu Linux

Let's see how to use the systemctl command on Ubuntu Linux. The systemctl command mostly used to manage systemd services, but can be used to shutdown and restart Ubuntu System.

So Let’s see some Examples.

Manage Ubuntu Services with systemctl command.

Users and administrators can manage services on Ubuntu Linux using the systemctl command.

1. List All Services

To get a List of All available services on your Ubuntu Operating System, Type:

systemctl list-unit-files --type=service

2. List Running Services

To list all running and active services in Ubuntu, Type:

systemctl list-units --type=service --state=active

3. View Status of a systemd service

To view the status of a Service, Type:

systemctl status <service-name>

Example, View the status of the Apache Web Server.

systemctl status apache2.service

4. Start, Restart and stop systemd services

systemctl [start|stop|restart] <service-name>

Example, Restart Apache Web Server on Ubuntu Linux.

systemctl restart apache2.service

Example, Start Mysql server.

systemctl start mysql.service

5. Enable service to start when system reboot.

Example, configure Apache Web Server to start when system reboot.

systemctl enable apache2.service

Disable the service if you do not want it to start at system reboot.

systemctl disable mysql.service

Reboot, Power Off and Change Runlevels

Systemctl system commands use for the Operating System Level Task.

1. Shut down and power-off the Ubuntu Operating System.

systemctl poweroff

2. Reboot the Ubuntu System.

systemctl reboot

3. Change Default Runlevel

Example, Change the default runlevel to Multi user Mode.

systemctl set-default graphical.target

4. Switch between runlevels

The systemctl isolate command use to switch between different runlevels.

Example, Switch to Multi User Mode in Ubuntu.

systemctl isolate multi-user.target