If you have a UPS dedicated to your Ubuntu workstation, Ubuntu “Power Management” can meet your requirements. See details in this post. If you have an APC UPS, another option is to use apcupsd, which is a more advanced tool to manage your APC UPS. UPS protects the computer from (usually instantaneous, but often dangerous) surge of electricity, just connecting computer with the UPS (usually with USB connection). apcupsd is an Open Source software with excellent documentation which additionally can gracefully shut down your computer some minutes after power outagecan force computer restart when the power returns (if AC back function supported by computer BIOS)You may use command line interface or Web interface or graphical interface (gapcmon) to monitor your UPS. The model of the APC UPS used in this tutorial is “APC Back UPS BR1500GI RS 1500VA (LI)”. Installation Open a terminal and type 1sudo apt-get install apcupsd (For information on how to install software without using command line, see this post). After installation, directory /etc/apcupsd contains: configuration files apcupsd.conf the MAIN configuration file hosts.conf other computers supported by the same UPS (NIS network driver for slaves) multimon.conf parameters to display in web interface executable files apccontrol here you will find the various events, which apcupsd can manage (power outage etc.). If you want o make changes, DO NOT modify this file directly, but create a script with the name of an event and place it in /etc/apcupsd (eg a custom script /etc/apcupsd/doshutdown will be executed first when the doshutdown event enabled). changeme sends email to change the UPS battery commfailure sends email when connection with the UPS is lost commok sends email when connection with the UPS is established offbattery sends email when your computer runs on power onbattery sends email when your computer runs on battery (UPS) executable files (Debian specific) ups-monitor Debian creates the symbolic link /etc/init.d/ups-monitor → /etc/apcupsd/ups-monitor. So, Debian halt script (/etc/init.d/halt) executes it. In this way, it kills power in the UPS (/etc/apcupsd/apccontrol -killpower) after the shutdown of the system (if there is the file /etc/apcupsd/powerfail, which is then deleted) killpower any actions that need to be executed before power interruption in the UPS (apcupsd -killpower) temporary files powerfail “Flag file” created by apcupsd before shutdown the system, in order to inform the halt script that the shutdown is due to power outage (power fail) Concerning the executables which send email If you want this email functionality, you have to install a message transfer agent (MTA). A lightweight option would be exim 1sudo apt-get install exim4 Additionally, you have to forward root mail to your email, as apcupsd sends email to sysadmin by default. See this post for details. Concerning the UPS “killpower” The power supply interruption in USB UPS will be done 60 sec after the shutdown of the computer. Otherwise, you have to make changes in the EEPROM of the UPS (not recommended). Configuration STEP 1 – Edit main configuration file First, create a backup of main configuration file: 1sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.bak Using your favorite text editor (nano in my case): 1sudo nano /etc/apcupsd/apcupsd.conf Find and edit UPSCABLE, UPSTYPE, DEVICEand optionally BATTERYLEVEL and MINUTESIn most models, the following changes are enough. 1234567891011121314151617181920212223242526272829303132...UPSCABLE usb...UPSTYPE usb......BATTERYLEVEL 30...MINUTES 10 STEP 2 – Edit /etc/default/apcupsd Using your favorite text editor (nano in my case): 1sudo nano /etc/default/apcupsd set: STEP 3 – Finally, restart apcupsd Open a terminal and type: 1sudo systemctl restart apcupsd.service View logs To view apcupsd logs, open a terminal and type: 1tail /var/log/apcupsd.events Command line interface To get information about your UPS status, use the command: So, in my workstation (named “athena”) the output is: 12345678910111213141516171819202122232425262728293031323334353637APC      : 001,036,0875DATE     : 2016-12-10 18:08:03 +0200HOSTNAME : athenaVERSION  : 3.14.12 (29 March 2014) debianUPSNAME  : athenaCABLE    : USB CableDRIVER   : USB UPS DriverUPSMODE  : Stand AloneSTARTTIME: 2016-12-10 10:12:12 +0200MODEL    : Back-UPS RS 1500GSTATUS   : ONLINELINEV    : 224.0 VoltsLOADPCT  : 10.0 PercentBCHARGE  : 100.0 PercentTIMELEFT : 66.7 MinutesMBATTCHG : 40 PercentMINTIMEL : 15 MinutesMAXTIME  : 0 SecondsSENSE    : MediumLOTRANS  : 176.0 VoltsHITRANS  : 294.0 VoltsALARMDEL : No alarmBATTV    : 27.2 VoltsLASTXFER : Unacceptable line voltage changesNUMXFERS : 0TONBATT  : 0 SecondsCUMONBATT: 0 SecondsXOFFBATT : N/ASELFTEST : NOSTATFLAG : 0x05000008SERIALNO : 3Q1106X37131BATTDATE : 2012-07-05NOMINV   : 230 VoltsNOMBATTV : 24.0 VoltsNOMPOWER : 865 WattsFIRMWARE : 878.L4 .I USB FW:L4END APC  : 2016-12-10 18:08:05 +0200 Web interface apcupsd offers a handy web interface to monitor your UPS. To install it, open a terminal and type 1sudo apt-get install apcupsd-cgi Of course, a web server is needed to use the web interface. For example, to install Apache (if not installed): 1sudo apt-get install apache2 To access web interface, point your browser to http://localhost/cgi-bin/apcupsd/multimon.cgi Here is the main page: To get details, click the “Local host” link The “All data” link is similar to apcaccess output Graphical interface (gapcmon) Unfortunately gapcmon is not yet available for latest Ubuntu versions (as Xenial 16.04 etc). See here for details. However, this is how the main screen looks like: The Historical Summary section The Detailed information section Test your UPS STEP 1 Modify the TIMEOUT parameter from 0 to 60 to force the computer shutdown after 60 sec from power failure, rather than running on battery until the battery is empty. 1sudo nano /etc/apcupsd/apcupsd.conf Restart apcupsd service: 1sudo systemctl restart apcupsd.service STEP 2 Disconnect power from the UPS. Your computer should be shut down in 60 seconds. STEP 3 Reset TIMEOUT parameter 1sudo nano /etc/apcupsd/apcupsd.conf Restart apcupsd service: 1sudo systemctl restart apcupsd.serviceEntrepreneur | Full-stack developer | Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects. EHR for Small Medical Practices Medical records. Appointments. Electronic invoicing. $9/month