Today’s Learning Log – Processes, Signals, and Services in Linux

Andrii RAndrii R
3 min read

Today I dove deep into Linux process management, signals, and system services. Here’s the breakdown of what I learned and practiced.

Processes and Their States

  • Foreground – process runs in direct interaction with the terminal; you can’t use the terminal until it finishes.

  • Background – process runs without blocking the terminal; you can continue typing other commands.

  • You can suspend a foreground process with Ctrl+Z and bring it back with fg.

  • Parent process – the process that spawned another process. On most modern Linux systems, systemd is the ultimate parent for many processes.

Checking Processes

CommandPurpose
psShows running processes for the current shell.
ps auxLists all processes from all users, with more detail.
topReal-time process viewer, showing CPU/memory usage and other stats.
pidProcess ID – unique number given to each process.

Signals and Killing Processes

  • Signals are messages sent to processes by the OS or other processes.

  • Common ones:

    • SIGTERM (15) – Politely asks a process to terminate (default for kill).

    • SIGKILL (9) – Immediately kills a process; can’t be caught or ignored.

    • SIGSTOP – Suspends a process (similar to what Ctrl+Z triggers)

    • SIGCONT – Resumes a stopped process.

  • kill <PID> – Sends a signal (default SIGTERM) to a process.

  • kill -l – Lists all available signals.

  • man 7 signal – Detailed info on all signals.

The Kernel

  • The kernel is the core of the OS, managing hardware, processes, memory, and devices.

  • All processes ultimately run under the kernel’s control.

Namespaces

  • Namespaces are a way Linux isolates processes, network interfaces, mount points, etc., so different processes can have their own separate “view” of the system.

  • Used heavily in containers like Docker.

Managing Services with systemctl

CommandPurpose
systemctl start <service>Starts a service immediately.
systemctl stop <service>Stops a running service.
systemctl enable <service>Enables a service to start on boot.
systemctl enable --now <service>Enables and starts a service immediately.
Example: systemctl stop apache2Stops the Apache HTTP server.

Why sudo can still matter even for root:

Even if you’re in a root shell, sudo may still be recommended because:

  1. It ensures the correct environment variables are set for system commands.

  2. It logs the command for auditing and traceability.

  3. It avoids running an entire shell as root, reducing risk.

  4. On some systems, it’s required to interact with certain privileged sockets (like systemd’s control interface).

Quick Script Example for Foreground/Background Practice

#!/bin/bash
echo "Running..."
sleep 100
  1. Make it executable: chmod +x script.sh

  2. Run it: ./script.sh

  3. Suspend with Ctrl+Z.

  4. Resume with fg.

Closing Thoughts
Today’s session gave me a clearer picture of how Linux handles processes and services. I now understand the difference between foreground and background tasks, how to view and manage processes with tools like ps and top, and how signals control what happens to them. I also learned that system services are managed with systemctl and why sudo can still matter even when you’re root. These basics feel like the foundation I’ll keep building on as I explore more advanced Linux topics.

0
Subscribe to my newsletter

Read articles from Andrii R directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Andrii R
Andrii R