Finding installed packages linux

How to list manually installed packages?

I’d like to get a list of packages installed manually by apt or aptitude and be able to find out whether a foobar package was installed manually or automatically. How can we do that from the command line?

Really good solution that excludes packages installed by default: Ubuntu list explicitly installed packages

«package was installed manually or automatically» How about manually or by dependency. I just did clean install of Debian for WSL, followed by apt update and custom install of only 5 package names: ack, zsh, vim, tree, git. Three of the high-vote solutions below make a list of 112 items.

20 Answers 20

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 (July 6, 2014) in this question.

Using apt-mark :

Using aptitude :

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:

  1. Get the list of manually installed packages. For aptitude, the additional sed strips out remaining whitespace at the end of the line.
  2. Get the list of packages installed right after a fresh install.
  3. 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.

I used various other StackExchange posts as references, however none work as well as the above solution:

Both list more packages than the above solution.

EDIT: What to do if you’ve upgraded from a previous release:

If you’ve upgraded Ubuntu from one release to the next, you will probably need to adjust this process. In that case, I would check the manifest file of the newer release (see above) in addition to the initial-status.gz file from the current release. You can easily do that by just adding another comparison. Using just the manifest file will not work, as the manifest file unfortunately does not contain everything that the initial_status.gz file does (I checked).

Читайте также:  Linux log error system

This didn’t work for me because /var/log/installer/initial-status.gz is missing. Also I want to know if this is depending on apts marking of manual or not?

This answer is the best I found until now. However, it (still) misses transient package suggestions (and recommendations). For example, when I apt install git-review , only git-review gets listed. So far, so good. When I apt remove git-review , the package git stays but is not listed. That is because git is a ‘suggests’ in the package libdpkg-perl (see /var/lib/dpkg/status). The same happens for if a package was installed with apt install —no-install recommends and later another package installs that recommendation, then it stays but gets not listed. No idea how to catch those.

I originally installed an older version of Ubuntu and now I’m running 20.04, so I downloaded the manifest from releases.ubuntu.com/20.04/… and then I ran comm -23 <(apt-mark showmanual | sort -u) <(cat ~/Desktop/ubuntu-20.04.2.0-desktop-amd64.manifest | awk '‘ | sort -u) . Thanks!

In newer versions of the package apt, there is also the apt-mark command

@Umang You are right. I would say this wasn’t like this when I wrote this answer. There is no reason on my system to consider linux-image-3.11.0-*-generic etc as manual

@Umang maybe this will help you askubuntu.com/questions/432743/…, but the answer is not accepted. Fact is, that many packages of a fresh installation are already marked as manual. But there are still some strange things. To stay with my example: linux-image-3.13.0-24-generic is manual but the current linux-image-3.13.0-27-generic is automatic. It seems that an upgrade of a referencing package (in this case linux-image-generic , which changed the dependencies), the manual mark is automatically set

@DanielAlder some packages of a fresh installation should be marked as manual. If no packages marked as manual, the entire system could be deleted with apt-get autoremove . This is definitely not what you want.

@AntonK that is usually done with the ubuntu-minimal and ubuntu-standard packages, there’s no need for any of their dependencies to be marked as manual

To get a list of all packages (not installed, installed by user or installed by default, across all PPAs), apt employs the following method:

The possible options useful for this are:

—installed to display only the packages that are installed on the system (out of some 50,000+)

—manual-installed to list the packages that were explicitly installed by a command, either directly, or as dependencies.

Читайте также:  Kali linux человек посередине

Alternatively, you could do:

apt list —installed | grep -F \[installed\] to get a list of packages that resulted from user commands and their dependencies only, and to get additional information on them such as version and architecture supported (x86, x86_64, amd64, all, etc.)

This still appears to list packages included in the base installation, which were not explicitly installed by the user running apt install . .

For Ubuntu 16.04, check out the log file /var/log/apt/history.log .

zgrep 'Commandline: apt' /var/log/apt/history.log /var/log/apt/history.log.*.gz 

It’s not perfect, but it’s pretty good at making it clear exactly what I installed by hand. Put a -B 1 on the grep to see when it was installed.

Commandline: apt install postgresql-9.5-plv8 Commandline: aptdaemon role='role-install-file' sender=':1.85' Commandline: apt install task Commandline: apt autoremove Commandline: apt install atom Commandline: apt upgrade Commandline: apt-get install asciinema Commandline: apt install iperf3 Commandline: apt upgrade Commandline: apt-get install chromium-browser Commandline: apt install joe cpanminus build-essential postgresql libdbd-pg-perl libcrypt-openssl-bignum-perl libcrypt-openssl-rsa-perl libio-socket-ssl-perl libnet-ssleay-perl libssl-dev Commandline: aptdaemon role='role-commit-packages' sender=':1.2314' Commandline: apt install git Commandline: apt install sqlite Commandline: apt install whois Commandline: apt install libdbd-pg-perl Commandline: apt install perl-doc Commandline: apt upgrade 

Not sure if this picks up aptitude or not. It doesn’t seem to pick up installs from the Ubuntu Software desktop app.

Источник

Find what packages are installed from a repository

I’m trying to find what packages I have installed from a repository using terminal commands. I found a post somewhere saying I could use aptitude search «?origin () ?installed» , but I couldn’t get it working. I tried searching for a packages that came from ppa:ubuntu-wine/ppa and got nothing with these:

aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/) ?installed" aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/) ?installed" aptitude search "?origin (http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/ raring/main) ?installed" 

