Archives For Howtos

The open-source LaTeX editor TeXstudio 4.0.0 was released! Here’s how to install it in Ubuntu via PPA repository.

TeXstudio 4.0.0 offers Qt6 support which should improve HiDPI handling. And the official packages for Windows and macOS are now based on Qt6, while Linux build sticks to Qt5.

The final release is out after 8 alpha, 3 beta and 2 release candidate tests, though it’s announced only with following changes:

  • Adapt to Qt6/poppler-qt6
  • OSX/win build provided with Qt6
  • Remodel structure handling in order to avoid (rare) crashes
  • More and updated completion word lists thanks to mbertucci47
  • Handle text (e.g. \text{text}) in mathenv as text with spell checking
  • Performance improvement for large files with large number of labels and/or large number of includes
  • Fix that search options are persistant
  • Automatic structure scrolling can be turned off
  • Some bug fixes

How to Install The Latest TeXstudio in Ubuntu:

The LaTeX editor has an official Ubuntu PPA that contains the latest packages for Ubuntu 18.04, Ubuntu 20.04, Ubuntu 21.04, Ubuntu 21.10, Ubuntu 22.04 and their derivatives, e.g, Linux Mint 20, Zorin OS 16, and Elementary OS 6.

NOTE: The steps below should ALWAYS install the latest version of TeXstudio in current Ubuntu releases, unless the software developer abandons the PPA!

1.) Add the PPA.

Firstly, open terminal by either searching from upper left corner Activities overview screen, or pressing Ctrl+Alt+T key combination on keyboard. When terminal opens, paste the command below and run to add the PPA:

sudo add-apt-repository ppa:sunderme/texstudio

Type user password (no visual feedback) when it asks and hit Enter to continue

2.) Update system package cache.

For Ubuntu 18.04 and some distributions, e.g., Linux Mint, you need to manually refresh the package cache by running command in terminal (though it’s done automatically in Ubuntu 20.04 & higher):

sudo apt update

3.) Install / Upgrade TeXstudio

Finally, either install the LaTeX editor by running apt command in terminal:

sudo apt install texstudio

Or, use “Software Updater” (Update Manager) utility to upgrade the package if an old version was installed.

Uninstall TeXstudio & Remove PPA:

To uninstall the editor package, simply run apt command with remove flag in terminal:

sudo apt remove --autoremove texstudio

And remove the Ubuntu PPA either by running command:

sudo add-apt-repository --remove ppa:sunderme/texstudio

or open and navigate to ‘Software & Updates’ -> ‘Other Software’ and remove the relevant repository line.

For laptop and desktop PC with more than one audio input and output devices, it’s possible to switch between audio devices quickly with upper right corner system tray menu.

It’s a common situation that users have more than one audio devices connected to the computer. GNOME, the default Ubuntu Desktop Environment, provides Sound settings to choose which input and/or output device to use.

To make life easier, a Gnome extension is available to integrate the settings into system tray status menu under volume control slider. So users can quickly choose a speaker, HMDI, microphone or other input device via few clicks.

The extension offers a setting dialog allows to select which device, e.g., HDMI , Speakers, microphone etc, you would like to display or hide in menu. It’s possible to hide the menu when there’s only one choice, or manually toggle visible of either menu, as well as audio profiles.

Install the audio device chooser extension:

The extension supports up to GNOME 40, it works on Ubuntu 18.04, Ubuntu 20.04, Ubuntu 21.04, and next Ubuntu 21.10. As well, all recent GNOME based Linux distros, e.g., Debian 11, Fedora 34, CentOS 8, and Manjaro are supported.

1.) Firstly, open terminal by either searching from activities overview or pressing Ctrl+Alt+T on keyboard.

2.) When terminal opens, run command to install the chrome-gnome-shell package which allows to install Gnome extensions using your web browser. Also install gnome-shell-extension-prefs (Gnome Extensions app) package, the tool to manage all installed extensions.

sudo apt install chrome-gnome-shell gnome-shell-extension-prefs

3.) Finally, go to the link button below and turn on the slider icon to install the extension.

Don’t worry if you don’t see the toggle icon, install the browser extension via ‘Click here to install the browser extension’ link and refresh the web page will make it visible.

