Do apt-get and apt maintain separate databases, and what happens if you use both?
-
In the Linux Essentials training, Don mentions that apt-get and apt handle the database of dependencies differently. Does that mean that they keep separate databases of packages? If so, what happens if you install/remove some packages with apt-get and others with apt? Will they get confused about which dependencies are already installed or which are no longer needed?
For example, apt-get install pkg1, installs pkg1 and pkg0 that it depends on. Next, apt install pkg2 installs pkg2, which is also dependent on pkg0. Does it reinstall pkg0 over the existing installation? Does it recognize that pkg0 is already installed?
Next, if we do apt remove pkg2, does it remove pkg0 because it doesn't know about the dependency of pkg1? -
apt and apt-get do maintain separate databases for the updates. For the most part, you can switch between the two without issue. However, there are certain scenarios that apt handles well, but will completely trip up apt-get. In your example, using apt to install pkg2 would not cause pkg0 to be reinstalled. Both utilities are able to see what software packages have been installed regardless of which tool installed them. So from that point of view, the two utilities play nice together.
Where things get hairy is when it comes to updates. Let's say we have a package (pkg1) that depends on another package (lib1). We then install another program (pkg2) that also depends on lib1. So far, either tool can handle this situation. Now let's say an update comes out for pkg2 that requires a newer version of lib1. Both tools will detect that, but apt-get will often be oblivious to the fact that updating pkg2 and lib1 may potentially break pkg1. apt on the other hand will see that updating lib1 would effect both pkg1 and pkg2, and hold the updates to a version supported by both, or manage simlinks in a way that each application can use the necessary versions.
There are a ton of exceptions to this and many other scenarios that apply, but I think that is a decent example of where one tool excels over the other.