Ubuntu 18.04 LTS's default desktop background showing a Bionic Beaver.

Fancy having critical Linux kernel patches automatically applied to your Ubuntu system—without having to reboot your computer? We describe how to use Canonical’s Livepatch Service to do just that.

What Is Livepatch and How Does It Work?

As Canonical’s Dustin Kirkland explained several years ago, Canonical Livepatch uses the Kernel Live Patching technology built into the standard Linux kernel. Canonical’s Livepatch website notes that massive corporations like AT&T, Cisco, and Walmart use it.

It’s free for personal use on up to three computers—according to Kirkland, these can be “desktops, servers, virtual machines, or cloud instances.” Organizations can use it on more systems with a paid Ubuntu Advantage subscription.

Kernel Patches Are Necessary But Inconvenient

Linux kernel patches are a fact of life. Keeping your system secure and patched up to date is vital in the inter-connected world we live in. But having to reboot your computer to apply kernel patches can be a pain. Especially if the computer is providing some sort of service to users and you have to co-ordinate or negotiate with them to take the service off-line. And there’s a multiplier. If you maintain several Ubuntu machines, at some point you have to bite the bullet and do each one in turn.

The Canonical Livepatch Service removes all of the aggravation of keeping your Ubuntu systems up to date with critical kernel patches. It’s easy to set up—either graphically or from the command line—and it takes one more chore off your shoulders.

Anything that reduces maintenance efforts, boosts security, and reduces downtime has to be an attractive proposition, right? Yes, but there are some caveats.

  • You must be using a Long Term Support (LTS) release of Ubuntu such as 16.04 or 18.04. The most recent LTS version is 18.04, so that’s the version we’re going to use here.
  • It must be a 64-bit version.
  • You must be running Linux Kernel 4.4 or higher
  • You need to have an Ubuntu One account. Remember them? If you don’t have an Ubuntu One account, you can sign up for a free account.
  • You can use the Canonical Livepatch Service at no cost, but you’re limited to three computers per Ubuntu One account. If you have to maintain more than three computers, you’ll need additional Ubuntu One accounts.
  • If you have physical, virtual, or cloud-hosted servers to look after,  you’ll need to become an Ubuntu Advantage customer.

Getting an Ubuntu One Account

Whether you’re going to set up the Livepatch Service through the graphical user interface (GUI) or via the command-line interface (CLI), you must have an Ubuntu One account. This is required because the operation of the Livepatch Service depends on a private key that is issued to you, and tied to your Ubuntu One account.

  • If you set up the Livepatch Service using the GUI, you won’t see your key. It is still required and used, but it is all handled in the background for you.
  • If you set up your Livepatch Service via the terminal, you’ll need to copy and paste your key from your browser to the command line.

If you don’t have an Ubuntu One account, you can create one at no cost.

Enabling the Canonical Livepatch Service Graphically

To launch the graphical setup interface, press the “Super” key. This is located between the “Control” and “Alt” keys on the lower-left of most keyboards. Search for “livepatch.”

When you see the Livepatch icon, click the icon or press “Enter”.

The Livepatch icon

The “Software and Updates” dialog window will appear with the Livepatch tab selected. Click the “Sign in” button. You are reminded that you need an Ubuntu One account.

Ubuntu One Sign in / register dialog

Click the “Sign in / Register” button.

The Ubuntu Single Sign-On Account dialog window appears. Canonical uses the terms “Ubuntu One” and “Single Sign-On” interchangeably. They mean the same thing. Officially “Single Sign-On” was replaced by “Ubuntu One”, but the old name lingers on.

Ubuntu Single Sign On Dialog Window

Enter your account details and click the “Connect” button. You can also use this dialog window to register for an account if you have not already created one.

You will be prompted for your password.

Ubuntu Authentication Dialog window

Enter your password and click the “Authenticate” button. A dialog window shows you the email address associated with the Ubuntu One account you’re going to use.

Email address verification dialog window

Make sure it is correct and click the “Continue” button.

You’ll be asked for your password once more. After a few seconds, the Livepatch tab in the “Software and Updates” dialog window will update to show that Livepatch is live and active.

Livepatch active in the Software and Updates dialog window

A new shield Icon will appear in the tool notification area, close to the networking, sound, and power icons. The green circle with the tick tells you all is well. Click the icon to access the menu.

We are told that Livepatch is on, and there are no current updates.

Livepatch notification area icon and menu

The “Livepatch settings” option will open the “Software and Updates” dialog window at the Livepatch tab.

