Skip to main content

How to use systemctl and journalctl on a VPS Server

This guide explains how to use two essential Linux troubleshooting tools:

  • systemctl — used for managing services (start, stop, restart, check status).

  • journalctl — used for viewing and analyzing system logs.

Commonly used commands

systemctl status service_name

systemctl restart service_name

systemctl enable service_name

journalctl -u service_name

journalctl -fjournalctl -xeu service_name

Below, we will take a closer look at the tools and commands mentioned.

1. What is systemctl?

systemctl is part of the systemd system and is used to:

  • Start services

  • Stop services

  • Restart services

  • Check service status

1.1 Check service status

Use the command:

systemctl status <service_name>

Examples:

systemctl status httpd
systemctl status apache2
systemctl status mariadb
systemctl status sshd
  • active (running) — service is running

  • inactive — service is stopped

  • failed — service has encountered an error

1.2 Start a service

Use the command:

systemctl start <service_name>

Examples:

systemctl start apache2
systemctl start mariadb
systemctl start sshd

1.3 Stop a service

Use the command:

systemctl stop <service_name>

Examples:

systemctl stop apache2
systemctl stop mariadb
systemctl stop httpd

1.4 Restart a service

Use the command:

systemctl restart <service_name>

Examples:

systemctl restart apache2
systemctl restart mariadb
systemctl restart sshd

The restart command is commonly used after making configuration changes.

1.5 Reload configuration only

Use the command:

systemctl reload <service_name>

Examples:

systemctl reload apache2
systemctl reload mariadb

1.6 Enable automatic startup

Enable a service to start automatically when the server boots:

systemctl enable <service_name>

Disable automatic startup:

systemctl disable apache2

1.7 List services

Use the command:

systemctl list-units --type=service

Output example:

UNIT                 LOAD   ACTIVE   SUB      DESCRIPTION
httpd.service loaded active running The Apache HTTP Server
mariadb.service loaded active running MariaDB database server
memcached.service loaded active running Memcached
pure-ftpd.service loaded active running Pure-FTPd FTP server
sshd.service loaded active running OpenSSH server daemon

2. What is journalctl?

journalctl is used to view:

  • System logs

  • Service errors

  • Boot information

2.1 View all logs

Use the command:

journalctl

This may display a very large amount of log data.

2.2 Follow logs in real time

Use the command:

journalctl -f

It is similar to

tail -f

2.3 View logs for a specific service

Use the command:

journalctl -u httpd

Examples:

journalctl -u httpd
journalctl -u apache2
journalctl -u mariadb

2.4 View recent log entries

Use the command:

journalctl -u nginx -n 50

Shows the last 50 log entries.

2.5 View error logs only

Use the command:

journalctl -p err -b

2.6 View logs since last boot

Use the command:

journalctl -b

2.7 Filter logs by time

Show logs since a specific date:

journalctl --since "2026-01-01"

Show logs from the last hour:

journalctl --since "1 hour ago"

3. Troubleshooting examples

3.1 If a service is not running

Check its status:

systemctl status mariadb

If you see failure, inspect recent logs:

journalctl -u mariadb -n 50

3.2 Apache does not start

Check status:

systemctl status httpd

View detailed logs:

journalctl -xeu httpd

3.3 After configuration changes

Restart the service:

systemctl restart nginx

If an error occurs, check detailed logs:

journalctl -xeu nginx

Did this answer your question?