Skip to content
Ubuntu Linux

Disable Laptop Suspend When Lid Closes in Ubuntu

Richard
Written by
Richard
Updated 4 min read
Enable Auto Login on Ubuntu Linux: Step-by-Step Guide
Enable Auto Login on Ubuntu Linux: Step-by-Step Guide
Before you start
  • 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.

⚡ Quick Answer

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.

Advertisement

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.

Advertisement

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.

  1. 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.

  1. 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.

🐧Bash / Shell
sudo gedit /etc/systemd/logind.conf
  1. 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.

💻Code
#HandleLidSwitch=suspend
Ubuntu logind.conf file with HandleLidSwitch set to ignore
ubuntu linux lid close action ignore
  1. 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.

💻Code
HandleLidSwitch=ignore
Ubuntu terminal showing HandleLidSwitch=ignore configuration change
ubuntu linux lid close action to ignore
  1. 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.

  1. Run the commands below to apply your changes.
⚠️WarningSave any open work first. Restarting the login service can briefly disturb your desktop session, and in some cases it logs you out.
🐧Bash / Shell
sudo systemctl restart systemd-logind.service
  1. 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.

  1. 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.

🐧Bash / Shell
sudo apt install gnome-tweaks
  1. Open the Activities overview and search for Tweaks.
  2. Click the Tweaks icon to launch the app.

The Tweaks window should open with a list of categories down the left side.

Ubuntu Tweaks application search and launch screen
ubuntu tweaks search launch
  1. Select General in the left pane.
  2. 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.

Ubuntu Tweaks power settings showing lid close action options
ubuntu linux tweak lid close action
⚠️WarningThat should do it! Close the lid once more to confirm the laptop stays awake. Keep in mind that a closed laptop that keeps running produces heat with no airflow, so don’t put it in a bag while it is working.

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?

Richard

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.

Advertisement

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *