Firebird Flight Wiki: Service & Process Management
Firebird Flight

Service & Process Management

Keeping critical services running and managing processes is at the core of Linux administration. Whether you’re using systemd or an older init system, you’ll rely on commands to start, stop, enable, and check the health of processes. This page covers the fundamentals of service management and process control.

1. Introduction

Many modern Linux distros use systemd for service management, while others rely on SysV init scripts or Upstart. Regardless of the init system, administrators need to:

  • Start, stop, and restart services.
  • Enable services at boot or disable them.
  • Monitor system logs to debug issues.
  • Kill or terminate misbehaving processes.
  • Run persistent tasks in separate sessions without logging out.

Below are core tools and methods to manage processes effectively on a Linux system.

2. systemd Basics

systemd is an init system and service manager that replaces older systems like SysV. It uses units (.service, .timer, .socket, etc.) to define how daemons and other processes start or run.

2a. Service Commands

systemctl is the main CLI tool for controlling services. Basic usage includes:

Command Description
systemctl status [service] Shows whether [service] is running, plus recent log entries.
systemctl start/stop/restart [service] Manually controls [service] state (e.g., systemctl start nginx).
systemctl enable/disable [service] Configures [service] to start (or not) at boot.
systemctl is-enabled/is-active [service] Checks if [service] is enabled for startup and if it’s currently active.
Table 1: Common systemd Commands

2b. Logs with journalctl

journalctl is the tool for querying the systemd journal, which collects logs from system services and the kernel.

Usage / Flag Description
journalctl -u [service] Shows logs specific to [service].
journalctl -b Displays messages since the last boot.
journalctl -f Follows the log in real-time (similar to tail -f).
journalctl --since "1 hour ago" Filters entries to the specified timeframe.
Table 2: Common journalctl Usage

You can also combine flags (e.g., journalctl -u nginx -f) to watch a particular service’s logs in real time.

3. Older SysV Systems

Some distros or older releases still rely on SysV-style init scripts in /etc/init.d. Common commands for these include:

Command Description
service [service] start/stop/restart Controls SysV init scripts (e.g., service apache2 restart).
update-rc.d [service] defaults Enables [service] at startup (Debian/Ubuntu style). Similar to chkconfig [service] on in Red Hat-based distros.
Table 3: SysV Init Commands

While SysV usage is declining, it’s useful to understand for legacy systems or minimal containers that haven’t migrated to systemd.

4. Screen & Tmux

Sometimes you want to run a process in the background or keep it alive after you log out of the shell. Tools like screen and tmux create persistent sessions that let you detach and reattach at will.

screen

  • screen -S [session]: Creates a new session with a name.
  • Ctrl+A, D: Detaches the session, leaving it running in the background.
  • screen -r [session]: Reattaches to the named session.

tmux

  • tmux new -s [session]: Creates a named tmux session.
  • Ctrl+B, D: Detaches from the session, but keeps it alive.
  • tmux attach -t [session]: Reattaches to the named session.

These tools are especially handy for long-running tasks, servers, or interactive scripts you don’t want killed when your SSH session ends.

5. Kill Commands

Eventually, you’ll encounter a misbehaving or frozen process that needs to be terminated. Linux offers multiple ways to kill processes, each with varying levels of force.

Command Description
kill [pid] Sends the default SIGTERM (15) to process ID [pid].
kill -9 [pid] Sends SIGKILL (9), forcibly stopping the process. Use with caution—no cleanup is performed.
pkill [pattern] Searches for processes matching [pattern] (usually part of the name) and kills them. Example: pkill apache.
killall [name] Terminates all processes matching [name], e.g., killall firefox.
Table 4: Process Termination Commands

6. Conclusion

Mastering service and process management is essential for any sysadmin. Whether you’re enabling a new service at boot, tailing logs to debug a crash, detaching a terminal session, or killing a runaway process, these fundamental commands will keep your system stable and services running reliably.

As you progress, explore advanced systemd units (like timers, sockets, and targets) or specialized tools for container orchestration, giving you even greater control over how processes start, stop, and interact within your environment.