Disable Laptop Suspend When Lid Closes in Ubuntu
- 12 steps
- Needs administrator rights
- Includes a restart or sign-out
Disabling lid suspend in Ubuntu stops the laptop from going to sleep when you close the screen. Ubuntu 22.04 and later suspend the system by default to save battery. Turning that off lets you keep long file downloads or server tasks running with the lid shut.
The change is made by editing one plain-text configuration file, which tells Ubuntu to ignore the closed lid. You need an account that can use sudo. The steps are the same on every Ubuntu edition and flavor that uses systemd.
To stop Ubuntu from suspending when you close the lid, open a terminal and run sudo gedit /etc/systemd/logind.conf. Find the line #HandleLidSwitch=suspend, remove the #, change suspend to ignore, save, then run sudo systemctl restart systemd-logind.service. Alternatively, install GNOME Tweaks and switch off Suspend when laptop lid is closed under General.
How to keep the laptop on when the screen is closed in Ubuntu Linux
The fix is to edit the systemd logind configuration file and set the HandleLidSwitch option to ignore. In short, you open the terminal, edit the logind.conf file and change that one setting. Downloads keep running, and you can use an external monitor with the lid closed.
The default value is suspend. To undo the change later, set it back to suspend and apply the change again.
To stop Ubuntu from suspending when you close the lid, work through the steps below in order. The first method edits the system file. If it doesn’t work on your machine, a second method using GNOME Tweaks follows.
These steps use systemd, the background service manager in modern Linux. Its login manager, systemd-logind, decides what happens when you close the lid, press the power button or leave the machine idle.
- Press Ctrl+Alt+T to open the command console, often called a terminal. A window with a command prompt should appear.
If the shortcut does nothing, open the Activities overview, search for Terminal and click it.
- Run the following commands in the terminal.
The commands open the logind configuration file in a text editor with administrator rights. If you are asked for your password, type it and press Enter. Nothing appears on screen while you type, and that is normal.
sudo gedit /etc/systemd/logind.conf
- Look at the file that opened and find the line below.
The file is mostly commented-out defaults, so you may need to scroll down. Lines that start with a # are ignored by the system.
#HandleLidSwitch=suspend

- Change the line to the version below. If the line begins with a #, delete that character, because the setting does nothing while it is commented out.
The line should now read HandleLidSwitch with the value ignore, and it should have no # in front.
HandleLidSwitch=ignore

- Save your changes and exit the editor.
In nano, the usual editor for this kind of task, press Ctrl+O, then Enter to confirm the file name, then Ctrl+X to exit. You should be back at the command prompt.
- Run the commands below to apply your changes.
sudo systemctl restart systemd-logind.service
- Restart your computer and test the result.
To test, close the lid for a minute or two, then check that your download or task is still running. If the screen stays dark after you reopen the lid, move the mouse or press a key. If the laptop still suspends, check that the line has no # in front and that you saved the file.
If those steps don’t work, install GNOME Tweaks, a tool that manages desktop settings. It changes the same behavior from the desktop side, so you don’t have to edit any files.
- Run the commands below to install it. You will need your password again.
The installer prints a lot of text. Wait until you get your command prompt back before moving on.
sudo apt install gnome-tweaks
- Open the Activities overview and search for Tweaks.
- Click the Tweaks icon to launch the app.
The Tweaks window should open with a list of categories down the left side.

- Select General in the left pane.
- Switch the toggle for Suspend when laptop lid is closed to Off.
The toggle should turn grey. If you don’t see this option in your version of Tweaks, use the logind.conf method above instead. To undo the change, switch the toggle back On.

Conclusion:
- Ubuntu Linux provides a straightforward way to change the laptop lid close behavior to “ignore,” allowing users to avoid automatic suspension when the lid is closed.
- By modifying the HandleLidSwitch parameter in the login.conf file or by using the Gnome Tweaks application, users can keep their laptop running even when the screen is closed.
- With these simple steps, Ubuntu Linux users can ensure their work continues uninterrupted when the laptop lid is closed, providing greater flexibility and control over power management.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!