How to Stop Ubuntu from Automatically Clearing the Clipboard

The Ephemeral Selection

The X11 windowing system (still widely used as a fallback in Ubuntu and many Linux distributions) utilizes a unique clipboard architecture. There are actually two clipboards: the standard “Clipboard” (used when you press Ctrl+C) and the “Primary Selection” (used simply by highlighting text with your mouse). A major quirk of the X11 architecture is that the Primary Selection is tied directly to the application that owns the text. If you highlight a URL in Firefox, and then completely close the Firefox window, Ubuntu will often automatically clear the clipboard, destroying the highlighted text because the parent application no longer exists.

Installing a Clipboard Manager

To preserve your copied text across application closures and stop Ubuntu from automatically clearing the clipboard when a program exits, you must install a dedicated background clipboard manager.

The most robust solution is to install a lightweight daemon that constantly monitors and saves your selections independently of the source apps. Open your terminal (Ctrl+Alt+T). A highly recommended, invisible tool is Parcellite (or Clipit for lighter desktop environments). Type sudo apt update and then sudo apt install parcellite, pressing Enter and providing your password. Once installed, launch it by typing parcellite in the terminal (or finding it in your application menu). It will place a small icon in your system tray. Right-click this icon and go to Preferences. Ensure the options for Use Copy (Ctrl-C) and Use Primary (Selection) are checked, and crucially, check the box for Synchronize clipboards. Parcellite will now permanently intercept and store all copied text, ensuring it survives application closures.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.