How to Stop Ubuntu from Automatically Discarding Unsaved Documents

The Silent Data Loss

In Ubuntu, the default text editor is usually Gedit (or GNOME Text Editor in newer releases). Unlike robust IDEs or modern word processors that constantly auto-save to the cloud, standard Linux text editors often rely on manual saves. However, there is a specific, highly frustrating scenario: if you have an unsaved document open in Gedit and the system forces a shutdown (for example, due to a critical update, a low battery hibernation, or an accidental press of the power button), Ubuntu’s session manager will aggressively terminate running applications. If the editor cannot intercept the termination signal fast enough to prompt you, it may automatically discard the unsaved document, resulting in total data loss without a warning dialog.

Configuring Auto-Save and Session Recovery

To stop Ubuntu from automatically discarding your unsaved work during unexpected terminations, you must rely on the editor’s built-in auto-save functionality, which is often disabled by default in minimal installations.

Open Gedit (or Text Editor). Click the hamburger menu (three horizontal lines) in the top-right corner and select Preferences. Navigate to the Editor tab. Look for the section related to saving files. You should see an option labeled Autosave files every [X] minutes. Check the box to enable this feature and set the timer to a low interval, such as 1 or 2 minutes. Furthermore, check the box for Create a backup copy of files before saving (which creates a file with a `~` suffix).
By enabling autosave, even if the Ubuntu session manager aggressively kills the Gedit process without a prompt, you will only lose a maximum of one or two minutes of work, rather than the entire document, as the editor will have safely written a recovery copy to the disk in the background.

Get the best tech tips delivered straight to your inbox.

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