SoFunction
Updated on 2025-05-23

The ultimate guide to software uninstallation and cleaning in Ubuntu systems

1. Basic knowledge

Common installation methods for software in Ubuntu systems:

  • APT:passaptorapt-getManagement software package, suitable for.debBag.
  • DPKG: The underlying package management tool,aptRely on it, often used for manual installation.debBag.
  • Snap: Containerized package management promoted by Ubuntu.
  • Flatpak: Containerized package management across distributions.
  • Source code installation: By compiling the source code installation, it usually requires manual management.
  • AppImage: No portable application required.

Pay attention to uninstalling:

  • Select the correct uninstall command (such asapt removesnap remove)。
  • Clean up residual files in dependencies, caches, and user directories.
  • Verify that the uninstallation is successful and prevent missed.

2. Find the package name

It is important to confirm the exact package name or ID of the software before uninstalling. The following are common methods:

passaptFind

apt search <Keywords>
dpkg -l | grep <Keywords>

Example: Find the package name of a VLC

dpkg -l | grep vlc

Find via Snap

snap list

Find via Flatpak

flatpak list

Check the user directory(If you need to clean the configuration):

ls -a ~/.config | grep <Keywords>
ls -a ~/.local/share | grep <Keywords>
ls -a ~/.cache | grep <Keywords>

hint: If you are not sure about the installation method of the software, you can try the above command to check one by one.

3. Uninstall the software using APT

APT is Ubuntu's default package management tool for software installed through the Software Center, command line, or PPA.

3.1 Uninstall the software (retain the configuration)

  • Applicable scenarios: Only delete the software ontology and retain the configuration files for future reuse.
  • Order
sudo apt remove <Package name>
  • Example
sudo apt remove vlc
  • verify
which vlc
dpkg -l | grep vlc
  • If empty or no relevant information is returned, it means that the uninstallation is successful.

3.2 Completely uninstall (remove configuration)

  • Applicable scenarios: Delete software and its system-level configuration files, recommended to use by default.
  • Order
sudo apt purge <Package name>
  • Example
sudo apt purge vlc
  • verify: Same as above.

Notice: apt purge does not clean up the configuration in the user directory (such as ~/.config/vlc), and needs to be deleted manually (see 3.5).

3.3 Clean up dependencies

  • Applicable scenarios: Remove dependency packages that are no longer needed after uninstallation.
  • Order
sudo apt autoremove
  • verify
sudo apt autoremove --dry-run
  • Check if there are still dependencies that can be cleaned up.

3.4 Clean up the cache

  • Applicable scenarios: Release/var/cache/apt/archivesDownloaded in.debPackage space.
  • Order

    Clean out obsolete cache:

sudo apt autoclean
  • Clean all caches:
sudo apt clean
  • verify
du -sh /var/cache/apt/archives
  • Confirm that the cache directory is cleared.

3.5 Clean up user directory residues

  • Applicable scenarios: Delete the software's configuration files and cache in the user directory.
  • step

    Check common directories:

ls -a ~/.config | grep <Software name>
ls -a ~/.local/share | grep <Software name>
ls -a ~/.cache | grep <Software name>
  • Delete related files:
rm -rf ~/.config/<Software related catalog>
rm -rf ~/.local/share/<Software related catalog>
rm -rf ~/.cache/<Software related catalog>
  • Example
rm -rf ~/.config/vlc
rm -rf ~/.cache/vlc

Notice: Make sure that the file has no important data before deletion and back up if necessary.

4. Uninstall the software using DPKG

DPKG is suitable for manual installation.debScenarios that a package or APT cannot handle.

  • Find installed packages
dpkg -l | grep <Keywords>
  • Uninstall the software (configure retain)
sudo dpkg -r <Package name>
  • Fix dependencies
sudo apt -f install
sudo apt autoremove
  • verify
dpkg -l | grep <Package name>
  • If there is no output, it means that the uninstallation is successful.

Notice: PriorityaptUninstall, DPKG is more suitable for special scenarios.

5. Uninstall the software using Snap

Snap is Ubuntu's containerized package management method.

View installed Snap software

snap list

Uninstall Snap Software

sudo snap remove <Software name>

Clean the residue (optional)

sudo rm -rf /var/lib/snapd/snap/<Software name>

verify

snap list | grep <Software name>

If there is no output, it means that the uninstallation is successful.

Uninstall Snapd (optional)

  • If you no longer use Snap:
sudo apt purge snapd
rm -rf ~/snap

