206 words
1 minutes
Service and Process Management
2025-04-03

Service and Process Management in Linux#

Overview#

Linux provides robust tools for managing system services and processes. This section explains how to handle background services (daemons) and running processes, with particular focus on modern systems using systemd.

Service Management#

Types of Services#

  • System Services: Critical services required for system operation (e.g., systemd, sshd)
  • User-Installed Services: Optional services providing additional functionality (e.g., web servers, databases)

Service Management with systemctl#

The systemctl command is the primary interface for service management in systemd-based systems:

CommandDescription
systemctl start <service_name>Starts a specified service
systemctl status <service_name>Displays current status of a service
systemctl enable <service_name>Configures service to start at boot
systemctl list-units --type=serviceLists all available services
journalctl -u <service_name> --no-pagerShows service logs

Process Management#

Process States#

Processes may exist in various states:

  • Running: Actively executing
  • Waiting: Paused for resources
  • Stopped: Suspended execution
  • Zombie: Completed but not yet removed

Process Control Commands#

Process Termination#

CommandDescription
kill <PID>Sends termination signal to process
kill -9 <PID>Forces immediate termination (SIGKILL)
kill -15 <PID>Requests graceful termination (SIGTERM)
kill -19 <PID>Stops/pauses a process (SIGSTOP)

Background Process Management#

CommandDescription
[Ctrl + Z]Suspends current foreground process
bgResumes suspended process in background
command &Runs command directly in background
jobsLists background jobs
fgBrings background job to foreground

Process Monitoring#

CommandDescription
ps -auxLists all running processes
kill -lDisplays all available signals
topInteractive process viewer

Practical Examples#

  1. Starting and enabling a service:
systemctl start nginx
systemctl enable nginx
  1. Checking service status:
systemctl status sshd
  1. Terminating a process:
ps -aux | grep chrome
kill -15 1234
  1. Managing background processes:
long_running_command &
jobs
fg %1
Service and Process Management
https://fuwari.vercel.app/posts/service-and-process-management/
Author
Ranjung Yeshi Norbu
Published at
2025-04-03