Ubuntu 14.10 Tip: Automatic Shutdown When Lid is Closed

automatic shutdown when lid is closed

Ubuntu provides a built-in Power utility which allows to choose your laptop behavior when the lid is closed. However, there are only “Suspend” and “Do nothing” available out-of-the-box.

What if you want to shutdown or hibernate Ubuntu automatically when laptop lid is closed?

See what I did in my 64-bit Ubuntu 14.10:

1. Press Ctrl+Alt+T on keyboard to open the terminal. When it opens, paste the command below and hit enter to edit the systemd-logind settings:

sudo gedit /etc/systemd/logind.conf

Replace gedit with vi or nano if you’re on Ubuntu server without a graphical user interface.

Type in user password when it asks. Note that there will be no visual feed back when type in a password.

2. When the file opens, find out the line #HandleLidSwitch=suspend. Remove the # and change the value so it will be:

HandleLidSwitch=poweroffpower off when lid is closed.


HandleLidSwitch=hibernatehibernate when lid is closed

3. After saved the changes, restart the computer so it takes place in next boot.