After installation, search for and open “Gnome Extensions” from the overview screen. Then click on the gear button for this extension to configure the audio device chooser menu.

That’s all. Enjoy!

gThumb image viewer and organizer announced version 3.12.0 as the new stable release series!

gThumb 3.12.0 is the new stable series since the last 3.10.x, while the 3.11.x is the development release.

What’s New in gThumb 3.12.0:

The new release includes many new features compare to the previous stable 3.10.x. They are all introduced in the 3.11 development releases, so you may already enjoy using them for a period of time.

With libheif library, gThumb now opens AVIF, HEIF (include Apple’s HEIC) images, and allows to save images as AVIF. And it supports JPEG XL images using the jpeg-xl library. A template editor is available to edit text values with special codes, for use in script commands, rename templates, print header and footer, etc.

Besides that, it improved file navigation for directory contains thousands of images. The file list now starts more thumbnailers in parallel, status bar has button to show the progress dialog. And the color picker tool shows colors in two more formats: rgb in % and hsl. Others include:

  • Allow to set shortcuts to activate filters.
  • Allow to mount unmounted volumes.
  • Add file actions to the viewer context menu.
  • Read color profiles from png files as well.
  • Option to show/hide the status bar.

For those already running gThumb 3.11.4, there are only bug-fixes and translation updates.

How to Install gThumb 3.12.0 in Ubuntu:

The software does not provide official binary package. Besides building from the source tarball, you may install it via the unofficial Ubuntu PPA.

1. Add the Ubuntu PPA.

The PPA so far provides packages for Ubuntu 20.04, Ubuntu 21.04, Ubuntu 21.10, and Linux Mint 20. It contains package for Ubuntu 18.04 but lacks JPEG XL support.

Firstly open terminal either from start menu or by pressing Ctrl+Alt+T on keyboard. When it opens, paste the command below into terminal and hit run:

sudo add-apt-repository ppa:ubuntuhandbook1/apps

2. Update system package cache.

Adding PPA will automatically refresh the package cache in Ubuntu 20.04 and higher. However old versions and some Ubuntu based systems does not. To do it manually, simply run command in terminal:

sudo apt update

3. Install / Upgrade gThumb.

Finally, either run the apt install command in a terminal window to install the image viewer:

sudo apt install gthumb

Or use the Software Updater (Update Manager) utility to receive package updates. Un-check other packages from the PPA if you don’t want them.

Uninstall / Restore gThumb:

You can restore to the stock version of the image viewer and organizer by purging the PPA repository. To do so, simply run command:

sudo apt install ppa-purge && sudo ppa-purge ppa:ubuntuhandbook1/apps

You may also keep the gThumb package but remove the Ubuntu PPA, since it contains many other software packages that you don’t prefer. To do so, either run command in terminal:

sudo add-apt-repository --remove ppa:ubuntuhandbook1/apps

Or remove the repository line under ‘Other Software’ tab via Software & Updates utility.

GIMP announced the 2.10.28 release of the popular image editor. The release includes mainly bug-fixes and stability improvements.

The source tarball of version 2.10.26 is available to download 2 weeks ago. Due to a build bug, the project team skipped it and announced GIMP 2.10.28 as the latest stable release with fixes.

Changes in GIMP 2.10.28:

For Windows users, the new GIMP released fixed some long standing issues, including:

  • Fixed very slow file dialogs that happen on slow or unavailable network devices, removable devices connection, or even fake floppy drives.
  • Fixed crash when opening files in specific third-party software.
  • GTK outputting the wrong character on some keyboard input using Input Engines.
  • TIFF exporting locks the TIFF files due to bug of Windows thumbnailer.
  • GIMP prevent some apps to open, when they need to watch some specific directory.
  • Apps with invisible windows, e.g., e.g. gesture shortcuts, screen capture, used to interfere and break some mouse interactions.

For macOS Big Sur, GIMP applied performance improvements to the packages since version 2.10.22 as experiments. Now the code has been moved to the main codebase.

The release also features GEGL 0.4.32, which introduced new edge_handling parameter allows to choose whether areas outside the input to be treated as above or below threshold for calculating distance. And the test system gets some nice improvements.

