Linux CLI Best Practices
Eighteen practices for a fast, ergonomic terminal workflow around Rust development and operations.
-
Use
rgfor search: Respects.gitignore; excludestarget/by default. -
Use
fdfor paths: Faster thanfindforsrc/**/*.rsdiscovery. -
Install tools via rustup + documented brew/apt list: Avoid ancient distro
rustc. -
Pin
rust-toolchain.tomlin repo: Matches CI and eliminates "works on my machine" version drift. -
cargo build --release --lockedfor prod artifacts: Debug binaries mislead benchmarks. -
cargo bloatbefore binary diet: Data-driven dependency removal. -
cargo watchfor TDD loop: Pair withnextestfor speed. -
Global gitignore
target/and.env: Prevent accidental commits. -
Structured JSON logs locally when debugging prod issues: Match production
tracingformat. -
SIGTERM integration tests: Verify graceful shutdown before k8s deploy.
-
perforsamplyfor CPU mysteries: Do not optimize from intuition alone. -
Monitor open fd count under load: Catches connection pool leaks early.
-
journalctl for systemd services: Centralized Rust service stdout/stderr.
-
Compose pipelines in
scripts/: Ad-hoc one-liners become team assets. -
jqfor JSON log queries: Works withtracingJSON subscriber output. -
ulimit -nbefore load tests: Matches production fd limits. -
Separate build and inspect concerns: Build in CI; inspect symbols in staging with debug info retained.
-
Document required CLI tools in onboarding checklist: New hires install once, correctly.
FAQs
macOS vs Linux commands?
Prefer portable tools (rg, fd); note GNU/BSD sed differences in scripts.
Windows developers?
WSL2 for Linux-aligned workflow; native MSVC for Windows-target builds.
Related
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+.