Setting Up NUT (Network UPS Tools) for Automated Safe Shutdown on Power Loss
Buying a UPS only solves half the problem. Left alone, it just runs on battery until it dies — and if that happens while your NAS or hypervisor is still writing data, you get the exact filesystem corruption a UPS was supposed to prevent. NUT (Network UPS Tools) is the free, open-source software that closes that gap: it watches the UPS over USB and triggers an orderly shutdown of your host(s) before the battery runs out.
Search intent
Someone searching this already owns a UPS and wants it to actually protect their systems — a config walkthrough for wiring a UPS into an automated shutdown, not a UPS buying guide.
What you’ll need
- A UPS with a USB connection to a Linux host (most consumer/prosumer UPS units — APC, CyberPower, Eaton — support USB-based monitoring; check your model’s manual for USB HID support if unsure).
- A Linux machine to run NUT — this can be the same host doing the work (a NAS, hypervisor box) or a dedicated small always-on machine.
- Root/sudo access, 20-30 minutes.
How NUT is structured
NUT has three components, and understanding them upfront makes the config make sense:
- A driver (
usbhid-upsfor most modern USB UPS units) — talks directly to the UPS hardware and translates its status into a common format. upsd— the server that reads from the driver and serves UPS status to clients over the network (even if that’s justlocalhost).upsmon— the monitoring client that watchesupsd, decides when the battery is critically low, and triggers the actual shutdown command.
For a single-host setup (NUT running on the same machine the UPS is plugged into and protecting), all three run locally. For a shared setup (one UPS, multiple hosts), other machines run just upsmon pointed at the host serving upsd over the network.
Step 1: Install NUT
On Debian/Ubuntu:
sudo apt update
sudo apt install nut
This installs the driver, upsd, and upsmon together. (Some distros split nut-server and nut-client into separate packages — install both if so.)
Step 2: Identify your UPS and configure the driver
Plug the UPS into the host via USB, then check it’s detected:
lsusb
You should see your UPS vendor listed (APC, CyberPower, Eaton, etc.). Then edit /etc/nut/ups.conf to add your UPS:
[myups]
driver = usbhid-ups
port = auto
desc = "Main server rack UPS"
usbhid-ups handles the vast majority of modern USB UPS units regardless of brand, since USB HID power-device class is a standard. If your specific model needs a different driver, NUT’s hardware compatibility list (bundled in the docs) will name it.
Step 3: Configure upsd to listen and set access mode
Set NUT’s operating mode in /etc/nut/nut.conf:
MODE=standalone
(Use netserver instead if other hosts will monitor this same UPS over the network.)
Then add a monitoring user in /etc/nut/upsd.users:
[upsmon_local]
password = <choose-a-strong-password>
upsmon primary
Lock down the permissions on this file, since it holds a plaintext password:
sudo chmod 640 /etc/nut/upsd.users
Step 4: Configure upsmon
Edit /etc/nut/upsmon.conf and add:
MONITOR myups@localhost 1 upsmon_local <same-password-as-above> primary
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
MONITOR ... primary means this host owns the UPS connection directly. The 1 is the number of power supplies this UPS represents to the host (leave at 1 for a typical single-UPS setup). SHUTDOWNCMD is what actually runs once upsmon decides the battery is critically low — the default triggers an immediate clean shutdown.
Step 5: Start the services
sudo systemctl enable --now nut-server
sudo systemctl enable --now nut-client
(Service unit names vary slightly by distro — nut.target, nut-server, and nut-monitor are the common variants; check systemctl list-units | grep nut if the names above don’t match.)
Step 6: Verify it’s actually working
Query live UPS status:
upsc myups@localhost
This dumps every variable NUT can see — battery charge, load, status, runtime estimate. Two worth watching specifically:
upsc myups@localhost battery.charge
upsc myups@localhost ups.status
ups.status should read OL (on line power) normally, and switch to OB (on battery) when you unplug the UPS from the wall — test this deliberately to confirm NUT notices the transition before trusting it in a real outage.
Step 7: Test the shutdown trigger (during a maintenance window only)
Don’t wait for a real outage to find out SHUTDOWNCMD doesn’t work. Force NUT into its shutdown path:
sudo upsmon -c fsd
Only run this against a host you’re prepared to have shut down right now — it triggers the real configured shutdown command, not a dry run. Confirm the host actually powers down cleanly, then bring it back up and verify NUT reconnects to the UPS on boot.
Multi-host setups: shutting down more than one machine from one UPS
If one UPS powers a NAS and a hypervisor host, run upsd (mode netserver) on whichever machine has the USB connection, then on the other host(s) configure upsmon as a secondary:
MONITOR myups@<primary-host-ip> 1 upsmon_remote <password> secondary
Add a matching user in the primary’s /etc/nut/upsd.users, and open the NUT port (3493/tcp) between the hosts on your local network only — this port has no reason to be reachable from outside your LAN. Now both hosts shut down together when the shared UPS hits its threshold, rather than only the one it’s physically plugged into.
Platform notes
- Proxmox: no built-in UPS UI, but NUT installs and runs as a normal Debian package on the Proxmox host itself, and
SHUTDOWNCMDcan be scripted to gracefully stop guests (viapveshorqm shutdown) before the host powers off. - TrueNAS: has NUT integration built into the web UI (Services → UPS) — point it at the USB-connected UPS and set a shutdown threshold there instead of hand-editing config files.
- Synology/QNAP: use their own native UPS monitoring (DSM/QTS Control Panel → Hardware → UPS) rather than NUT — see the best UPS for a home server rack guide’s shutdown-integration section for that path.
Bottom line
NUT is free, well-documented, and the standard answer for Linux-based UPS shutdown automation outside the Synology/QNAP walled gardens. The setup is a handful of config files, but the step people actually skip is Step 7 — testing the real shutdown trigger during a planned window. Do that test before you need it to work during an actual outage.