
Reinstalling Ubuntu via the terminal is a process that requires careful consideration and steps, especially if you want to keep your data intact or perform a fresh installation. Below are detailed instructions for both methods: upgrading an existing installation and performing a complete reinstallation.
Method 1: Upgrading/Repairing the Existing Installation
This method will upgrade or repair your existing installation without losing your personal data.
- Open the Terminal: Access your terminal by pressing
Ctrl + Alt + T
. - Update Your System: It’s crucial to have your existing system updated before upgrading.
bash sudo apt update sudo apt upgrade
- Install the Update Manager: If it’s not already installed, install the update-manager-core package.
bash sudo apt install update-manager-core
- Start the Upgrade Process: Run the following command to start the upgrade process.
bash sudo do-release-upgrade
This will check for new releases. If there’s a new version available, it will prompt you to start the upgrade. - Follow the On-Screen Prompts: Follow the on-screen instructions. Your system will download packages, and it may take some time depending on your internet speed and system configuration.
- Restart Your System: Once the upgrade process completes, restart your system:
bash sudo reboot
Method 2: Complete Reinstallation of Ubuntu
If you prefer to perform a complete reinstallation, you will need to create a bootable USB drive, as you cannot reinstall Ubuntu directly from the terminal without a live environment.
Step 1: Create a Bootable USB Drive
- Download the Ubuntu ISO: Go to the Ubuntu website and download the appropriate ISO for your desired version.
- Insert a USB Drive: Insert a USB drive into your computer and make sure you have backed up any important files on it, as this process will erase everything on the drive.
- Identify the USB Drive: Use the following command to identify your USB drive:
bash lsblk
Look for your USB drive (it should be something like/dev/sdb
). - Create the Bootable USB: Use the following command to create a bootable USB. Replace
/path/to/ubuntu.iso
with the actual path to your downloaded ISO and/dev/sdX
with your USB drive identifier (e.g./dev/sdb
).bash sudo dd if=/path/to/ubuntu.iso of=/dev/sdX bs=4M status=progress
Important: Make sure you specify the correct USB drive; otherwise, you may overwrite other data. - Wait for the Process to Complete: The
dd
command will take some time to complete. Once it’s done, run:bash sync
This ensures all data has been written to the USB.
Step 2: Reinstall Ubuntu
- Boot From the USB Drive: Restart your computer. You may need to access the BIOS/UEFI settings (usually by pressing
F2
,F12
,Del
, orEsc
during boot) to set the USB drive as the boot device. - Select ‘Try Ubuntu’ or ‘Install Ubuntu’: Once the live environment loads, select
Install Ubuntu
. - Choose Installation Type:
- If you want to keep your files, select
Reinstall Ubuntu
(if available). - If you’re looking to perform a clean installation, choose
Erase disk and install Ubuntu
.
- If you want to keep your files, select
- Follow the Installation Wizard: Follow the instructions provided by the installer, including selecting language, keyboard layout, time zone, and creating user account details.
- Complete the Installation: Once the installation process finishes, the system will prompt you to remove the installation media and press Enter to reboot.
- Reboot Your System: After rebooting, you should see your fresh Ubuntu installation.
Final Steps
- Install Updates: After the installation, connect to the internet and run the following commands to ensure your system is up to date:
bash sudo apt update sudo apt upgrade
- Restore Your Data: If you backed up data before the reinstallation, you can restore it now.
By carefully following these steps, you can either upgrade or completely reinstall Ubuntu with minimal hassle. Always ensure to back up your important data before proceeding with any reinstallation to prevent data loss.