Other changes in GIMP 2.10.28 include:

  • The Dashboard dockable now has memory support in OpenBSD.
  • Fixes to plugins, including C-source, DICOM, GIF, PS, Sunras, BMP, DDS, PSD, TIFF, Gimpressionist, metadata viewer and several script-fu scripts.
  • A new Script-Fu function (dir-make) enables to create directories from scripts.
  • Fixed some accessibility issues in themes.

How to Install GIMP 2.10.28 in Ubuntu:

1. GIMP Flatpak:

The project team recommends the flatpak package, the universal Linux package format runs in sandbox. The package is available at flathub.org. Users need to follow the setup guide and install the flatpak via the command in the bottom of the link page.

2. GIMP Snap:

The image editor is also available as Snap, another universal package format developed by Canonical, the company behind Ubuntu.

The snap version is so far GIMP 2.10.24. It however will automatically update to the latest (once published) after installed it. And the snap is available in Ubuntu Software:

3. Ubuntu PPA

For those stick to the classic .deb package, GIMP 2.10.28 is available to install via this unofficial PPA in Ubuntu 20.04, Ubuntu 21.04, and Ubuntu 21.10.

1.) Firstly, either search for and open terminal from the Activities overview screen, or press Ctrl+Alt+T on keyboard. When terminal opens, run command to add the PPA:

sudo add-apt-repository ppa:ubuntuhandbook1/gimp

Type user password (no visual feedback) when it asks and hit Enter to continue.

2.) Next, install GIMP 2.10.28 either by running apt command in terminal:

sudo apt install gimp gegl

or upgrade the editor using Software Updater (Update Manager):

Remove PPA and restore GIMP:

For any issue, you can purge the Ubuntu PPA which will downgrade the installed packages to the stock versions. To do so, firstly install the ppa-purge utility:

sudo apt install ppa-purge

Next run command to purge the Ubuntu PPA:

sudo ppa-purge ppa:ubuntuhandbook1/gimp

KeePass Password Safe 2.49 released with user interface improvements and minor new features. Here’s how to install it in Ubuntu via PPA.

According to the release note, the new release added new dedicated context menus for custom string fields and auto-type associations in the entry dialog. Allows to copy names, values, target windows and sequences, copy and paste items, and do select all and move to actions. The button “More” is present to the right of the custom string fields and auto-type associations list to show the context menu.

The release also added optional “Auto-Type – Enabled” and “Auto-Type – Sequences” main entry list column. They are disabled by default and can be turned on via menu “View -> Configure Columns”.

KeePass 2.49 added support for importing Keeper 16.0.0 JSON files, and automatic screen reader detection based on the operating system’s screen reader parameter. Other changes include:

  • New ‘Show confirmation dialog when opening a database file whose minor format version is unknown’ option.
  • Dialog banners can now be read by screen readers
  • Added accessibility names for some controls
  • Controls in the accessibility/automation control tree are now ordered by their visual locations
  • Various accessibility enhancements and other improvements.

How to Install KeePass 2.49 in Ubuntu:

KeePass 2.x runs on Linux through Mono, the open-source .NET Framework-compatible software framework. The UI looks old. If you don’t like it, try KeePassX the native Linux password manager.

The software does not provide Linux binary package so far. Besides building from the source, you can use the unofficial Ubuntu PPA.

NOTE: I offer no warranty for any package in the PPA. Build rules and patches borrowed from the Julian Taylor’s PPA. Use it at your own risk.

1.) Firstly, open terminal from start menu and run command to add the PPA:

sudo add-apt-repository ppa:ubuntuhandbook1/keepass2

Type user password when it asks since sudo command need user authentication and hit Enter to continue

2.) Then run command to update package cache, though it’s done automatically in Ubuntu 20.04 & higher while adding PPA:

sudo apt update

3.) Finally install this mono based password manager package by running command:

sudo apt install keepass2

By keeping the Ubuntu PPA, next time a new release is published you’ll be able to upgrade it using system’s Software Updater (Update Manager) utility.

Uninstall KeePass2:

To remove the software package, run command in terminal:

sudo apt remove --autoremove keepass2

And remove the Ubuntu PPA either via command in temrinal:

sudo add-apt-repository --remove ppa:ubuntuhandbook1/keepass2

