Middle
How to view systemd service logs?
sobes.tech AI
Answer from AI
The journalctl command is used to view systemd service logs.
To view logs for a specific service, for example nginx.service, you can run:
journalctl -u nginx.service
Keys and options:
-u <unit>— filter by unit (service)-f— output in real-time mode (liketail -f)--sinceand--until— filter by time, e.g.,--since "2024-06-01 10:00:00"
Example of viewing the last 50 lines:
journalctl -u nginx.service -n 50
To view system logs without filtering by service, simply use journalctl.
You can also combine with sudo if you need logs that are access-restricted:
sudo journalctl -u nginx.service