81

Is there a way to know which GTK version is installed using the command line?

I am working on Ubuntu 11.10.

avpaderno
  • 297
Black Block
  • 5,139

6 Answers6

76

apt-cache policy libgtk2.0-0 libgtk-3-0 (optionally pipe to grep Installed)

or

dpkg -l libgtk2.0-0 libgtk-3-0

zpletan
  • 3,443
  • 1
    The grep is localized, so for french users you may have to type | grep Installé – Hybris95 Jan 11 '21 at 06:05
  • 1
    rather than assuming the major version to get the minor version, one can first run something like: dpkg --get-selections | grep 'libgtk.*bin' which today will likely show gtk2, gtk3, and gtk4, then you can pass those to dpkg -l, for example, dpkg -l libgtk2.0-bin libgtk-3-bin libgtk-4-bin – michael Sep 11 '22 at 06:25
  • 2
    @michael, you can also use that with dpkg-query as in dpkg-query -W libgtk*bin – randyman99 Jun 19 '23 at 21:48
  • @randyman99 - This is the most useful command. – wdp Oct 05 '23 at 20:03
  • 1
    Since Ubuntu 16.04 LTS (I haven't checked if it works with any previous release), you can use wildcards in the selector, as dpkg -l 'libgtk*'. Remember to surround the expression with single quote. You could pipe to a grep, if you want a finer output. – alberto May 21 '24 at 08:04
11

--get-selections will show you the installed packages

dpkg --get-selections | grep gtk
  • 4
    This is the ONLY answer of all the terrible answers that actually makes sense. And guess what, on my 22.04 there are THREE GTK versions installed. libgtk2.0-bin libgtk-3-bin libgtk-4-bin among many other GTK packages. – redanimalwar Aug 11 '22 at 18:59
  • This just gives a list of packages that contain "gtk" in their name. – wdp Oct 05 '23 at 19:58
10

Try this:

dpkg -l libgtk2.0-0 libgtk-3-0

This will give info for both GTK 2 and 3.

MiJyn
  • 3,396
  • 1
    Too bad still not gtk 4.0 – Melroy van den Berg Dec 17 '21 at 23:24
  • Well with this shitty you never know if you have GTK 4 installed because it does not ask for it. (And yes I realize this question is 10 years old, with makes this answer now BAD) – redanimalwar Aug 11 '22 at 18:56
  • @MelroyvandenBerg, Please check our comments about using wildcards or general queries along with grep. – alberto May 21 '24 at 08:18
  • Just relative recently GTK 4 is now here on my Linux Mint distro. Base on Ubuntu Jammy. GTK4 seems to be backported now from Ubuntu 22.04, when looking at this version: 4.6.9+ds-0ubuntu0.22.04.2 – Melroy van den Berg May 22 '24 at 09:06
8

Try these commands

gtk-launch  --version
gtk3-launch --version
gtk4-launch --version
zx485
  • 2,894
diogob003
  • 91
  • 1
  • 4
3

Try: dpkg-query -W libgtk-3-bin

# Gives version as 3.10.8, separated on the left by a tab, and on the right by a ~
$ dpkg-query -W libgtk-3-bin
libgtk-3-bin    3.10.8~8+qiana

# An associated package also gives the package architecture [for me]
$ dpkg-query -W libgtk-3-0
libgtk-3-0:amd64    3.10.8~8+qiana
ThorSummoner
  • 3,392
3
  1. Open Synaptic Package Manager: enter image description here

  2. Under "Quick filter" enter "libgtk-3".

  3. Gtk3 libraries are contained in "libgtk-3-0". You may want to select it for convenience. Your installed version appears in the column "Installed version". If you need additional information press the button "Properties".