or by launching “Software & Updates” utility and removing the relevant line under “Other Software” tab.

For those don’t like the Flatpak package, here’s how to install GIMP 2.99.18 from PPA in Ubuntu 20.04 and/or Ubuntu 22.04 LTS.

The popular GIMP image editor is working on the next major 3.0 release. For testing purpose, GIMP 2.99.18 was released as the latest development version. It provides the official Linux package via Flatpak package. However, some users don’t like it, since Flatpak is an universal package format needs separate daemon to run in sandbox.

Install GIMP 3.0 Dev from PPA in Ubuntu 20.04/22.04:

For Ubuntu 20.04, Ubuntu 22.04, and derivatives, e.g, Linux Mint 20/21 and Zorin OS 17, the unofficial PPA contains the classic .deb package for GIMP 3.0 Dev release.

NOTE: The package in the PPA is unstable. It may have bugs and used only for testing purpose. Installing GIMP from this PPA will override the 2.10 stable release, don’t install it on production machine.

1. Add the PPA.

Press Ctrl+Alt+T on keyboard to open terminal, or search for and open terminal from start menu if you’re on Linux Mint or ZorinOS.

When terminal opens, copy and paste the command below and hit Run to add the PPA:

sudo add-apt-repository ppa:mati75/gimp30

Type your password as sudo command need user authentication, and hit Enter to continue.

2. Update package cache

Since Ubuntu 20.04, it updates the system package cache automatically while adding Ubuntu PPAs, However, Linux Mint 20 does not. So you may need to manually run command in terminal to update cache:

sudo apt update

3. Install / Upgrade to GIMP 3.0 Dev

Finally, you can either open Software Updater (Update Manager) to install or upgrade the GIMP package, or run command in terminal instead:

sudo apt install gimp gegl

Revert to GIMP 2.10 Stable:

It’s possible to downgrade the image editor back to 2.10 stable release, 2.10.18 if no other relevant PPA added.

Simply open terminal and run the command below to install the ppa-purge package, and then purge the Ubuntu PPA which will remove it as well as downgrade installed packages:

sudo apt install ppa-purge && sudo ppa-purge ppa:mati75/gimp30

That’s all. Enjoy!

This simple tutorial shows how to install Virtualbox Guest Additions in Ubuntu based systems, e.g., Linux Mint, Zorin OS and Elementary OS, with fix or workaround for common issues.

Guest Additions is a set of device drivers and system applications to install in Guest OS. It’s useful when you try to share folder and/or clipboard between guest and host, enable USB support etc. Installing the software suite is easy via a menu option. However, it might not function in some cases.

Install Guest Additions in the Normal Way

Firstly, start and login the Guest OS. Then go to VM menu “Devices -> Insert Guest Additions CD image“.

Usually, a pop-up dialog will open and prompt whether to run autorun script or not. Just click “Run” and it starts to install the guest additions after you typing user password in authentication dialog.

After installation, the additions will function in next boot of the Guest OS.

[Workaround] Unable to insert the virtual optical disk:

Sometimes it outputs an error “Unable to insert the virtual optical disk … into the machine …” when you click on the menu option in VM (VirtualBox Machine).

It happens in my case when trying to install the additions in Elementary OS 6. And it will pop-up an error dialog:

Don’t know why but do following steps will fix the issue in next Guest boot:

1.) Power off the Guest OS, then go to its Settings page. Under the Storage settings, remove the attached iso under Controller:IDE.

2.) Next add new optical drive, and click “Leave Empty” in the select dialog.

After saving the changes, start the Guest OS and try to install the additions again.

Manually Download & Install Guest Additions:

Nothing happens when clicking ‘Insert Guest Additions CD image’ option? You can download the iso, mount it, and install the Guest Additions manually.

1.) Firstly start the VirtualBox Machine, download the iso image for your VirtualBox edition, usually “VBoxGuestAdditions_x.x.xx.iso”, from the link button below:

2.) Next open the Downloads folder, right-click or (double-click) on the file and select to mount the iso image.

The dialog should pop-up allows you to select “Run” to install the additions. If not, go to the mounted folder from the left pane in file manager. Right-click on blank area and select ‘Open in Terminal‘ to open a terminal window and navigate to the directory automatically.

When terminal opens, run the .run installer manually via command:

sudo ./VBoxLinuxAdditions.run

That’s all. Enjoy!

This is a step by step tutorial shows how to add “open as root (or administrator)” option in Pantheon file browser in Elementary OS 6 Odin.

Elementary OS now is at version 6.0 based on Ubuntu 20.04 LTS. For those looking for the “Open as Administrator” function to open system file via root user permission, or do copy & paste things outside of user’s home directory, things have changed.

The executable command for the file manager now is io.elementary.files, and the command to start text editor is io.elementary.code. Both are named in Flatpak app style. Gksu has gnone, and “pkexec” takes the place to allow an authorized user to execute program as root.

Add Open as Admin action in Elementary OS 6:

1. ) Firstly, search for and open “terminal” from the top-left corner Applications menu.

2. When terminal opens, run command to create (& edit via nano) the configuration file for option to edit file as root user privilege:

sudo nano /usr/share/contractor/io.elementary.code.open-as-root.contract

When the file opens in terminal, paste following lines and save via Ctrl+X, type y and hit Enter.

[Contractor Entry]
Name=Edit as Administrator
Icon=io.elementary.code
Description=Edit file via root user privilege
MimeType=text/plain;
Exec=pkexec io.elementary.code %U
Gettext-Domain=code

3. And create another config file for an option to open folder as root permission:

sudo nano /usr/share/contractor/io.elementary.files.open-as-root.contract

Then paste the following lines and save it (Ctrl+X, type y, and hit Enter):

[Contractor Entry]
Name=Open as Administrator
Icon=system-file-manager
Description=Open a folder via root user privilege
MimeType=inode/directory;
Exec=pkexec io.elementary.files %U
Gettext-Domain=file manager

After creating the two files, “Edit as Administrator” and “Open as Administrator” context menu option appear when right-clicking a file or folder immediately without restart.

As you see, you can create more actions by creating files with “.contract” extension under /usr/share/contractor directory. The name will be displayed as menu option, and you can find value of icon, MineType and Exec by checking the app shortcut file (.desktop) under /usr/share/applications directory.

That’s all. Enjoy!

The MATE desktop 1.26 now is available to install via the official Ubuntu PPA!

UPDATE 2024: This PPA is so far only for Ubuntu 20.04 LTS, since Ubuntu 22.04/24.04 has MATE 1.26 in system repository.
The lightweight MATE desktop environment 1.26 was released a week ago. It features initial wayland support, do not disturb applet, and many core applications updates!

The Ubuntu MATE developer team finally made a new Ubuntu PPA contains the packages for Ubuntu 20.04 LTS, MATE 1.26 will be there in the main repositories.

Install MATE 1.26 via PPA:

Firstly, search for and open terminal from start menu, or simply press Ctrl+Alt+T on keyboard. When terminal opens, run following commands one by one.

1. Add MATE PPA.

To add the official PPA, copy and paste the command below into terminal and hit Enter.

sudo add-apt-repository ppa:ubuntu-mate-dev/fresh-mate

Type user password (no visual feedback) when it asks and hit Enter to continue.

Install / Upgrade to MATE 1.26:

If you’re running MATE 1.24, simply run command in terminal to upgrade it:

sudo apt update && sudo apt upgrade

or launch Software Updater and install all the available system updates:

For non-mate users, it’s possible to run this command to get the desktop environment:

sudo apt install mate-desktop-environment

Uninstall MATE 1.26:

For any reason, it easy to downgrade the desktop to the stock version by purging the Ubuntu PPA. To do so, run command:

sudo apt install ppa-purge && sudo ppa-purge ppa:ubuntu-mate-dev/fresh-mate

Computer hibernate does not work in your Ubuntu? Here’s step by step complete guide shows how to enable this feature in Ubuntu 24.04 and Ubuntu 22.04 LTS.

Similar to suspend, hibernate can be used to save your system work. It moves the content from RAM memory into swap area in hard disk, then shutdown your machine completely. Next time you boot the computer, it restores the system status exactly as it was.

NOTE:This tutorial now is tested and works on my Ubuntu 22.04 and Ubuntu 24.04 Laptop with default GNOME. It may NOT work if you’ve edited the boot-menu via Grub Customizer!!

