$ run as a normal user# run as root (or with sudo)
Skills in this chapter
- Daily server work — 6
systemctl — services
systemctl starts, stops, enables and checks services (units) of systemd.
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 warningssh — 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.
rsync — copy and sync files
rsync copies only what changed — for deploys of static files, backups and migrations.
crontab — scheduled jobs
crontab runs scripts on a schedule (backups, clean-ups, reports). systemd timers are the modern choice.
logrotate — keep log files small
logrotate rotates, compresses and deletes old log files so disks do not fill up.
Write a runbook for every server role
A short page per server role saves hours at 3 in the night.
- What runs here, which ports, which config files.
- How to check health (
systemctl status, acurlURL, a dashboard link). - Where the logs are (
journalctl -u …, Loki labels). - How to restart safely, and who must know.
- 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.