| |

LFCS 166 ๐Ÿง LFCS Practice Scenarios โ€” Services

โฑ๏ธ Estimated read: 9 min | |

The previous chapters covered the storage and networking practice scenarios. This chapter covers the services practice: the scenarios that simulate the exam tasks in the service management domain. The LFCS service domain is weighted at 15% of the total score, and the objectives cover the systemd unit management, the web server configuration, the SSH server configuration, the time synchronization, the logging, and the firewalld . The critical trap is the configuration versus the runtime distinction. The systemctl start is the runtime. The systemctl enable is the persistence. The httpd.conf edit is the file. The systemctl reload is the apply. The firewalld rule requires the --permanent and the --reload. The scenarios test the complete workflow: the service install, the configuration, the apply, the verification, and the persistence.

Key point: The services scenarios are the end-to-end tasks: the install the service, the configure the service, the apply the configuration, the verify the service, the make the service start at boot, and the open the firewall. The candidate must verify the state with the systemctl status, the ss -tlnp, the curl, the firewall-cmd --list-all, and the journalctl. The scenarios assume the clean VM where the install, the configure, the restart, and the verify are possible.


Why the services practice requires a specific mental model

The runtime versus persistent problem. The systemctl start nginx starts the service now. The reboot stops it. The systemctl enable nginx sets the service to start at boot, but does not start it now. The systemctl enable --now nginx does both. The exam tests both states: the running and the enabled.

The configuration versus apply problem. The httpd.conf edit does nothing until the systemctl reload httpd or the apachectl graceful. The sshd_config edit requires the sshd -t and the systemctl reload sshd. The chronyd configuration requires the systemctl restart chronyd. The scenarios test the apply step.

The firewall problem. The service that listens on the port is not reachable if the firewall blocks the port. The firewalld rule requires the --permanent and the --reload. The ufw allow is the Ubuntu alternative. The scenarios test the firewall-cmd --list-all to verify the service is allowed.

The verification problem. The systemctl status shows the service state. The ss -tlnp shows the listening port. The curl tests the HTTP response. The journalctl -u shows the errors. The scenarios test the state, not the command output.

The trade-off. The services scenarios are the most likely to hit the configuration error that prevents the service from starting. The systemctl status and the journalctl are the diagnostic tools. The practice must include the failure and the recovery.


a. The web server installation and configuration

The scenario: the install the Nginx, the configure the static site, the open the firewall, the verify the response, and the make the service start at boot.

# Install
sudo apt install nginx
# or: sudo dnf install nginx

# Create the site
sudo mkdir -p /var/www/mysite
echo "<h1>My Site</h1>" | sudo tee /var/www/mysite/index.html

# Add the server block (Debian/Ubuntu)
sudo tee /etc/nginx/sites-available/mysite <<'EOF'
server {
    listen 80;
    server_name mysite.local;
    root /var/www/mysite;
    index index.html;
    location / { try_files $uri $uri/ =404; }
}
EOF
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/

# Test and reload
sudo nginx -t
sudo systemctl reload nginx

# Verify
curl -H "Host: mysite.local" http://localhost
ss -tlnp | grep :80

# Enable at boot
sudo systemctl enable nginx

# Firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

The nginx -t validates the syntax. The systemctl reload applies. The curl -H "Host: ..." tests the virtual host. The ss -tlnp shows the listening port. The systemctl enable makes the boot start. The firewall-cmd --permanent --add-service=http opens the port persistently.


b. The SSH server configuration

The scenario: the configure the SSH server to disable the password auth, the change the port, and the restart the service.

# Generate the key (on the client)
ssh-keygen -t ed25519
ssh-copy-id user@server

# Test the key auth
ssh -o PubkeyAuthentication=yes -o PasswordAuthentication=no user@server

# Edit the server config
sudo tee /etc/ssh/sshd_config.d/99-custom.conf <<'EOF'
PasswordAuthentication no
PermitRootLogin no
Port 2222
EOF

# Validate and reload
sudo sshd -t
sudo systemctl reload sshd

# Firewall for the new port
sudo semanage port -a -t ssh_port_t -p tcp 2222
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --reload

# Verify
ss -tlnp | grep sshd

The key auth must be tested before the password is disabled. The sshd -t validates the config. The semanage port -a allows the new port in the SELinux. The firewall-cmd --add-port allows it in the firewall. The ss confirms the listening port.


c. The time synchronization and the logging

The scenario: the configure the chronyd to sync with the NTP server, the verify the sync, and the configure the rsyslog to forward the logs.

# Install chrony
sudo apt install chrony

# Configure the NTP servers
sudo tee /etc/chrony/chrony.conf <<'EOF'
pool 2.pool.ntp.org iburst
EOF

# Restart and verify
sudo systemctl restart chrony
chronyc sources
chronyc tracking
timedatectl

# rsyslog forward
sudo tee /etc/rsyslog.d/50-forward.conf <<'EOF'
*.* @@logserver.example.com:514
EOF
sudo rsyslogd -N1
sudo systemctl restart rsyslog

The chronyc sources shows the NTP sources. The chronyc tracking shows the sync status. The timedatectl shows the system time. The rsyslogd -N1 validates the config. The @@ is the TCP forward, the @ is the UDP.


Complete Example Session

# ============================================
# PART 1: INSTALL NGINX
# ============================================

sudo apt install nginx
sudo systemctl enable --now nginx
# ============================================
# PART 2: CONFIGURE THE SITE
# ============================================

