Is there a method or command which can tell from which repository a package is coming from?
dpkg -s <package>- allows you to find the version of that you have installed. (source)
apt-cache showpkg <package>- will show a list of Versions of the package available. For each version, the source of the package, in the form of an index file name, will be given.
If you want to find the source of the package that's currently installed, you'll need the output of
dpkg -s <package>. Otherwise, you can simply look at the newest version output by
apt-cache showpkg <package>.
$ dpkg -s liferea Package: liferea Status: install ok installed Priority: optional Section: web Installed-Size: 760 Maintainer: Ubuntu Developers <firstname.lastname@example.org> Architecture: i386 Version: 1.6.2-1ubuntu6 ... $ apt-cache showpkg liferea Package: liferea Versions: 1.6.2-1ubuntu6.1 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_lucid-updates_main_binary-i386_Packages) Description Language: File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_lucid-updates_main_binary-i386_Packages MD5: 557b0b803b7ed864e6d14df4b02e3d26 1.6.2-1ubuntu6 (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_lucid_main_binary-i386_Packages) (/var/lib/dpkg/status) Description Language: File: /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_lucid_main_binary-i386_Packages MD5: 557b0b803b7ed864e6d14df4b02e3d26 ...
From the first command, I can see that Liferea version 1.6.2-1ubuntu6 is installed. From the second command, I can see that that version is listed in
Without too much effort, I can deduce that the source line contains
And, sure enough, my
/etc/apt/sources.list contains the following line.
deb http://archive.ubuntu.com/ubuntu lucid main universe restricted multiverse
Use following command. It has better output:
apt-cache policy <Package Name>
For Ubuntu 16.04 and later there is a shorter way to do that:
apt policy <Package Name>
Sadly, this information is not recorded during package installation. You can make a decent guess if the repository is still in the source list and the repository still has the package:
grep -l PKG /var/lib/apt/lists/*
Even synaptic cannot tell if you disable the repository and update.
apt on Ubuntu 16.04+
show, now we have a more simple, easy to remember subcommands:
apt (don't confuse with classic
apt policy <package>
or the alternative with more info
apt show <package>, line starting with "APT-Sources:".
Description: This package provides commandline tools for searching and managing as well as querying information about packages as a low-level access to all features of the libapt-pkg library. These include:
Basic commands from
Other also easy to remember subcommands:
list– list packages based on package names
search– search in package descriptions
show– show package details
update– update list of available packages
install– install packages
remove– remove packages
upgrade– upgrade the system by installing/upgrading packages
full-upgrade– upgrade the system by removing/installing/upgrading packages
edit-sources– edit the source information file
sudo grep *packagename* /var/lib/apt/lists/* | grep "Filename:"
This is a little more accurate:
apt-cache show <packagename> | grep "Version:"
The newest version will typically be installed unless you have set apt-pinning or explicitly install a particular version.