Resetting Ubuntu to Default: 5 Easy Steps, No Data Loss

Resetting Ubuntu to default settings without losing data means two separate things: putting your desktop settings (themes, scaling, touchpad, window buttons) back to the defaults, and putting changed system configuration files back to what the package shipped. Ubuntu has no single "factory reset" button for an installed system, but both parts can be done safely from the terminal while your files in ~/Documents, ~/Pictures and the rest of your home stay untouched. Everything below was tested on Ubuntu 24.04.5 LTS (dconf, GLib's gsettings, dpkg/apt) with a test user and test files.

dconf dump / > ~/dconf-backup.ini          # 1. back up desktop settings
gsettings reset-recursively org.gnome.desktop.interface   # reset one area
dconf reset -f /                            # reset ALL desktop settings
dconf load / < ~/dconf-backup.ini           # undo
dpkg --verify PACKAGE                       # find changed config files
sudo rm /etc/FILE && sudo apt install --reinstall -o Dpkg::Options::=--force-confmiss PACKAGE

What resetting Ubuntu touches (and what it does not)

GNOME stores your desktop settings in one binary file per user, ~/.config/dconf/user. Applications keep their own settings in ~/.config, ~/.local/share and dot-files. System-wide settings are files under /etc, owned by packages. Resetting Ubuntu the way shown here changes only the first and last of these and never deletes documents. If you want a clean application, move its folder in ~/.config away (rename, do not delete) and start it again.

Step 1: back up your current desktop settings

The test user changed five common settings: dark style, theme, text scaling 1.25, window buttons and touchpad scrolling. dconf dump shows only values that differ from the defaults:

$ dconf dump /
[org/gnome/desktop/interface]
color-scheme='prefer-dark'
gtk-theme='Adwaita-dark'
text-scaling-factor=1.25

[org/gnome/desktop/peripherals/touchpad]
natural-scroll=false

[org/gnome/desktop/wm/preferences]
button-layout='appmenu:minimize,maximize,close'

$ ls -la ~/.config/dconf/
-rw-rw-r--. 1 me me 720 Oct 17 02:30 user

$ dconf dump / > ~/dconf-backup.ini; wc -l ~/dconf-backup.ini
10 /home/me/dconf-backup.ini

That text file is your undo button when resetting Ubuntu goes too far. Keep it before resetting Ubuntu settings, and copy it to another machine if you want the same desktop there.

Step 2: reset one setting or one area

Resetting Ubuntu does not have to be all or nothing. Often only one thing is broken, for example a scaling factor or a theme. Reset just that:

$ gsettings reset org.gnome.desktop.interface text-scaling-factor
$ gsettings get org.gnome.desktop.interface text-scaling-factor
1.0

$ gsettings reset-recursively org.gnome.desktop.interface
$ gsettings get org.gnome.desktop.interface color-scheme
'default'
$ gsettings get org.gnome.desktop.interface gtk-theme
'Adwaita'

$ dconf dump /
[org/gnome/desktop/peripherals/touchpad]
natural-scroll=false

[org/gnome/desktop/wm/preferences]
button-layout='appmenu:minimize,maximize,close'

Only the interface section went back to defaults; the touchpad and window-button changes stayed.

Step 3: reset all desktop settings to default

Resetting Ubuntu desktop settings with dconf reset -f / while files in Documents stay
Real output: all dconf settings back to defaults, user files untouched.
$ dconf reset -f /
$ dconf dump / | wc -l
0
$ gsettings get org.gnome.desktop.wm.preferences button-layout
'appmenu:close'
$ gsettings get org.gnome.desktop.peripherals.touchpad natural-scroll
true

$ ls -la ~/Documents ~/Pictures; cat ~/Documents/report.txt
/home/me/Documents:
-rw-rw-r--. 1 me me  10 Oct 17 02:30 report.txt
/home/me/Pictures:
-rw-rw-r--. 1 me me   6 Oct 17 02:30 p.jpg
my report

This is the full reset. After resetting Ubuntu's desktop settings, the dump is empty (everything is at default), the window buttons and touchpad scrolling are back to Ubuntu's defaults, and the user's files are exactly where they were. On a real desktop, log out and back in after this so every running application picks up the defaults. To undo:

$ dconf load / < ~/dconf-backup.ini
$ gsettings get org.gnome.desktop.interface color-scheme
'prefer-dark'
$ gsettings get org.gnome.desktop.wm.preferences button-layout
'appmenu:minimize,maximize,close'

Mistakes when resetting Ubuntu settings

$ dconf reset /org/gnome/desktop/interface/
error: -f must be given to (recursively) reset entire directories

$ gsettings reset org.gnome.desktop.nosuch key
No such schema “org.gnome.desktop.nosuch”

# over SSH or "su - user", without the user's desktop session:
(process:983): dconf-WARNING **: 02:30:52.154: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
error: Cannot autolaunch D-Bus without X11 $DISPLAY

The last one matters if you try to reset Ubuntu settings for another user remotely: gsettings and dconf talk to the dconf service on the user's D-Bus session bus. Run the commands in that user's own terminal, or wrap them in dbus-run-session as this lab did. Run them as the user, never with sudo, or you change root's settings instead. If you work on servers over SSH, see how to enable SSH on Ubuntu.

Step 4: reset system config files to package defaults

The second half of resetting Ubuntu is /etc, the system configuration. First find what was changed. The test modified /etc/nanorc (owned by the nano package):

$ dpkg -S /etc/nanorc
nano: /etc/nanorc
$ dpkg --verify nano
??5?????? c /etc/nanorc
...

The 5 means the checksum differs and c marks a config file. (This test ran in a minimal container image without documentation, so dpkg --verify also listed missing doc and man files; on a normal install those lines do not appear.) debsums -ce lists changed config files of all packages.

The obvious fix for resetting Ubuntu config files does not work:

$ sudo apt-get install -y --reinstall nano
Setting up nano (7.2-2ubuntu0.2) ...
$ grep -c '^set linenumbers' /etc/nanorc
1

$ sudo apt-get install -y --reinstall -o Dpkg::Options::=--force-confnew nano
Setting up nano (7.2-2ubuntu0.2) ...
$ grep -c '^set linenumbers' /etc/nanorc
1

dpkg never overwrites a config file you changed, and --force-confnew only applies when a new version of the file arrives, which a reinstall of the same version does not deliver. What works is removing the file and telling dpkg to restore missing config files:

# first keep your version, e.g. sudo cp /etc/nanorc /etc/nanorc.mine
$ sudo rm /etc/nanorc
$ sudo apt-get install -y --reinstall nano
$ ls /etc/nanorc
ls: cannot access '/etc/nanorc': No such file or directory

$ sudo apt-get install -y --reinstall -o Dpkg::Options::=--force-confmiss nano
$ ls -l /etc/nanorc
-rw-r--r--. 1 root root 11424 May 23  2023 /etc/nanorc

Without --force-confmiss, even the deleted file was not restored, because dpkg respects a config file you removed on purpose. With it, the original file came back (dated from the package), and dpkg --verify nano no longer listed it. Do this one package at a time, for the files you really want to reset.

Step 5: find the packages you added

The last part of resetting Ubuntu is software. A fresh install has no extra software; you can list what was installed by hand later and decide what to remove:

$ apt-mark showmanual | grep -E '^(tree|htop|nano)$'; apt-mark showmanual | wc -l
htop
nano
tree
102
$ zcat -f /var/log/apt/history.log* | grep -E '^Commandline' | tail -4
Commandline: apt-get install -y --reinstall -o Dpkg::Options::=--force-confnew nano
Commandline: apt-get install -y --reinstall nano
Commandline: apt-get install -y --reinstall -o Dpkg::Options::=--force-confmiss nano
Commandline: apt-get install -y -qq tree htop

apt-mark showmanual also includes packages the installer marked as manual, so read the list before removing anything. The apt history log shows what you installed and when, which is often the quickest way to find the change that broke something. The Linux history command shows the commands that were typed.

Checklist for resetting Ubuntu without losing data

  1. Back up: dconf dump / > ~/dconf-backup.ini (and your files, as always).
  2. Reset the smallest thing that fixes the problem: one key, one schema, then dconf reset -f /.
  3. Applications: rename their folder under ~/.config.
  4. System files: dpkg --verify, then delete and reinstall with --force-confmiss.
  5. If the system itself is broken (does not boot, packages half-removed), a reinstall that keeps /home on its own partition is the safer route.

Command references: dconf(1) and dpkg(1) (--force-confmiss, --verify).

Comments

Popular posts from this blog

How to Play Minecraft Bedrock Edition on Linux: A Comprehensive Guide for Tech Professionals

The Ultimate Guide: How to Set Up DXVK in Wine on Linux for Enhanced Gaming Performance

Linux desktop frozen? My 5 go-to tricks to try - before forcing a hard reboot