sudo mkdir -p /var/www/mysite
echo "<h1>My Site</h1>" | sudo tee /var/www/mysite/index.html
# ============================================
# PART 3: ADD THE SERVER BLOCK
# ============================================

sudo tee /etc/nginx/sites-available/mysite <<'EOF'
server {
    listen 80;
    server_name mysite.local;
    root /var/www/mysite;
}
EOF
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
# ============================================
# PART 4: TEST AND RELOAD
# ============================================

sudo nginx -t
sudo systemctl reload nginx
# ============================================
# PART 5: VERIFY
# ============================================

curl -H "Host: mysite.local" http://localhost
ss -tlnp | grep :80
# ============================================
# PART 6: FIREWALL
# ============================================

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
# ============================================
# PART 7: SSH KEY AND CONFIG
# ============================================

ssh-keygen -t ed25519
ssh-copy-id user@server
sudo tee /etc/ssh/sshd_config.d/99-custom.conf <<'EOF'
PasswordAuthentication no
EOF
sudo sshd -t
sudo systemctl reload sshd
# ============================================
# PART 8: TIME SYNC
# ============================================

sudo systemctl restart chrony
chronyc sources
timedatectl
# ============================================
# PART 9: LOG FORWARD
# ============================================

sudo tee /etc/rsyslog.d/50-forward.conf <<'EOF'
*.* @@logserver.example.com:514
EOF
sudo rsyslogd -N1
sudo systemctl restart rsyslog

The nine parts trace the services scenarios: the install, the site, the server block, the reload, the verify, the firewall, the SSH, the time sync, and the log forward.


Quick Reference

Service Management

CommandPurpose
systemctl startStart now
systemctl enableStart at boot
systemctl enable --nowBoth
systemctl reloadApply the config
systemctl statusShow the state

Web Server

CommandPurpose
nginx -tTest the config
systemctl reload nginxApply
curl -H "Host: ..."Test the virtual host
ss -tlnpShow the listening port

SSH

CommandPurpose
ssh-keygenGenerate the key
ssh-copy-idDeploy the key
sshd -tValidate the config
systemctl reload sshdApply

Time and Log

CommandPurpose
chronyc sourcesNTP sources
chronyc trackingSync status
rsyslogd -N1Validate rsyslog
systemctl restart rsyslogApply

Best Practices

โœ… Do This:

sudo systemctl enable --now nginx
<!-- Enable and start in one command -->              # โœ…
sudo nginx -t && sudo systemctl reload nginx
<!-- Test before the reload -->                       # โœ…
sudo firewall-cmd --permanent --add-service=http && sudo firewall-cmd --reload
<!-- Persistent firewall rule -->                    # โœ…

โŒ Don’t Do This:

sudo systemctl start nginx
<!-- Not enabled at boot -->                         # โŒ
sudo systemctl restart nginx
# For the config change
<!-- Use reload -->                                  # โŒ
# Disable the SSH password before the key test
<!-- Locks out the admin -->                         # โŒ

Common Pitfalls

PitfallWhy It HappensFix
Site not reachableFirewall blocks the portOpen the firewall
Config not appliedNo reloadsystemctl reload
Service not starting at bootNo enablesystemctl enable
SSH locked outWrong configsshd -t first
NTP not syncingWrong serverCheck chronyc sources

Real-World Examples

1. Install Nginx

apt install nginx

2. Enable

systemctl enable --now nginx

3. Test Config

nginx -t

4. Reload

systemctl reload nginx

5. Firewall

firewall-cmd --permanent --add-service=http && firewall-cmd --reload

6. SSH Key

ssh-copy-id user@server

7. SSH Validate

sshd -t

8. Time Sync

chronyc tracking

9. Log Forward

echo "*.* @@logserver:514" > /etc/rsyslog.d/50-forward.conf

10. Verify

ss -tlnp; curl localhost

Visual

Service Scenario Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Install (apt, dnf)                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Configure (nginx.conf, sshd_config)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Test (nginx -t, sshd -t)                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Reload (systemctl reload)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Verify (ss, curl, firewall-cmd)             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Persist (systemctl enable, --permanent)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Firewalld Rule

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --permanent --add-service=http โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --reload                       โ”‚
โ”‚  โ†’ Applies the permanent rule                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  firewall-cmd --list-all                     โ”‚
โ”‚  โ†’ Verify the rule                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
Service startsystemctl start
Service bootsystemctl enable
Bothsystemctl enable --now
Apply configsystemctl reload
Web testnginx -t
SSH testsshd -t
Firewallfirewall-cmd --permanent
Time syncchronyc sources
Log forward@@host:port

Key takeaways:

  • The enable and the start are separate. The start runs the service now. The enable sets the boot. The enable --now does both. The exam tests both states.
  • The config edit requires the apply. The nginx -t and the sshd -t validate. The systemctl reload applies. The restart drops the connections; the reload does not.
  • The firewall is the persistent. The firewall-cmd --permanent writes the rule. The --reload applies. The rule without the --permanent is lost on the reload.
  • The SSH hardening is the key first. The password disable locks out the admin if the key is not working. The sshd -t validates. The reload applies.
  • The verification is the state. The ss -tlnp shows the listening port. The curl tests the response. The chronyc tracking shows the sync. The firewall-cmd --list-all shows the rules.

Remember: The services scenarios are the end-to-end tasks. The install, the configure, the test, the reload, the verify, the enable, the firewall. The systemctl is the service. The nginx -t is the check. The firewall-cmd is the port. The chronyc is the time. The exam tests the complete workflow.

Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!