For other desktop environments, you need to replace gnome-text-editor or gedit in following commands with your favorite text editor, or use the universal nano command line editor that works in most desktops (use Ctrl+S to save, Ctrl+X to exit).

Step 1: Check the ID of Swap Area & Create if NOT exist.

System hibernate feature saves data into swap area on disk. You need to first find out the ID or UUID of the swap device, so to know where to resume from hibernation.

a. Check Swap Area:

First, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command:

swapon --show

The command will output all enabled swap devices in your system, along with its name, type, size, priority, etc., information.

  • If the TYPE is a partition, then you need to write down its name, which is usually ‘/dev/sdaX‘ or ‘/dev/nvme0n1px‘. Next go directly to step 2
  • If it’s a file, then you need to go next step (b.) to find out the root partition (Ubuntu file-system) name, as well as the physical offset to locate that swap file.

NOTE: A Linux system may have multiple swap devices, go check the one with highest priority! If the swap name is “/dev/zram0”, then it does NOT support hibernation!!

b. Find root partition name and physical offset

So, if your system uses a file for swap area, then you need to find out the root partition name + physical offset to locate it.

To get the system partition name, run the command below, and check the one mounted on “/”:

df -h

In the screenshot below, the root is /dev/nvme0n1p6 in my case.

To get the physical offset of the file, use command:

sudo filefrag -v /swapfile

Here, replace /swapfile with yours swap file name (see swapon --show output). Then, copy the start number under physical_offset. It’s 3606528 in my case.

c. Create Swap File, if you don’t have Swap area:

To create a file for swap if you don’t have it, run following commands one by one:

a.) Pre-allocate a disk place for a file via command:

sudo dd if=/dev/zero of=/swapfile count=8192 bs=1MiB

Replace 8192 MB (8G) to your desired size. As large as RAM is recommended for swap.

b.) Change the file permission to only read & write for root:

sudo chmod 600 /swapfile

c.) Set the file as swap area:

sudo mkswap /swapfile

d.) Finally enable it by running command:

sudo swapon /swapfile

If you already have a swap space, and want to use this one with higher priority, run sudo swapon -p 100 /swapfile instead. Replace 100 with any number bigger than the existing swap.

And, if you already ‘swapon’ the swap, then you need to disable it via sudo swapoff /swapfile first, then swap-on with priority number with the command above.

e.) And write it into ‘/etc/fstab’, so Ubuntu will mount it automatically on startup.

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

When done, you may run step b. to find out the root partition name plus physical offset for this swap file.

Step 2: Enable Hibernate by adding Kernel Parameter

After step 1, you can now add kernel parameter in Grub boot-loader config file, to tell it to try resuming from the swap device on every boot.

To do so, press Ctrl+Alt+T to open terminal, and run command to edit the config file:

sudo gnome-text-editor /etc/default/grub

For Ubuntu 22.04 and earlier, replace gnome-text-editor with gedit. For non-GNOME desktop, use other text editor or nano that works for all.

For Swap partition, add resume=/dev/xxx (do replace “/dev/xxx” to the Swap partition name you got in step 1) as value of “GRUB_CMDLINE_LINUX_DEFAULT”.

For Swap file, add resume=/dev/xxx resume_offset=xxx (also replace xxx with the root partition name and physical offset number according to step 1) instead for value of “GRUB_CMDLINE_LINUX_DEFAULT”.

Finally, save the file and apply changes by updating the Grub configuration via command:

sudo update-grub

Step 3: Check if hibernate works:

NOTE: The hibernation won’t work with secure boot!! You have to disable it in BIOS/EFI first. With secure boot enabled, you’ll get error:

“Failed to hibernate system via logind: Sleep verb “hibernate” not supported”.

To verify if the hibernation function works now, open terminal (Ctrl+Alt+T) and run command:

sudo systemctl hibernate

Save you work before running the command!! Then type user password when it asks. The command will turn off your computer/laptop. Next you can boot the machine again, and see if it restores your system status after login.

If hibernation works, go to Step 4 to enable ‘Hibernate’ option in shutdown menu. If NOT, then your computer may NOT support this feature or something has gone wrong.

Troubleshooting:

