How to prevent your Linux computer from falling asleep with Caffeine

Operating Systems do not always do precisely what you would like or expect them to do. For example, they are set up in such a way that they make your computer fall asleep to reduce the energy consumption of your laptop, or to ensure that if you have a toilet break, someone else does not abuse your absence. But there are situations where you want to avoid that, such as a lengthy download of a huge file, compiling your big software project, making a backup, or rendering your latest blockbuster movie. In those cases, you don’t want your Linux computer to go to sleep while processes are busy doing their job. The solution is Caffeine. In this article, I will explain how to prevent your Linux computer from falling asleep with Caffeine.

Content of this article

  1. What is Caffeine
  2. How to download and install Caffeine
  3. How to use Caffeine

What is Caffeine

If you want to be absolutely sure that your computer won’t go to sleep due to the default power settings of your Linux installation, you’ll want to use a tool that gives you control over when and how long your Linux computer stays active. As indicated in the introduction, there are many conceivable applications where you cannot use unexpected behavior from your operating system, such as rendering/exporting your final video editing result or a long backup or restore process. Caffeine is a free and open source tool that makes this possible. Caffeine can be operated via the command line but also offers a simple graphical solution, a nice hot cup of coffee, via the system tray.

If you have moved from OS X / macOS to Linux you will probably have heard of the Amphetamine tool, which is a popular keep-awake utility for the Mac. But in the time that I still used the Apple environment, I used an app which was also called Caffeine for the same purpose. Former Windows users also had multiple solutions, and one of them was named…you guessed it…Caffeine. So we have a caffeine app for all platforms, but they are actually unrelated.

You might wonder why you couldn’t just do the same in the Power Saving options of your Linux Settings. That is only partly true, since for example in Ubuntu the maximum automatic suspend time is 2 hours. In addition, more steps are needed to adjust the power settings. caffeine offers a much simpler solution that also gives you the freedom to decide for yourself how long you want to keep the computer from sleep mode.

How to download and install Caffeine

Downloading and installing Caffeine couldn’t be easier if you are using an Ubuntu-based distro like Linux Mint, Zorin, etc., because Caffeine is part of the default Ubuntu repository.

1) Open the Software app.

2) Search for Caffeine.

3) Select Caffeine.

4) Click on Install.

5) When the installation is complete, search within your applications for Caffeine. You will find two icons, Caffeine, and Caffeine Indicator.

6) Click on Caffeine Indicator.

Now you will see the Caffeine icon in your system tray.

Off course you can also install caffeine by using the command line if that is your preference:

1) Use Ctrl + Alt + T to open your Terminal app.

2) Type “sudo apt update’ and hit Enter.

3) Type “sudo apt install caffeine”  and hit Enter.

How to use Caffeine

Using Caffeine is even simpler than downloading and installing. 

1) Click on the empty coffee cup in the system tray.

2) Select the option Activate.

Now you will see a steaming hot cup of coffee to show you that Caffeine is active.

As long as you keep it like this Caffeine will stay active and your system will not fall asleep. When it is time to stop Caffeine, just do the same as before and select the option Deactivate.

An additional point of attention. By default, Caffeine is not available in your system tray after every boot-up of your computer. In principle, Caffeine is active underwater, but if you also want the Caffeine Indicator to be visible by default, simply add it to your Startup Applications Preferences.

Final words

There are several solutions available for Linux to prevent your computer from going to sleep unintentionally. Personally, I like Caffeine. simple solution, because it can only be active or inactive, nothing more. It really couldn’t be simpler. No additional settings. it does exactly what it should.


Have a look at my latest book on Linux, in Paperback or Kindle format.

For more info on my book click here.

When you want to buy the book click on the image below.


If you appreciate what I do on this website…,

User Avatar

About John Been

Hi there! My name is John Been. At the moment I work as a senior solution engineer for a large financial institution, but in my free time, I am the owner of RealAppUser.com, RealLinuxUser.com, and author of my first book "Linux for the rest of us". I have a broad insight and user experience in everything related to information technology and I believe I can communicate about it with some fun and knowledge and skills.

View all posts by John Been →