The Autoremove Command
Ubuntu uses the Advanced Package Tool (APT) to manage software. When you install a new application, APT automatically downloads and installs any required dependencies (helper libraries and tools). If you later uninstall that main application, those dependencies are often left behind on your system as “orphaned” packages. To clean up disk space, Ubuntu sometimes suggests or automatically runs an apt autoremove command during major system updates to purge these unused dependencies. However, if you are a developer relying on a specific library that was originally installed as a dependency for something else, this automatic purging will break your custom scripts or unmanaged software.
Preventing the Purge of Specific Dependencies
To protect vital libraries and stop Ubuntu from automatically purging unused dependencies that you actually want to keep, you must explicitly mark those specific packages as manually installed.
Open a terminal window (Ctrl+Alt+T). If you know the name of the dependency package you want to protect (for example, `libfoo-dev`), you can tell the APT package manager that you installed it on purpose, rather than it just being an automatic requirement for something else. Type the command sudo apt-mark manual [package_name] and press Enter (replace `[package_name]` with the actual name, e.g., sudo apt-mark manual libfoo-dev). The system will output a message confirming that the package is “set to manually installed.” Because APT now believes you specifically requested this software, it will never flag it as an orphaned dependency, and it will survive any future `autoremove` or automatic system clean-up operations.