9

In this question is described how to remove an application with apt-get using the options remove and purge.

Is there a way to list which files are going to be removed with those before effectively doing it?

I saw there is a -s --simulate option, but that does not show with files will be removed after performing the command.

nephewtom
  • 259

3 Answers3

4

It isn’t possible to fully determine the impact of package removal or purge without performing the removal, because maintainer scripts in the package might remove more files than are listed as belonging to the package.

You can determine at least some of the impact though, by listing the files registered for each package which will be removed. When you run apt -s, you’ll see lines prefixes with Remv or Purg depending on whether the package will be removed or purged. Packages which are purged will remove all the files listed by dpkg -L; packages which are removed will remove those files, except the files listed by dpkg-query -W -f='${binary:Package}\n${Conffiles}\n'. In many cases this will cover everything that would be removed.

Stephen Kitt
  • 1,539
2

In general, it's not possible to list what files maybe removed. Packages contain maintainer scripts, and these files may create or remove files. These scripts could be shell scripts, Perl, Python, ... - so it's not possible to determine what's going to get removed without actually running the script.

Also, an ordinary remove doesn't remove configuration files, which are usually those in /etc, but could include other files depending on which were marked as conffiles, but purge removes these as well.

muru
  • 207,228
1

Check out the purge section in shell file /var/lib/dpkg/info/<package_name>.postrm to know what will happend if you run apt purge <package_name>.

https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html:

The postrm script is called after the package’s files have been removed or replaced. The package whose postrm is being called may have previously been deconfigured and only be “Unpacked”, at which point subsequent package changes do not consider its dependencies. Therefore, all postrm actions must only rely on essential packages and must gracefully skip any actions that require the package’s dependencies if those dependencies are unavailable.

n0099
  • 221