Notice: Snap uninstall usually cleans most files automatically, but old versions may remain and need to be checked manually.

6. Uninstall the software using Flatpak

Flatpak is a containerized package management method for cross-distribution.

View the installed Flatpak app

flatpak list

Uninstall the app

flatpak uninstall <applicationIDor software name>

Clean up useless runtime

flatpak uninstall --unused

Clean up user directory residues

rm -rf ~/.var/app/<applicationID>

verify

flatpak list | grep <Software name>
  • If there is no output, it means that the uninstallation is successful.

Notice: Flatpak's application ID is usually, the full ID is required when uninstalling.

7. Uninstall the software installed by the source code

The software installed in the source code is not managed by the package manager and needs to be deleted manually.

  • Positioning installation directory
    • Usually in/usr/local/optor a directory specified by the user.
    • Check the installationmake installRecord orREADMEdocument.
  • Delete files
sudo rm -rf /usr/local/<Software Directory>
  • Clean up user configuration:
rm -rf ~/.config/<Software name>
rm -rf ~/.local/share/<Software name>
  • verify
which <Software name>
  • If it returns empty, it means that the uninstallation is successful.

Notice: The software installed in the source code may involve the system library, and confirmation before deletion will not destroy the dependency.

8. Uninstall the AppImage software

AppImage is a portable application that does not require installation.

Delete the AppImage file

  • Find the storage location (such as~/DownloadsOr custom directory):
find ~/ -name "*.AppImage"
  • delete:
rm ~/path/to/<Software name>.AppImage

Clean the residual configuration

rm -rf ~/.config/<Software name>
rm -rf ~/.local/share/<Software name>

verify

  • confirm.AppImageThe file has been deleted.

Notice: AppImage does not affect system files, and there is no need to clean up dependencies after uninstalling.

9. Clean up system-level residuals

9.1 Cleaning up old kernels

  • Applicable scenarios: Free up space occupied by the old kernel.
  • View the current kernel:
uname -r
  • List installed kernels:
dpkg --list | grep linux-image
  • Delete the old kernel:
sudo apt remove linux-image-<Version number>
sudo apt autoremove
  • Update boot:
sudo update-grub

9.2 Clean up third-party sources (PPA)

  • View source list:
ls /etc/apt//
  • Delete useless PPA:
sudo rm /etc/apt//<file name.list>
  • Update source:
sudo apt update

10. Commonly used combination commands

10.1 APT software is completely uninstalled

sudo apt purge &lt;Package name&gt;
sudo apt autoremove
sudo apt clean
rm -rf ~/.config/&lt;Software name&gt;
rm -rf ~/.cache/&lt;Software name&gt;

10.2 Snap software uninstallation

sudo snap remove &lt;Software name&gt;
rm -rf ~/snap/&lt;Software name&gt;

10.3 Flatpak software uninstallation

flatpak uninstall &lt;applicationID&gt;
flatpak uninstall --unused
rm -rf ~/.var/app/&lt;applicationID&gt;

11. Troubleshooting

  • The package name cannot be found
    • usedpkg -l | grep <keywords>orapt search <keywords>Find.
    • Check the Snap or Flatpak list.
  • Dependency damage
sudo apt -f install
sudo apt autoremove
  • Uninstall failed
    • Confirm whether there are running processes:
ps aux | grep &lt;Software name&gt;
kill -9 &lt;processID&gt;
    • Try uninstall again.
  • Snap/Flatpak cannot be uninstalled
    • make suresnapdorflatpakThe service is normal, or it is uninstalled after reinstalling.

12. Best Practices

  1. Priority useapt purge: Reduce configuration file residues.
  2. Clean cache regularly: Run monthlyapt autoremoveandapt autoclean
  3. Verify uninstall:usewhichOr the package manager command confirms that the software has been removed.
  4. Backup important configurations: Backup before cleaning up the user directory.configKey documents in  .
  5. Careful operating system files: Avoid mistaken deletion/etcor/usrShared files in  .

Summarize

With this guide, you can easily uninstall software from your Ubuntu system and clean up residues. Core steps:

  1. Confirm the installation method: APT, Snap, Flatpak, source code or AppImage.
  2. Perform uninstall: Use the corresponding command (such asapt purgesnap remove)。
  3. Clean up the residue: Handle dependencies, caches, and user directory files.
  4. Verification results: Make sure that the software and related files have been completely removed.

The above is the detailed content of the ultimate guide for software uninstallation and cleaning in Ubuntu system. For more information about Ubuntu software uninstallation and cleaning, please follow my other related articles!