Progress: 0/62 (0%)

⚙️ Checking Running Services

Checking Running Services

Think of services like ongoing operations in your office: security cameras, printers, coffee machines, or a receptionist. They need to be running properly for your system (office) to function smoothly. Linux has systemd to manage services, and older systems may use the service command.

Using systemctl (modern systems)

systemctl controls and checks systemd services.

Common commands:

1. Check status of a service:

systemctl status ssh

Shows if the service is active, inactive, or failed and provides logs and process ID.

2. Start a service:

sudo systemctl start apache2

Boots up a service if it's stopped.

3. Stop a service:

sudo systemctl stop apache2

4. Enable/Disable at boot:

sudo systemctl enable nginx

# starts on boot

sudo systemctl disable nginx

# won't start on boot

Using service (older systems)

The service command is similar to systemctl but uses older syntax.

sudo service apache2 status

# check status

sudo service apache2 start

# start service

sudo service apache2 stop

# stop service

Practical Tips

If a web server or database isn't responding, always check its service status first. Use systemctl list-units --type=service to see all running services at once. Logs for a service can often be viewed via:

journalctl -u service_name

Real-life analogy

For systemctl: Like the office manager who can start, stop, or check the status of any ongoing operation. For service: Like an old-school manager. Services are like ongoing office operations that need supervision. This wraps up System Monitoring and Logs. You now have tools to check CPU, memory, and disk health; view system logs for troubleshooting; monitor disk I/O and memory usage; and inspect and control running services.