As the man apt-get
page says:
remove - remove is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed.
purge - purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).
This of course, does not apply to packages that hold configuration files inside the user's home folder (e.g. /home/SexyNoJutsuUser
), these files will not be touched ( Why does "Purge" not remove everything related to an app? )
So for example, if you were to purge
Chrome, Firefox, Kodi or any other that holds some configuration files inside your /home
folder, these configuration files will stay there.
On the other hand if you were to install Apache, squid, MySQL or any other services similar that save their configuration files in /etc
, these configuration files will be deleted if you use purge
.
In the Filesystem Hierarchy Standard, `/var/lib/ is stated as (in italic the most important part):
5.8.1 Purpose
This hierarchy holds state information pertaining to an application or
the system. State information is data that programs modify while they
run, and that pertains to one specific host. Users must never need to
modify files in /var/lib to configure a package's operation.
State information is generally used to preserve the condition of an
application (or a group of inter-related applications) between
invocations and between different instances of the same application.
State information should generally remain valid after a reboot, should
not be logging output, and should not be spooled data.
An application (or a group of inter-related applications) must use a
subdirectory of /var/lib for its data. There is one
required subdirectory, /var/lib/misc, which is intended for state
files that don't need a subdirectory; the other subdirectories should
only be present if the application in question is included in the
distribution.
/var/lib/ is the location that must be used for all distribution
packaging support. Different distributions may use different names, of
course.
In short: /var/lib/ is for data that is used locally.
So it makes perfect sense to put a database's data into /var/lib/{mysql|postgress}/ directory but... the FHS is a standard created mostly for use by distributions. As a user you are free to put your data wherever you want and it is mostly a matter of opinion.
You are misunderstanding the word "local". /usr/local/bin/ is not for system software but for your own software (basically anything with "local" in must never be touched by the system. As explained by FHS:
/usr/local/
4.9.1 Purpose
The /usr/local hierarchy is for use by the system administrator when
installing software locally. It needs to be safe from being
overwritten when the system software is updated. It may be used for
programs and data that are shareable amongst a group of hosts, but not
found in /usr. Locally installed software must be placed within
/usr/local rather than /usr unless it is being installed to replace or
upgrade software in /usr.
An executable installed from system software should never go to anything local.
Now for /usr/lib/.
4.7.1 Purpose
/usr/lib includes object files, libraries, and internal binaries that
are not intended to be executed directly by users or shell
scripts. Applications may use a single subdirectory under
/usr/lib. If an application uses a subdirectory, all
architecture-dependent data exclusively used by the application must
be placed within that subdirectory.
postgressql is probably a daemon started at boot? If so it makes sense to put it here. You are not suppose to use the command yourself but start a service. The files in /usr/lib/ tend to have their own user and group and/or a daemon that restricts access to /var/lib (only mysqld can access /var/lib/mysql/ for instance; this will be the same for postgressql)
Best Answer
Yes, there are such files. In particular,
*.list
,*.postrm
, and*.conffiles
, which are all stored in/var/lib/dpkg/info
directory.The
.postrm
files are post-remove scripts, that run after a package is removed. Those scripts are responsibility of the package maintainers, and each script is tailored to the specific package. If you examine/var/lib/dpkg/info/usb-modeswitch-data.postrm
for example , you will see something like this:There's also
*.list
and*.conffiles
files, which are basically lists.gnome-terminal.list
, for example, will list all files and directories created whengnome-terminal
was installed. The*.list
files are very useful for determining what installed what.*.conffiles
list all the config files for a package. For instance, whilexterm.list
gives all the files , `xterm.conffiles* gives only conffiles. In other words, the contents of conffile will also be present in list file.I don't quite know how
*.conffiles
work. My assumption is that the post-removal scripts take priority, andapt-get
just uses those*.conffiles
to double check that files listed there were removed.As @A.B. properly reminded me, there are also
*.prerm
files, some of which do remove the .conf files, but not necessarily, for instance the one forxpdf
app was removing the files in/etc/xpdf/includes
directory