Reading system logs is one of the first real troubleshooting skills you need in Linux. It can feel intimidating at the start, especially when you see thousands of lines scroll past the screen. This guide keeps everything calm, simple, and focused on the commands that matter.
You’ll learn how to use
journalctl to view logs, filter them, and find real answers when something goes wrong.
What journalctl Does
journalctl reads logs collected by systemd, the system manager used by most modern Linux distributions. Think of it as a single place where services, applications, and the system itself report what they’re doing.
When something breaks, this is usually the first tool you check.
Step 1: View All Logs
The simplest way to start is to look at everything the system has recorded:journalctl
You’ll see a long list of messages, starting from when the system was installed. Each line is an event from a service, process, or part of the system.
This broad view helps when a user says their machine is “acting strange” and you want a quick sense of recent activity.
Step 2: View the Most Recent Logs First
Most of the time, you only care about what just happened. Reverse the order like this:journalctl -r
The newest logs are now at the top. This is useful when something fails right now and you want immediate clarity without scrolling.
Step 3: Follow Logs in Real Time
If you’re restarting a service or testing a fix, you can watch logs appear as they’re created:journalctl -f
This works like tail -f. It gives you a live view—perfect for watching errors appear the moment something runs.
Step 4: Show Logs for One Service
You don’t need to sift through thousands of system messages. Narrow your focus to the service you’re troubleshooting:journalctl -u sshd
The -u option shows logs for one systemd unit—in this case, the SSH service.
When a user can’t connect over SSH, this command shows you only what matters: authentication issues, connection attempts, and error messages.
Step 5: View Logs From the Current Boot
If the system was recently restarted, older logs aren’t helpful. Limit your view to just this boot session:journalctl -b
Now you’re looking only at events since the last startup. This is helpful when a service refuses to start after a reboot.
Step 6: Filter Logs by Time
You can ask journalctl for logs from a specific window without guessing:journalctl --since "1 hour ago"
This human-friendly filter lets you match logs to when the problem occurred. If someone says “It broke about an hour ago,” this gives you exactly the right slice of time.
Troubleshooting Tips
Beginners often run into the same problems. Here’s how to avoid them.1. Permission Denied Errors
Some logs require root access. If you see an error, rerun the command withsudo:
sudo journalctl
2. Too Many Logs at Once
Don’t start withjournalctl alone. Use filters like:
-u service-b--since
3. Wrong Service Name
Service names must match exactly. To confirm the name:systemctl list-units --type=service
A Practical Real-World Example
A user reports they can’t connect through SSH. You focus immediately:sudo journalctl -u sshd -r
Newer logs show at the top. You notice repeated authentication failure messages.
This reveals three things:
- SSH is running
- The server is reachable
- The issue is likely bad credentials or a locked account
A Small Next Step
Once you’re comfortable, try combining filters:journalctl -u sshd --since "30 minutes ago" -r
This gives you a focused view: one service, a short time frame, and newest logs first. It’s a clean way to practice building precise log queries.
Conclusion
journalctl becomes less intimidating once you learn a few simple patterns. Start with the basics, use filters to reduce noise, and give yourself time to get comfortable. With these steps, system logs become a clear, manageable tool rather than something to avoid.