SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / ubuntu / Questions / 8560
Accepted
dfme
dfme
Asked: 2010-10-21 12:43:30 +0800 CST2010-10-21 12:43:30 +0800 CST 2010-10-21 12:43:30 +0800 CST

How do I find out which repository a package comes from?

  • 772

Is there a method or command which can tell from which repository a package is coming from?

package-management repository apt
  • 6 6 Answers
  • 197021 Views

6 Answers

  • Voted
  1. SuB
    2013-09-20T22:21:19+08:002013-09-20T22:21:19+08:00

    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>
    
    • 197
  2. Best Answer
    crenshaw-dev
    2010-10-21T13:49:08+08:002010-10-21T13:49:08+08:00

    Edit:

    Check out SuB's answer. Looks a bit simpler!

    Original:

    Commands Needed:

    • 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>.

    Example:

    $ dpkg -s liferea
    Package: liferea
    Status: install ok installed
    Priority: optional
    Section: web
    Installed-Size: 760
    Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
    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 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_lucid_main_binary-i386_Packages.

    Without too much effort, I can deduce that the source line contains archive.ubuntu.com, ubuntu, lucid, and main.

    And, sure enough, my /etc/apt/sources.list contains the following line.

    deb http://archive.ubuntu.com/ubuntu lucid main universe restricted multiverse
    
    • 155
  3. Pablo Bianchi
    2017-06-02T11:27:35+08:002017-06-02T11:27:35+08:00

    apt on Ubuntu 16.04+

    Beside apt-cache policy, showpkg and show, now we have a more simple, with easy to remember subcommands: apt[1] [2] (don't get confused with classic apt-*):

    apt policy <package> 
    

    Or the alternative with more info apt show <package>, line starting with "APT-Sources:".

    Description: This package provides command line tools for searching and managing as well as querying information about packages as low-level access to all features of the libapt-pkg library. This includes:apt-get, apt-cache, apt-cdrom, apt-config, apt-key.

    Warning: apt does not have a stable CLI interface. Use with caution in scripts.

    Basic commands from apt --help

    Other also easy to remember subcommands:

    • apt list – list packages based on package names

    • apt search – search in package descriptions

    • apt show – show package details

    • apt update – update list of available packages

    • apt install – install packages

    • apt remove – remove packages

    • apt purge – remove packages and configuration files:

      Removing a package removes all packaged data, but leaves usually small (modified) user configuration files behind, in case the remove was an accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. On the other hand you can get rid of these leftovers by calling purge even on already removed packages. Note that this does not affect any data or configuration stored in your home directory.

      To remove residual packages:

      sudo apt purge $(dpkg -l | grep "^rc" | awk '{print $2}')
      
    • apt upgrade – upgrade the system by installing/upgrading packages

    • apt full-upgrade – upgrade the system by removing/installing/upgrading packages

    • apt edit-sources – edit the source information file

    • 22
  4. kanaka
    2010-10-21T13:37:35+08:002010-10-21T13:37:35+08:00

    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.

    • 9
  5. sBlatt
    2010-10-21T13:29:00+08:002010-10-21T13:29:00+08:00
    sudo grep *packagename* /var/lib/apt/lists/* | grep "Filename:"
    

    source

    • 4
  6. Jiang
    2021-12-23T15:27:38+08:002021-12-23T15:27:38+08:00

    Another useful command is "apt-cache policy". It will show something like this:

    $ apt-cache policy 
    Package files: 
     # The default https://wiki.debian.org/DebianStable repository with a priority of 500
     500 https://deb.debian.org/debian stable/main amd64 Packages
         o=Debian,n=stable,l=Debian,c=main,b=amd64
         origin deb.debian.org
    
     # The repository for Debian https://wiki.debian.org/PointReleases (security and grave bug fixes ~every 2 months)
     500 https://deb.debian.org/debian stable-updates/main amd64 Packages
         release o=Debian,a=oldstable-updates,n=stable-updates,l=Debian,c=main,b=amd64
         origin deb.debian.org
    

    Ref: https://wiki.debian.org/AptConfiguration

    • 1

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    How to add a directory to the PATH?

    • 17 Answers
  • Marko Smith

    How do I install .run files?

    • 7 Answers
  • Marko Smith

    How to list all installed packages

    • 24 Answers
  • Marko Smith

    How do I get the CPU temperature?

    • 21 Answers
  • Marko Smith

    Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

    • 25 Answers
  • Marko Smith

    How can I add a user as a new sudoer using the command line?

    • 7 Answers
  • Marko Smith

    Change folder permissions and ownership

    • 9 Answers
  • Marko Smith

    How do you restart Apache?

    • 13 Answers
  • Marko Smith

    How can I uninstall software?

    • 11 Answers
  • Marko Smith

    How can PPAs be removed?

    • 26 Answers
  • Martin Hope
    justingrif How to add a directory to the PATH? 2009-07-23 12:42:23 +0800 CST
  • Martin Hope
    NES How to enable or disable services? 2010-12-30 13:03:32 +0800 CST
  • Martin Hope
    Ivan How to list all installed packages 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra Unable to lock the administration directory (/var/lib/dpkg/) is another process using it? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    Olivier Lalonde How to keep processes running after ending ssh session? 2010-10-22 04:09:13 +0800 CST
  • Martin Hope
    David B How can I add a user as a new sudoer using the command line? 2010-10-16 04:02:45 +0800 CST
  • Martin Hope
    Hans How do I remove old kernel versions to clean up the boot menu? 2010-08-21 19:37:01 +0800 CST
  • Martin Hope
    David Barry How do I determine the total size of a directory (folder) from the command line? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "The following packages have been kept back:" Why and how do I solve it? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford How can PPAs be removed? 2010-07-30 01:09:42 +0800 CST

Related Questions

Trending Tags

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve