How do you track which packages were installed on Ubuntu (Linux)?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Over a Mysterious Island
--
Chapters
00:00 How Do You Track Which Packages Were Installed On Ubuntu (Linux)?
01:19 Answer 1 Score 3
02:01 Accepted Answer Score 31
04:03 Answer 3 Score 7
04:33 Answer 4 Score 3
05:46 Answer 5 Score 2
05:58 Answer 6 Score 2
08:05 Thank you
--
Full question
https://superuser.com/questions/6338/how...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #ubuntu #packagemanagement #aptitude
#avk47
ANSWER 1
Score 3
I think perhaps you're confusing monograms with initials.
Initials are always listed in the same order as they would appear in the name: the initials of William Henry Gates are WHG, the initials of Bill Gates are BG, etc.
Monograms, on the other hand, combine the initials in an aesthetically-pleasing way. A common method is to put the last name's initial in the middle, and the first & middle names on the left and right, respectively. Almost always, the last initial (the one in the middle) is larger than the other two. The monogram of William Henry Gates could thus look something like:
ACCEPTED ANSWER
Score 31
On any Debian based machine, this is one common way to duplicate a package set. On the old machine:
dpkg --get-selections "*" > my_favorite_packages
Copy the file my_favorite_packages
to the new machine (a thumb drive is a good option, but scp
also works fine). Then run this sequence (with root privileges):
apt-get update
dpkg --set-selections < my_favorite_packages
apt-get -u dselect-upgrade
This doesn't get you only the packages you installed. It also gets their dependencies, etc. Also, if the repositories between the two machines are different, all bets are off.
As far as logs, apt-get
keeps a log at /var/log/apt/history.log
(thanks to Tshepang for updating this in a comment); dpkg
does (at /var/log/dpkg.log
), but it's famously hard to parse and can only be read with root privileges; aptitude
has one at /var/log/aptitude
and you can page through it with regular user privileges.
As far as I can tell, you are right that none of these logs track specifically what you installed as opposed to auto-installed dependencies. You can get that information, however, from an aptitude
search. Search for all installed packages that were also installed automatically:
aptitude search '~i ~M'
If you want only the ones you installed (not the auto-dependencies), negate the ~M
:
aptitude search '~i !~M'
If you want that formatted so that you have only the names of packages and the word "install", aptitude
can do that too. This gives you a list ready to feed to dpkg --get-selections
:
aptitude search '~i !~M' -F "%p install"
(I've got nothing on RedHat or RedHat-based systems. Sorry. There really is no one answer for Linux per se since package management is a big part of what makes different distros different.)
ANSWER 3
Score 7
Use dpkg -l '*' > jaunty.original
to remeber all installed packages on a freshly installed system.
After you have installed all your additional packages do dpkg -l '*' > mysystem.2009017
.
The additional packages are just the difference: diff jaunty.original mysystem.2009017
ANSWER 4
Score 3
Aptitude is actually quite good at this. Aptitude does know when something was installed by hand or by dependency and you can tell it to remove things that are no longer needed and were only installed because something else depended on it always keeping up your system as small as possible.
There's a handful of packages that make up an Ubuntu installation, ubuntu-minimal, ubuntu-desktop, ubuntu-server and so on. If you tell Aptitude to mark those as manually installed and remove everything else, then you end up with the minimum amount possible of packages.
I explain how to do all that in two posts at my blog: Cleaning up a Debian GNU/Linux and Cleaning up a Debian GNU/Linux (or Ubuntu), reprise. In short, the answer you are looking for is:
aptitude search ~i | grep -v "i A"
The last time I worked with that, if you used apt-get, then it didn't work. That's why I always recommend aptitude and as far as I know, Debian is deprecating apt-get in favor of aptitude.
I don't know how to do it on Fedora and you should probably separate than into a different question. Fedora and Ubuntu are different operating systems and should be treated as such (even if they share their kernel and some other stuff).
ANSWER 5
Score 2
On debian apt-show-versions shows the versions of the installed packages.
ANSWER 6
Score 2
When just using dpkg
you don't know whether the package was manually installed by the user or automatically (as a dependency or during the initial OS install). If you want to retain that information, you need to get a list of only the packages that were actually manually installed.
For that, you can use either of these two one-liners. Both yield the exact same output on my machine and are more precise than all solutions proposed up until now in this question. They are a combination of the two answers (1) and (2). Note that I originally posted this answer here.
Using apt-mark
:
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
Using aptitude
:
comm -23 <(aptitude search '~i !~M' -F '%p' | sed "s/ *$//" | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
Very few packages still fall through the cracks, although I suspect these are actually installed by the user, either right after the installation through the language localization setup or e.g. through the Totem codec installer. Also, the linux-header versions also seem to accumulate, even though I've only installed the non version-specific metapackage. Examples:
libreoffice-help-en-gb
openoffice.org-hyphenation
gstreamer0.10-fluendo-mp3
linux-headers-3.13.0-29
How does it work
- Get the list of manually installed packages. For aptitude, the additional
sed
strips out remaining whitespace at the end of the line. - Get the list of packages installed right after a fresh install.
- Compare the files, only output the lines in file 1 that are not present in file 2.
Other possibilities don't work as well:
- Using the
ubuntu-14.04-desktop-amd64.manifest
file (here for Ubuntu 14.04) instead of/var/log/installer/initial-status.gz
. More packages are shown as manually installed even though they are not. - Using
apt-mark showauto
instead of/var/log/installer/initial-status.gz
.apt-mark
for example doesn't include the xserver-xorg package, while the other file does.
Both list more packages than the above solution.