The answer comes from a small Unix hack that serves as a workaround for the file. Adding a single command to it should allow users to shut their machine down as soon as they push the power button, regardless of whether you’re actually at the lock screen, where this behavior is expected, or at the desktop where it isn’t.
Enabling the PC Power Button
Some users have tried to short out by adding shutdown -h now to the section immediately before if pidof x $PMS > /dev/null, but this doesn’t work in modern versions of Ubuntu. Editing the file is the right call, however, but you’ll need root access to do it. This is a protected system file, which means that you can’t edit it with your usual user privileges. First, lock up your PC by holding down the Super key and pushing L. This is generally the Windows key on most keyboards, but if you’re running Ubuntu with an Apple Macintosh keyboard plugged into your machine you’ll need to hold down the Command Key with the “⌘” logo on it. As long as you didn’t leave any programs running, push the power button and make sure that your system shuts down. Don’t do this, however, if you have any programs running. Enter your password instead and then close said applications. If you’re given an options menu when you push the power button, then reboot the machine and try it again. Once you’ve successfully been able to do so, reboot the machine back to an Ubuntu desktop and open a terminal. You may wish to start it from the Dash or Whisker Menu. Alternatively, you can hold down Ctrl, Alt and T to start it up. Type and then enter your password when prompted for it. You’ll be given the option to edit the file in question, but don’t go scrolling through the code.
Push the enter key one time to create a new line up top, and then push the up arrow cursor key to place the cursor at the start of said new line. Type shutdown -h now and then hold down the Ctrl key. Push O while holding Ctrl to save it and then use Ctrl+X to quit. Type exit at the CLI prompt to close the terminal window.
Once you’ve closed all of the applications, feel free to push the power button to see if the shutdown options window comes up or not. If your machine shuts down properly, then you’re all set. Otherwise, you’ll want to try restarting the machine and then pushing the power button once again. You shouldn’t need more than this second reset to make the changes finally stick. While this works in the majority of cases, there are two caveats to consider. The first is that this is a simple hack, and it’s by no means a workaround that enjoys official support. There’s always the possibility that a future update to Ubuntu might actually make it obsolete, and some software update might consider the shutdown -h now line an error and comment it out. Should you ever notice that it suddenly stopped working then you should try opening the file with the , command again. You might need to remove a comment mark indicated by the # symbol, or you might need to add that line of code in for a second time. The second problem comes from the fact that this only works on systems that fully support ACPI technology. Advanced Configuration and Power Interface (ACPI) is a power management scheme supported by Intel and Toshiba, which originally came from the so-called Wintel world. While it’s highly doubtful that any machine too old to support ACPI can even run a graphical Ubuntu desktop, there is a chance that some proprietary ACPI schemes don’t play nice with Ubuntu. Users who don’t have the file and aren’t using LXDE or another lightweight management solution might suffer from this problem. It’s also possible that a needed package might have been removed, which will recreate the directory when reinstalled. Should this be the problem, you may want to run sudo apt-get -f install before trying the command. This will quickly repair any broken packages you might have. Eventually, it should simply turn off, but you’ll still see the Ubuntu Plymouth powering down graphic when you do so. Your machine shouldn’t be shutting down drastically, so you might have a related ACPI problem if you’re constantly seeing a message on boot about recovering from a journal. If this is the case, then you might wish to avoid using this workaround because what you’re doing is the same thing as physically pulling the cable out of the back of your PC.
Ubuntu 18.04 LTS Bionic Beaver Officially Available for Ubuntu, Kubuntu,…How to: Create an Ubuntu Bootable USB on Mac, Windows or UbuntuUbuntu 16.04.5 LTS Released on Heels of Ubuntu 18.04 LTS, Bundles All Past…SOLVED: “Unable to initialize audit layer: Permission denied” bug in libvirt-bin…