Shutdown Ubuntu 14.04 LTS When The Lid Is Closed

shutdown ubuntu when lid is closed

Already upgraded to Ubuntu 14.04? Well, you may want to change your laptop behaviour when the lid is closed.

You can easily set the vaule to “Suspend” or “do nothing” in System Setting -> Power window. Here’s how to shutdown (or hibernate) Ubuntu when you close the lid of your laptop.

To get started:

1. Press Ctrl+Alt+T on keyboard to open the terminal. When it opens, run the command below to open the configuration file via gedit editor:

sudo gedit /etc/systemd/logind.conf

Replace gedit with vi or other text editor if you’re on Server edition.

2. Find out the line #HandleLidSwitch=suspend, remove the # and change it to:

  • HandleLidSwitch=poweroff to shutdown computer when lid is closed
  • HandleLidSwitch=hibernate to hibernate computer when lid is closed
  • HandleLidSwitch=ignore to do nothing

3. Save the file and restart the service or just restart your laptop to apply changes.

sudo restart systemd-logind

Update: for Ubuntu 16.04, the command to restart the systemd service should be:

systemctl restart systemd-logind.service

That’s it. Enjoy!

By Ji m

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to remind me outdated tutorial! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

11 comments

  1. Thanks for your wonderful tutorial. I’m new to ubuntu and I can’t find the dropdown field “When the lid the is closed” in the Power Setting. I’m using Asus K55VD Latop and Ubuntu 14.04 LTS.

  2. Well.. no no no.. it worked with 12.04 but with 14.04.1 it just does…. nothing.

    Any /var/log/ file where I can verify the correct behaviour ?

  3. Disable all 4:
    HandlePowerKey=ignore
    HandleSuspendKey=ignore
    HandleHibernateKey=ignore
    HandleLidSwitch=ignore

  4. Nice It almost worked for me but I don’t want to ignore at all I want that when the lid it’s closed it shutdown the screen but do not suspend or hibernate.

    Any way to do this??

  5. HandleLidSwitch=ignore used to work but with 14.04 does nothing. The GUI settings offer nothing, as they only apply to the logged in user.

  6. With this advice I was able to disable my laptop’s annoying habit of going to sleep during shutdown while lid is closed. I use external screen whenever possible, thus it’s more likely for the lid to be closed when I shut the laptop, thus I constantly had to wake it for either the shutdown to continue, or to redo the shutdown, sometimes having to login first. Even if not using an external screen, doing a hasty shutdown in a hurry often resulted to even more delay due to abovementioned reasons, as I often closed the lid too soon, putting the laptop to sleep.

    Ubuntu MATE 14.04.

    Also, I would recommend suggesting nano rather than vi, as nano is more beginner-friendly by constantly having “help-section” visible, showing main-commands. For a terminal-newbie, vi is a nightmare (I still remember *shudders*).

Comments are closed.

Exit mobile version