How to Change Lid Close Behavior in Ubuntu/Linux

2 min readJan 30, 2021

So i usually just close the lid of my laptop when i have to get out of my blanket or for any other reason to do a work which might take 5 sec or 5 min. But when i open the lid back, it always prompted me to enter my password. I wanted to make it function like macbook, just close the lid and open up lightening fast exactly how i closed it.

Here are two ways to do this. First one is by changing some settings while other method includes usage of terminal.

Method 1 : Settings

Goto Settings > privacy > Screen lock

Toggle the ‘Lock screen on suspend’

Here just turn off the ‘Lock screen on suspend’. If in case you have any other OS version or other linux distro and cannot find this option, follow method 2.

Method 2 : Terminal

Step 1: Open your terminal and type the following command :

sudo gedit /etc/systemd/logind.conf

Step 2 : In the opened file, find #HandleLidSwitch.

Line number 24 here.

Step 3 : To uncomment the line and make it apply-able , remove the ‘#’ from that line.

Step 4 : Now it can have many options like following :

HandleLidSwitch=lock (lock when lid closed)

HandleLidSwitch=ignore (do nothing)

HandleLidSwitch=poweroff (shutdown)

HandleLidSwitch=hibernate (hibernate Ubuntu)

Set it as ignore and save the file.

Final product

Step 5 : Now apply the changes by restarting the session. To do that, run the following command in your terminal.

systemctl restart systemd-logind.service

Connect with me by visiting :)