apt-get purge
- Completely removes a package and its configuration files.
- Also removes any packages that depend on the package being purged.
- Can be used to free up disk space.
apt-get remove
- Removes a package but leaves its configuration files intact.
- Does not remove any packages that depend on the package being removed.
- Can be used to downgrade a package to a previous version.
Comparison
| Feature | apt-get purge | apt-get remove |
|---|---|---|
| Removes package | Yes | Yes |
| Removes configuration files | Yes | No |
| Removes dependent packages | Yes | No |
| Can be used to free up disk space | Yes | No |
| Can be used to downgrade a package | No | Yes |
Example
To purge the apache2 package, you would use the following command:
sudo apt-get purge apache2
To remove the apache2 package, but leave its configuration files intact, you would use the following command:
sudo apt-get remove apache2
Additional notes
apt-get purgeis a more destructive command thanapt-get remove. It should be used with caution.- If you are not sure whether you should use
apt-get purgeorapt-get remove, it is best to useapt-get remove. - You can also use the
apt-get autoremovecommand to automatically remove any packages that are no longer needed.