Debian Linux How to find out if installed package is from stable or testing environment

I install many packages for Debian / Ubuntu Linux from both stable/testing environment but some time I need to find out installed package is from stable or testing environment. I can use dpkg status file to get this information. But Debian comes with perl script called apt-show-versions which lists available package versions with distribution.

ADVERTISEMENTS

apt-show-versions parses the dpkg status file and the APT lists for the installed and available package versions and distribution and shows upgrade options within the specific distribution of the selected package. apt-show-versions uses caching for the status information of installed and available packages. If you run apt-show-versions as root the cache is updated as needed. If you run as non-root uses the newest available information, but can’t update the cache. If you run as root with the option -i the cache is initialized or updated only.

This is really useful if you have a mixed stable/testing environment and want to list all packages which are from testing and can be upgraded in testing.

Install apt-show-versions

Type the following command at shell prompt:
$ sudo apt-get install apt-show-versions
Just type command apt-show-versions:
$ apt-show-versions
Output:

java-common/testing uptodate 0.23
libperl5.8/testing upgradeable from 5.8.7-10 to 5.8.8-2
sysutils/testing upgradeable from 2.0.0-1 to 2.0.1
autoconf/unstable uptodate 2.59a-8

To upgrade all packages in testing you can type command:

# apt-get install $(apt-show-versions -u -b | fgrep testing)

Find out a list of all available versions of postgresql database server:

$ apt-show-versions -a -p postgresql
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • Eric Boutilier - OpenSolaris Mar 1, 2006 @ 7:08

    Hi!

    I don’t think this is Debian/Linux specific. IOW, it looks to me like it’ll also work for Nexenta (Debian/OpenSolaris), Debian/BSD, Debian/Hurd, etc.

  • 🐧 nixcraft Mar 1, 2006 @ 13:02

    Eric,

    You are right Nexenta/OpenSolaris use apt and this script should work on almost all Unixsh oses where perl and apt used. Thanks for pointing out.

  • dude Nov 29, 2017 @ 9:24

    Really cool stuff, thanks for sharing. Was looking for a way to track which packages are installed from other Debian branches when running a mixed/pinned gnu/Linux OS and came across this. Found another interesting and potentially useful command for doing that with apt-show-versions. To find/list packages on the OS installed from unstable.
    ie: apt-show-versions | grep /unstable

    Of course could be testing or even found out it works for seeing what you’ve got installed from backports in the case of Debian 9/Stretch. Would just replace unstable in the above command with /stretch-backports. Anyway, thanks again Vivek.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.