Skip to content

How to Reinstall Ubuntu Desktop When Broken

How to Reinstall Ubuntu Desktop When Broken

When your Ubuntu desktop environment is broken (black screen, crash loops, missing panels), you can repair it without fully reinstalling the OS.


Prerequisites

  • Access to terminal (TTY or recovery mode)
  • Root or sudo access
  • Internet connection
  • At least 5GB free disk space
Note: This guide repairs the desktop environment without losing your personal files.

Access the Terminal

Method A: TTY (if desktop is stuck)

Press Ctrl + Alt + F2 through F6 to open a text terminal. Log in with your username and password.

Ctrl+Alt+F2  # Go to TTY2
Ctrl+Alt+F1  # Back to desktop

Method B: Recovery Mode

  • Hold Shift during boot (BIOS) or spam Esc
  • Select “Advanced options for Ubuntu”
  • Select “(recovery mode)” kernel entry
  • Choose “root – Drop to root shell prompt”

Step 1: Check Disk Space

df -h

If / is full (>90%), free space first:

sudo apt clean
sudo apt autoremove -y
sudo journalctl --vacuum-size=100M

Step 2: Fix Broken Packages

sudo apt update --fix-missing
sudo dpkg --configure -a
sudo apt install -f
sudo apt dist-upgrade -y

Step 3: Reinstall Desktop Packages

Method A: Reinstall GNOME Desktop (Most Complete)

sudo apt install --reinstall ubuntu-desktop
sudo apt install --reinstall ubuntu-desktop-minimal
sudo apt install --reinstall gnome-shell
sudo apt install --reinstall gdm3
sudo apt install --reinstall gnome-terminal

Method B: Reinstall Specific Components

sudo apt install --reinstall gnome-shell ubuntu-session gdm3
sudo apt install --reinstall gnome-control-center
sudo apt install --reinstall nautilus
sudo apt install --reinstall unity-control-center

Method C: Purge and Reinstall Desktop

For severely broken setups:

sudo apt purge -y ubuntu-desktop ubuntu-desktop-minimal
sudo apt autoremove -y
sudo apt install -y ubuntu-desktop
sudo apt install -y ubuntu-desktop-minimal
Tip: Method A is safest. Method C is for extreme cases.

Step 4: Reinstall Display Manager

sudo apt install --reinstall gdm3
sudo dpkg-reconfigure gdm3
sudo systemctl enable gdm3
sudo systemctl start gdm3

Step 5: Reset GNOME Settings

mv ~/.config ~/.config.backup
mv ~/.local ~/.local.backup
mv ~/.gnome ~/.gnome.backup
mv ~/.gconf ~/.gconf.backup
mv ~/.cache ~/.cache.backup

Or reset dconf (GNOME settings database):

dconf reset -f /
gsettings reset-recursively org.gnome.shell

Step 6: Reinstall Graphics Drivers

sudo apt install --reinstall xserver-xorg-core
sudo apt install --reinstall xserver-xorg-video-intel  # Intel
sudo apt install --reinstall xserver-xorg-video-nouveau  # NVIDIA open
sudo dpkg-reconfigure xserver-xorg

Step 7: Reboot

sudo reboot

Quick Fix: One-Liner

Run this if desktop is broken but you have terminal access:

sudo apt update && sudo apt install --reinstall ubuntu-desktop ubuntu-desktop-minimal gnome-shell gdm3 gnome-control-center nautilus gnome-terminal -y && sudo dpkg-reconfigure gdm3 && sudo reboot

Troubleshooting

Black Screen After Login

Ctrl+Alt+F2  # TTY
sudo apt install --reinstall ubuntu-desktop gnome-shell gdm3
sudo reboot

Desktop Manager Not Starting

sudo systemctl status gdm3
sudo journalctl -xe -u gdm3
sudo systemctl restart gdm3

GNOME Shell Extension Conflict

rm -rf ~/.local/share/gnome-shell/extensions
sudo reboot

NVIDIA GPU Black Screen

sudo apt purge -y nvidia-*
sudo apt install --reinstall xserver-xorg-video-nouveau
sudo reboot

Switch to X11 (Wayland Issues)

sudo nano /etc/gdm3/custom.conf
# Uncomment: WaylandEnable=false

Can’t Even Get TTY

Use USB live boot:

  • Boot from Ubuntu live USB
  • Select “Try Ubuntu”
  • Mount your root partition: sudo mount /dev/sdaX /mnt
  • Chroot: sudo chroot /mnt
  • Run the reinstall commands inside chroot

If All Else Fails

Backup your data and do a fresh install:

# From live USB, backup home
sudo rsync -av /mnt/home/ /media/backup/
# Then reinstall Ubuntu from the USB installer

Conclusion

Most broken desktops can be fixed without a full reinstall:

  • Get to TTY with Ctrl+Alt+F2
  • Fix packages: sudo dpkg –configure -a
  • Reinstall desktop: sudo apt install –reinstall ubuntu-desktop gnome-shell gdm3
  • Reset configs if needed
Pro Tip: Always keep a Ubuntu live USB handy. It can chroot into any broken system to repair it.