Distribution differences
| Task | Amazon Linux 2023 | Ubuntu 24.04 LTS |
|---|---|---|
| Package manager | dnf | apt |
| Refresh metadata | sudo dnf makecache | sudo apt update |
| Install a package | sudo dnf install -y nginx | sudo apt install -y nginx |
| Apache service | httpd | apache2 |
| Default SSH user | ec2-user | ubuntu |
Package names, versions and repository availability vary. Inspect /etc/os-release, package information and enabled repositories. AL2023 uses versioned repositories; an update within the current release is not automatically a distribution release upgrade. Do not paste Amazon Linux 2 amazon-linux-extras instructions into AL2023.
Service lifecycle
sudo systemctl status nginx --no-pager
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl is-enabled nginx
sudo systemctl reload nginx
sudo journalctl -u nginx -n 50 --no-pagerStart affects this boot; enable configures future boots. Reload asks a service to reread configuration when supported; restart stops and starts it. Run the service-specific config test before either. systemctl daemon-reload rereads unit definitions, not Nginx configuration.
Build a simple systemd service
Create /usr/local/bin/academy-clock with an executable script that prints a timestamp and sleeps in a loop. Create /etc/systemd/system/academy-clock.service:
[Unit]
Description=Academy clock lab
After=network.target
[Service]
ExecStart=/usr/local/bin/academy-clock
User=nobody
Restart=on-failure
NoNewPrivileges=true
[Install]
WantedBy=multi-user.targetprintf '#!/bin/sh\nwhile true; do date -Is; sleep 60; done\n' | sudo tee /usr/local/bin/academy-clock >/dev/null
sudo chmod 755 /usr/local/bin/academy-clock
sudo systemctl daemon-reload
sudo systemctl enable --now academy-clock
journalctl -u academy-clock -n 5Scheduling
Cron uses minute, hour, day-of-month, month and day-of-week fields. 0 2 * * * /absolute/path/backup.sh runs daily at 02:00 in the scheduler's timezone. Cron has a limited environment: use full paths and capture logs. Systemd timers integrate with service logging and can support missed-run handling.
Practice and cleanup
Stop/disable the clock unit, remove only its two files, and run daemon-reload. Explain why enable without --now need not start a service immediately.
Official reference
Ravindra’s Tip
Start मतलब अभी चलाओ; enable मतलब boot पर चलाओ। दोनों अलग हैं, इसलिए restart के बाद भी service check करो।
Interview and revision check
What is the difference between reload and daemon-reload?
Service reload asks the application to reread its configuration when supported. systemctl daemon-reload rereads systemd unit definitions.
Ravindra Bagale · Cloud & DevOps Academy · Handbook and project downloads