⚙️ Linux Administration

Take control of your Linux server — manage scheduled tasks with cron, control services, and read system logs.

⏰ Cron Jobs
Q1What is a cron job?Intermediate

A cron job is a scheduled task in Linux that runs automatically at specified times or intervals. It's managed by the cron daemon (a background service).

Common uses: automated backups, sending emails, clearing temp files, running scripts.

Cron syntax: minute hour day month weekday command

# Run backup.sh every day at 2:30 AM
30 2 * * * /home/user/backup.sh

# Run every hour
0 * * * * /scripts/check.sh

# Run every Monday at 8 AM
0 8 * * 1 /scripts/weekly-report.sh
💡 Use crontab -e to edit your cron jobs. Use crontab -l to list them. The asterisk * means "every" for that time unit.
🔧 Services
Q2How do I start, stop and restart services in Linux?Intermediate

Modern Linux systems use systemd to manage services. Use the systemctl command:

sudo systemctl start nginx      # Start nginx
sudo systemctl stop nginx       # Stop nginx
sudo systemctl restart nginx    # Restart nginx
sudo systemctl reload nginx     # Reload config without restart
sudo systemctl status nginx     # Check if running
sudo systemctl enable nginx     # Auto-start on boot
sudo systemctl disable nginx    # Don't auto-start on boot
💡 After editing a config file (e.g. Apache's apache2.conf), use reload instead of restart to apply changes without dropping active connections.
📋 Log Files
Q3Where are log files stored in Linux?Intermediate

Most log files are stored in /var/log/. Key log files:

  • /var/log/syslog — General system messages
  • /var/log/auth.log — Authentication events (logins, sudo usage)
  • /var/log/apache2/access.log — Apache web requests
  • /var/log/apache2/error.log — Apache errors
  • /var/log/nginx/access.log — Nginx web requests
  • /var/log/nginx/error.log — Nginx errors
tail -f /var/log/nginx/error.log    # Watch log in real-time
grep "404" /var/log/apache2/access.log  # Find 404 errors
💡 tail -f (follow) is your best friend for debugging — it shows new log lines as they appear in real time.