5 Answers 5

Here is a shell script I wrote to display packages installed from different origins excluding Ubuntu. It uses common dpkg -l output format. It works faster than aptitude solutions.

#!/bin/sh # Print packages installed from different origins. # Exclude standard Ubuntu repositories. grep -H '^Origin:' /var/lib/apt/lists/*Release | grep -v ' Ubuntu$' | sort -u \ | while read -r line; do origin=$ echo $origin: list=$ sed -rn 's/^Package: (.*)$/\1/p' $*Packages | sort -u \ | xargs -r dpkg -l 2>/dev/null | grep '^.i ' echo done 

Some packages may be available from more than one repository. Run apt policy [pkgname] to check from which repository the current package is actually installed from.

Note that there may also be installed packages that have no such origin available, see this to find them.

Читайте также:  Linux показать com порты

@technastic_tc Could you run the line starting by grep excluding «. Upload the result in pastebin and share the link to it.

In brackets, you should use only the name of the repository, not the URI or something else. For example in your case:

aptitude search "?origin (ubuntu-wine) ?installed" 

Run apt-cache policy to see the repositories and the names (aka origin, o ) of those:

$ apt-cache policy | grep wine 500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main i386 Packages release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=i386 500 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial/main amd64 Packages release v=16.04,o=LP-PPA-ubuntu-wine,a=xenial,n=xenial,l=Wine Team PPA,c=main,b=amd64 

Since the search string is a regex pattern matched anywhere in the string, you can use a convenient substring like ubuntu-wine , or even just wine .

This did not list packages for me: aptitude search «?origin (multiverse) ?installed» — shouldn’t it? («multiverse» is enabled)

On my system, this seems to list packages that are installed and also available in the specified repository, irrespective of whether they were actually installed from that repository.

Origin is not URL of repository. To find Origin of repository look for file in /var/lib/apt/lists/ ending with Release.

grep "Origin" /var/lib/apt/lists/linux.dropbox.com_debian_dists_wheezy_Release 

So aptitude search «?origin(dropbox.com) ?installed» will show me installed package from dropbox repository.

You might need to escape some characters in the origin name, if they are special in regular expression.

From the command line If you like to do means

awk '$1 == "Package:" < if (a[$2]++ == 0) print $2; >' /var/lib/apt/lists/*PPA-FIRST-PART*PPA-SECOND-PART*Packages 

for example : All there are packages from noobslab

 jai@frank-Jai:~$ awk '$1 == "Package:" < if (a[$2]++ == 0) print $2; >' /var/lib/apt/lists/*noobslab*Packages python-logilab-common synapse ubuntuone-client python-ubuntuone-storageprotocol ubuntuone-client-gnome python-ubuntuone-client lives libweed0 libweed-dev lives-data converseen minitube libsyncdaemon-1.0-1 libsyncdaemon-1.0-dev ubuntu-sso-client python-ubuntuone-devtools ubuntuone-dev-tools ubuntuone-control-panel python-ubuntuone-control-panel synapse-dbg gir1.2-syncdaemon-1.0 libweed-dbg lives-dbg umplayer umplayer-translations libgranite-dev deepin-software-center ubuntuone-control-panel-qt python-dirspec rhythmbox-ubuntuone python-ubuntu-sso-client ubuntu-sso-client-qt python-ubuntu-sso-client.tests granite-demo ubuntuone-client-proxy python-oauthlib slidewall python3-dirspec python3-oauthlib ubuntuone-client-data libgranite1 libgranite1-dbg gir1.2-granite-1.0 libgranite-common curlew fbmessenger open-as-administrator indicator-synapse indicator-synapse-dbg wallpaper-manager awoken-icon-theme malys-uniblack malys-uniblue malys-ex acyl-icons nitrux-icons piratunbu-icons azenis-green-icons nouvegnome-color nouvegnome-gray hi-lights-icons matrilineare zoncolor-icons royal-linux-icons elementary-icons myhumanity myelementary glass-icons osx-nostalgie sky-blue-cinnamon sky-blue-gnome sky-blue-unity wine-blue-remix lubuntubox windows7-icons appleart-icons magical-lights-icons colored-plastic-icons numix-utouch-icon-theme ubudao-style artnet-icons high-delight-icons snow-sabre-icons trevilla-icons aery-icons ambiance-blue zukitwo gnomishbeige-theme salience-theme zukiwi gnomishgray delorean-dark smoothly-theme ambiance-ds-blue ambiance-lime gnomishdark zukitwo-cupertino-gs mediterranean-theme elementaryish borderline boje wow-2 zoncolor-themes omg-suite simplex leopard-steel dorian-theme daylight adwaita-elements uncomplicated trevilla-jmhzonedark trevilla-dark trevilla-white trevilla-whiteblue trevilla-whiteorange trevilla-white2 ambiancep-set ambiance-crunchy trevilla-gray siva-series-gtk cobibird elegant-brit mac-ithemes-noobslab mac-icons-noobslab ubuntu-touch-themes windows8-theme bigfootblue-cinnamon windows8-cinnamon eliza1-cinnamon bigfootred-cinnamon plus1-theme futura blo-theme darkair-theme plane-gtk3 deepin-gtk-theme nokto-theme numix-theme neptune-theme trevilla-themes jai@frank-Jai:~$ 

Источник

Оцените статью
Adblock
detector