Viewing Logs with `journalctl`
The `journalctl` command is used to query and display messages from the systemd journal, which contains logs from the kernel, services, and applications.
Basic `journalctl` Commands
View logs for a specific service
journalctl -u [service_name] --no-pager -n 50Displays the last 50 log entries for a given service. The `--no-pager` option prevents the output from being paginated.
Follow logs in real-time
journalctl -fu [service_name]The `-f` (follow) flag streams new log entries to the terminal as they are generated, which is useful for real-time monitoring.
View logs since the last boot
journalctl -bDisplays all log entries from the current boot session. This is very helpful for troubleshooting issues that occur during startup.