Linux: How do I keep my laptop running when the lid is closed?

In short,

sudo vim /etc/systemd/logind.conf

Find and uncomment the following lines, and change the values

HandleLidSwitch=lock
HandleLidSwitchExternalPower=lock
HandleLidSwitchDocked=ignore

Save and exit, and 

sudo systemctl restart systemd-logind

Comments

  1. Markdown is allowed. HTML tags allowed: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.