That’s it; you’re all done.

Enabling the Canonical Livepatch Service using the CLI

You’re going to need an Ubuntu One account. If you don’t have one, you’ll have the opportunity to create one. They’re free, and it only takes a moment.

Some of the steps we need to perform are web-based, so this isn’t a truly CLI-only method. We start by visiting the Canonical Livepatch Service web page in order to obtain our secret key or “token.”

Canonical Livepatch Service web page

Select the “Ubuntu User” radio button and click the “Get Your Livepatch Token” button.

You’re prompted to log in to your Ubuntu One account.

Ubuntu One Log In web page

  • If you have an account, enter the email address you used to set up the account, and select the “I have an Ubuntu One account, and my password is:” radio button.
  • If you don’t have an account, enter your email address and select the “I don’t have an Ubuntu One account” radio button. You will be guided through the account creation process.

Once your Ubuntu One account has been verified, you’ll see the Managed live kernel patching web page. Your key will be displayed.

Managed live kernel patching web page

Keep the web page with your key on it open and open a terminal window. Use this command in the terminal window to install the Livepatch service daemon:

sudo snap install canonical-livepatch

sudo snap install canonical-livepatch in a terminal window

When the installation is finished, you’ll need to enable the service. You’ll need the key from the “Managed live kernel patching” web page.

You need to copy and paste the key to the command line. Highlight the key on the web page, right-click it, and select “Copy” from the context menu. Or you can highlight the key and press “Ctrl+C.”

Type the following command in the terminal window, but don’t press “Enter.”

sudo canonical-livepatch enable

Then type a space, and right-click and select “Paste” from the context menu. Or you can press “Ctrl+Shift+V.” You should see the command you just typed, a space, and the key from the web page.

On the test machine used to research this article it looked like this:

sudo canonical-livepatch enable in a terminal window

Press “Enter.”

RELATED: How to Copy and Paste Text at Linux's Bash Shell

If all goes well, you’ll see a verification message from Livepatch telling you that the computer has been enabled for kernel patching. It will also show another long key; this is the “machine-token.”

Livepatch enabled verification message in a terminal window

What just happened is:

  • You’ve obtained your Livepatch key from Canonical.
  • You can use it on three computers. You’ve used it on one computer so far.
  • The machine-token that was generated for this computer—using your key—is the machine-token displayed in this message.

If you check the Livepatch tab in the “Software and Updates” dialog window, you’ll see that Livepatch is enabled and active.

Livepatch tab in the Software and upgrades dialog window

Checking the Status of Livepatch

You can make Livepatch give you a status report using the following command:

sudo canonical-livepatch status

sudo canonical-livepatch status in a terminal window

The status report contains:

  • client-version: The software version of Livepatch.
  • architecture: The CPU architecture of the computer.
  • cpu-model: The type and model of the Central Processing Unit (CPU) in the computer.
  • last-check: The time and date that Livepatch last checked to see if there were any critical kernel updates available for download.
  • boot-time: The time this computer was last powered on.
  • uptime: The duration this computer has been powered on.

The status block tells us:

  • kernel: The version of the current kernel.
  • running: Whether Livepatch is running or not.
  • checkstate: Whether Livepatch has checked for kernel patches.
  • patchState: Whether there are any critical kernel patches requiring to be installed.
  • version: The version of the kernel patches, if any, that need to be applied.
  • fixes: The fixes contained in the kernel patches.

Forcing Livepatch to Update Now

The whole point of Livepatch is to provide a managed update service, meaning you don’t need to think about it. It’s all done for you. But if you want to, you can force Livepatch to check for kernel patches (and to apply any it finds) with the following command:

sudo canonical-livepatch refresh

sudo canonical-livepatch refresh in a terminal window

Livepatch tells you the version of the kernel before and after the refresh. There was nothing to be applied in this example.

Less Friction, More Security

Security friction is the pain or inconvenience associated with implementing, using, or maintaining a security feature. If the friction is too high, the security suffers because the feature isn’t used or maintained. Livepatch takes all the friction out of applying critical kernel updates, keeping your kernel as secure as possible.

That’s longhand for “win, win.”

Dave McKay Dave McKay
Dave McKay first used computers when punched paper tape was in vogue, and he has been programming ever since. He is now a Data Protection Officer and has worked as a freelance programmer, manager of an international software development team, and an IT services project manager. Dave is a Linux evangelist and open source advocate.
Read Full Bio »