Interview Q&A / Linux & Shell

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is the difference between apt remove, purge and autoremove?

SHORT ANSWER

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 nginx removes the binaries but leaves files in /etc/nginx, so a later reinstall restores your old settings.
  • sudo apt purge nginx removes the package and its system-wide config files. Your own data (like a database in /var/lib) may still need manual deletion.
  • sudo apt autoremove removes 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

bash
sudo apt remove nginx
ls /etc/nginx | head -2          # config still there
sudo apt purge nginx
sudo apt autoremove
sudo apt clean

What 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.

#linux#package-managers#apt

Related questions

Practise more Linux & Shell questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Linux & Shell quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.