Sysadmin Essentials
Rust developers deploying services need baseline Linux skills: files, permissions, processes, systemd, and logs. These commands debug production and local Docker hosts alike.
Recipe
ls -la
chmod 755 /usr/local/bin/my-service
systemctl status my-service
journalctl -u my-service -f --since "10 min ago"
df -h && du -sh target/
ulimit -nWhen to reach for this:
- First deploy to VM or bare metal
- Permission denied on binary or socket
- Service crash loops after release
Working Example
# Create service user and install binary
sudo useradd -r -s /bin/false myservice
sudo install -o myservice -g myservice -m 755 \
target/release/my-service /usr/local/bin/my-service
sudo systemctl daemon-reload
sudo systemctl enable --now my-service
curl -sf localhost:8080/healthWhat this demonstrates:
- Least-privilege service user
- systemd manages restart policy
- journald captures stdout/stderr from
tracingsubscriber
Deep Dive
Permissions Model
| Symbol | Meaning |
|---|---|
rwx user/group/other | read, write, execute bits |
4 | read, 2 write, 1 execute |
Rust binaries need execute bit; config files often 640 root + service group.
File Descriptors
High-concurrency Axum services need LimitNOFILE=65535 in systemd unit.
Gotchas
- Running as root - security risk. Fix: dedicated user in unit file.
- Disk full on
target/- incremental builds fail oddly. Fix: monitordf, clean old artifacts. - Wrong timezone in logs - UTC vs local confusion. Fix: log UTC in app; set
TZfor shell only. - SELinux blocking binary - permission denied on custom paths. Fix:
audit2whyor documented context. - journald rate limit - missing crash logs. Fix: adjust
RateLimitIntervalfor debug windows.
Alternatives
| Alternative | Use When | Don't Use When |
|---|---|---|
| Docker only | No SSH on prod | Debugging host networking |
| Ansible | Repeated fleet setup | One-off local VM |
| Kubernetes | Orchestrated pods | Single VM prototype |
FAQs
systemd vs supervisord?
systemd is default on modern Linux; use native units for Rust daemons.
Where do println logs go?
journald when stdout connected; prefer structured tracing either way.
Related
- Process & resource management
- Deployment basics
- rustup & toolchain management
- Linux CLI Best Practices
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.