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=poweroffto shutdown computer when lid is closed
HandleLidSwitch=hibernateto hibernate computer when lid is closed
HandleLidSwitch=ignoreto 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!