Linux · Lesson 10 of 14
Processes, services & logs
See what’s running on Linux (ps, top, systemctl) and investigate logs with tail, grep and journalctl. Hunt for failed logins in a practice auth.log.
⏱ 18 min🎯 Beginner🧪 Hands-on practice🎬 Video
By the end, you’ll be able to…
- List running processes and services and recognise what they are
- Find and read important log files on a Linux system
- Use grep, tail and pipes to answer a question from a log
Key words
- Process
- A program that is currently running. Each one has a process ID (PID).
- Service (daemon)
- A program that runs in the background, like a web or SSH server.
- systemd
- The system that starts and manages services on most modern Linux distributions.
- Log
- A record of events written by the system or a program.
- grep
- A command that searches text for lines that match a pattern.
- Pipe (|)
- Sends the output of one command into the next command.
What’s running right now?
Every running program is a process with a number called a PID. Two commands show them:
ps aux # snapshot of every process
top # live view, updated every few seconds (q to quit)
htop # a friendlier top, if installed
In ps aux you’ll see the user, PID, CPU and memory use, and the command. Defenders look for things that don’t belong: a process running from /tmp, an unknown program using lots of CPU, or something running as root that shouldn’t be.
Services
Background programs are called services (or daemons, which is why many end in “d”, like sshd). On most distributions, systemd manages them:
systemctl status ssh # is the SSH server running?
systemctl list-units --type=service --state=running
sudo systemctl stop apache2 # stop a service (changes the system!)
A service you don’t need is a door you don’t need. Turning off unused services is one of the simplest ways to harden a machine.
Where the logs live
| Location | What’s in it |
|---|---|
/var/log/auth.log | Logins, sudo use, SSH (Debian/Ubuntu) |
/var/log/secure | The same idea on Red Hat, Fedora and similar |
/var/log/syslog | General system messages (Debian/Ubuntu) |
journalctl | systemd’s journal, which holds logs from every service |
Many systems now keep most logs in the journal. These are handy:
journalctl -u ssh --since "1 hour ago"
journalctl -p err -b # errors since the last boot
journalctl -f # follow new entries live
Searching logs like an analyst
Logs can have millions of lines. You don’t read them, you ask them questions:
tail -n 20 /var/log/auth.log # the last 20 lines
grep "Failed password" /var/log/auth.log # only failed logins
grep "Failed password" /var/log/auth.log | wc -l # how many?
grep "Accepted" /var/log/auth.log # successful logins
The pipe | is the secret weapon: it chains small tools together. Each does one job well.
Evidence vs guesses
Say you see 40 failed SSH logins from one address, then one success from the same address. Is that an account takeover? Maybe, maybe not. The logs show what was recorded. Before deciding, check:
- Which account succeeded? Is that person expected to log in?
- Is the source address known, like the admin’s home or office?
- What happened after the login? New users, changed files, new processes?
Write down times, accounts and addresses before drawing conclusions. That’s exactly what SOC analysts and incident responders do every day.
🧪 Hands-on
Practice
Investigate the practice server’s login log. Missions guide you, and the answers are all in the log.
🎬 Watch
Video: The 50 Most Popular Linux & Terminal Commands
Video by freeCodeCamp, hosted on YouTube. It loads only when you press play.
✅ Check yourself
Quick quiz
🔗 Go further
Trustworthy resources
- journalctl manual Every way to query the systemd journal.
- GNU grep manual Patterns, flags and examples.
- Linux Journey: Logging Look for the Logging chapter.