For Ubuntu 24.04 with swap file, there was a bug, that may cause “Call to Hibernate failed: Invalid argument” error when running the hibernate command. In the case, the hibernation may only work on first action.

The bug has been fixed in Ubuntu 24.04.1. And, here is just the note about the workaround:

  • First, open terminal and run command lsblk to get the MAJ:MIN value of the root partition. If you don’t know root name, use df -h to find the one mounted on “/”.
  • Next, run command to create a tmpfiles.d config file:
    sudo nano /etc/tmpfiles.d/hibernation_resume.conf

    When file opens in terminal window, add the lines below:

    #    Path                   Mode UID  GID  Age Argument
    w    /sys/power/resume       -    -    -    -   259:6

    Here, replace 259:6 according to MAJ:MIN value you got in last command. Then, press Ctrl+S to save file and Ctrl+X to exit.

This config file tells to write MAJ:MIN value to the /sys/power/resume automatically on system boot, so to workaround the bug until it was fixed.

Regenerate initramfs if hibernate to Swap file

Hibernation works in my case without this step!! If it’s NOT for you, try regenerating initramfs via a new rule.

Firstly, open terminal (Ctrl+Alt+T) and run command to create a config file:

sudo gedit /etc/initramfs-tools/conf.d/resume

Then paste the line “RESUME=/dev/xxx resume_offset=xxx” (replace xxx with correct partition name and offset number) and save it.

After saving the file, regenerate initramfs via command:

sudo update-initramfs -c -k all

Finally reboot and test hibernate function again.

Step 4: Enable Hibernate option in Power-Off Menu:

After enabled the function, you can now add a menu option into the system tray shutdown menu.

Option 1: The legacy method for For Ubuntu 22.04 and earlier, though it still works in Ubuntu 24.04.

1.) First, open terminal (Ctrl+Alt+T) and run command to create the config directory, that’s not exist by default in Ubuntu 24.04:

sudo mkdir -p /etc/polkit-1/localauthority/50-local.d

2.) Thanks to @Joerg, Ubuntu 23.10 and Ubuntu 24.04 users need to install polkitd-plka package first:

sudo apt install polkitd-pkla

3.) Then, run command to create & edit a config file (replace gedit with gnome-text-editor for 24.04):

sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

When the file opens, paste following lines and save it.

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes

Option 2: Thanks to this thread, since Ubuntu 24.04, the new method to add hibernate menu option is to create config file under /etc/polkit-1/rules.d/ directory.

  • First, run command to create a config file:
    sudo nano /etc/polkit-1/rules.d/10-enable-hibernate.rules
  • When file opens, paste the lines below and press Ctrl+S to save, finally press Ctrl+X to exit.
    polkit.addRule(function(action, subject) {
        if (action.id == "org.freedesktop.login1.hibernate" ||
            action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
            action.id == "org.freedesktop.upower.hibernate" ||
            action.id == "org.freedesktop.login1.handle-hibernate-key" ||
            action.id == "org.freedesktop.login1.hibernate-ignore-inhibit")
        {
            return polkit.Result.YES;
        }
    });

After doing either option above, your desktop (including MATE, XFCE, KDE, but exclude GNOME) should NOW have the “Hibernate” option in shutdown menu!

For GNOME, the default desktop in Ubuntu, you need to do one more step to make the menu option visible:

For default GNOME desktop, go to the link button below and install the extension for the menu option:

For those first time installing Gnome extension, you need to run command to install “chrome-gnome-shell” package first:

sudo apt install chrome-gnome-shell

And click the “click here to install browser extension” link in the extension page and refresh the page if you don’t see the toggle icon.

Or, search for and install “Extension Manager” from Ubuntu Software, and use the tool to search and install that extension:

After installed the extension, go back “Installed” tab in Extension Manager window, and click configure the extension for showing/hiding power-off menu options (May need log out and back in).

Moreover:

If everything goes well after this tutorial, you can get more, including hibernate when lid is closed, and automatic hibernate on system idle.

Tips:

For users who upgraded Ubuntu from an old release (e.g, 22.04 -> 24.04, 24.04 -> 24.10), some report that screen turns on automatically 15s after hibernation (See this comment). Thanks to @Maarten Vergouwe, try upgrading the latest kernel may fix the issue.