apt-get remove: Usage, Options & Common CI Errors
apt-get remove uninstalls a package but, by default, leaves its config files behind.
apt-get remove takes a package off the system. The distinction that catches people in CI is remove (keeps config) versus purge (deletes config too), which matters when you slim an image or reset state.
What it does
apt-get remove uninstalls the named package but keeps its configuration files under /etc. apt-get purge (or remove --purge) also deletes the config. --auto-remove additionally drops dependencies that were installed only for the removed package and are now unused.
Common usage
apt-get remove -y nginx
apt-get purge -y nginx # also delete config files
apt-get remove --purge --auto-remove -y nginx # full cleanup
apt-get autoremove -y # drop now-unused depsCommon errors in CI
A common surprise: apt-get remove leaves /etc config behind, so reinstalling later picks up old settings - use purge when you want a clean slate. Removing a package can cascade: apt may remove dependents too, which the plan output shows ("The following packages will be REMOVED") - read it before passing -y. "E: Unable to locate package X" on remove means the name is wrong; "Package X is not installed, so not removed" is informational, not a failure. Always pass -y in CI.
Options
| Flag | What it does |
|---|---|
| -y / --yes | Assume yes (required in CI) |
| --purge | Also remove configuration files |
| --auto-remove | Remove now-unused dependencies too |