Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Chapter 11Name in the course: Daily server work

Do the daily work on Linux servers

Even with Kubernetes and the cloud, many things still run on Linux servers: CI runners, databases, proxies, jump hosts. These 6 tools are the daily basics — the same you learn for the RHCSA exam.

  • 7 Lessons
  • 8 Commands

$ run as a normal user# run as root (or with sudo)

Skills in this chapter

  • Daily server work — 6

11.1

systemctl — services

systemctl starts, stops, enables and checks services (units) of systemd.

systemctl status nginx
systemctl enable --now node_exporter
systemctl restart shop && systemctl is-active shop
systemctl --failed

11.2

journalctl — logs of the system

journalctl reads the logs of all services in one place.

journalctl -u shop -f
journalctl -u shop --since "10 min ago" -p err
journalctl -b -1 -p warning

11.3

ssh — log in and run commands

ssh is how you reach every server — with keys, a jump host and an ssh config file.

ssh -J bastion.example.com web1.internal
ssh web1 'sudo systemctl is-active nginx'
ssh-keygen -t ed25519 -C "hosam@laptop"

Good practice:

  • Keys only, no root login, no passwords on internet-facing servers.

11.4

rsync — copy and sync files

rsync copies only what changed — for deploys of static files, backups and migrations.

rsync -avz --delete dist/ web1:/var/www/shop/
rsync -aHAX --info=progress2 /srv/data/ backup1:/backups/data/
rsync -avn --delete dist/ web1:/var/www/shop/

Commands in this lesson

11.5

crontab — scheduled jobs

crontab runs scripts on a schedule (backups, clean-ups, reports). systemd timers are the modern choice.

crontab -l
crontab -e
systemctl list-timers

11.6

logrotate — keep log files small

logrotate rotates, compresses and deletes old log files so disks do not fill up.

logrotate -d /etc/logrotate.d/shop
logrotate -f /etc/logrotate.d/shop

11.7

Write a runbook for every server role

A short page per server role saves hours at 3 in the night.

  1. What runs here, which ports, which config files.
  2. How to check health (systemctl status, a curl URL, a dashboard link).
  3. Where the logs are (journalctl -u …, Loki labels).
  4. How to restart safely, and who must know.
  5. How backups work and when the last restore test was.

Remember

Every manual fix you do twice belongs in Ansible, a script or the runbook.

All commands in this chapter