8

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
  • 249
  • 2
  • 10
  • The -s option shows what packages will be removed. Why do you need more detail? – Zeiss Ikon Nov 16 '17 at 14:15
  • 1
    I want to know which files are really removed... Is it that strange? – nephewtom Nov 16 '17 at 14:17
  • I can run dpkg -L <package-name> and the will list the files associated with that package. I suspect that those ones are the files that will be removed by apt-get remove and apt-get purge. Though not sure if there more details. – nephewtom Nov 16 '17 at 14:24
  • Generally, if you list the files in a package, and remove that package, all those files will be removed unless another installed package depends on them. – Zeiss Ikon Nov 16 '17 at 15:52

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,507
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
  • 197,895
  • 55
  • 485
  • 740
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
  • 161