What is the difference between apt remove, purge and autoremove?
remove deletes a package's programs but keeps its configuration files. purge deletes the programs and the configs. autoremove deletes dependency packages that were installed automatically and are no longer needed by anything.
Explain it simply
Uninstalling a game: removing the app, versus removing the app plus your saved settings, versus cleaning up the helper libraries it brought along.
sudo apt remove nginxremoves the binaries but leaves files in/etc/nginx, so a later reinstall restores your old settings.sudo apt purge nginxremoves the package and its system-wide config files. Your own data (like a database in/var/lib) may still need manual deletion.sudo apt autoremoveremoves packages that were pulled in as dependencies and are now orphaned. It lists them first, so read the list.
A tidy clean-up often combines them: sudo apt purge nginx && sudo apt autoremove.
apt clean is different: it deletes downloaded .deb files from /var/cache/apt/archives to free disk space and does not touch installed software.
On Red Hat systems, dnf remove leaves modified config files as .rpmsave files rather than keeping the folder as is.
Example
sudo apt remove nginx
ls /etc/nginx | head -2 # config still there
sudo apt purge nginx
sudo apt autoremove
sudo apt cleanWhat to say in the interview
"remove keeps config files, purge deletes them too, and autoremove clears dependencies nobody needs any more. clean only empties the download cache. I read the autoremove list before confirming."
Common mistakes
- Using purge and expecting application data in /var/lib to be deleted as well.