Ubuntu shut down

If you use Ubuntu or a system derived from it and want to change the behavior of the system when the laptop lid is closed, here’s how to do it.

Usually, when lowering the cover of a laptop it goes into hibernation, but this is not always the behavior that the user wants.

For example, the system can also be turned off. If you still do not know how to configure ubuntu shutdown command, follow this tutorial and find out.

How to configure Ubuntu to shut down and hibernate when the lid is closed

To configure Ubuntu to shut down when the Laptop lid is closed, you can open the “System Settings” and go to the “Power” item.

Although the power settings provide only the ‘Suspend’ and ‘Do nothing’ options for the closing actions of your laptop, you can make a small change in the Systemd configuration file to do more actions. To do this, do the following ubuntu shutdown command:

Step 1: Open a terminal (Using Dash or pressing CTRL + ALT + T) 

Step 2: Run the command below to open the configuration file via text editor Gedit

sudo gedit /etc/systemd/logind.conf

Step 3: Find the line # HandleLidSwitch = suspend, after that to remove the # symbol and change it to the behavior corresponding to what you want to use.

For example, to shut down the computer when the cover is closed, leave the following commands:

HandleLidSwitch=poweroff

Step 4: To hibernate the computer when the cover is closed, leave the following:

HandleLidSwitch=hibernate

Step 5: To do nothing, use this command:

HandleLidSwitch=ignore

Step 6: Save the file and close it.

Step 7: Run the Ubuntu restart command below or simply restart the computer to apply the changes

sudo restart systemd-logind

Or

systemctl restart systemd-logind.service

For some laptops, the hibernation function may not work. Execution hibernation command:

sudo pm-hibernate

The above procedure will not add the shutdown or hibernation options in the power settings, but will make the function work directly when you close the lid.

After the computer is turned off, turn it on again.

Have previous open applications reopened?

If hibernation does not work, make sure your swap partition is at least as large as the available RAM.

LEAVE A REPLY

Please enter your comment!
Please enter your name here