Tuesday, September 26, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1587  / 5 Months ago, tue, april 25, 2023, 7:57:38

I'm always confused to get the version of software installed in Ubuntu. To prevent from full typing to get the version like <software> --version instead I always use something like <software> -V.

But the problem is that not for all software it works. For some I've to use <software> -v and for some, I've to use full --version to get the version.

For example

wget, gedit, nano, mysql`, etc all work with -V (Capital V)

but Php, Skype and may be others never worked with -V instead I've to use -v (small v) to get the version:

php -V
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]

php -v
PHP 5.3.10-1ubuntu3.9 with Suhosin-Patch (cli) (built: Dec 12 2013 04:27:25)

Some work with both -v and -V like firefox. And some even don't work with either of -v or -V like totem, wine and google-chrome.

  • Why there is this much difference?

  • Since -V is always preferred to get the version of the software, why there is no any standard? or is there any standard that I don't know?

More From » versions


The correct way to get the version of system-installed software is to use your package manager tools!

--version is not a reliable way to do so, for several reasons:

  • Not all programs have executables. Libraries are a good example. You can't check your kernel version using linux --version, as there is no such command. Or your video driver version.

  • Not all executables have command-line arguments. Most do, but GUI programs don't need to, and some don't.

  • --version, as any command-line argument, is application-dependent. It depends on the developer to implement it, and there is no "standard" per-se, merely a convention. As you've noticed with -v|-V, it is not consistent. Even --help is not universal.

  • The format output of --version is not consistent either. Some print a single line, some print several. Some print the version number only, some print the program name too.

That said, there is a standard, consistent way to get the installed version of any software in your system: ask the system, not the sofware!

Thanks to its Debian heritage, Ubuntu has a powerful package management system called apt (actually, dpkg). It controls installed packages, its dependencies, available repositories, and versions.

There are several package-management tools and front-ends you can use to query your installed packages. Here are some that display the version:

  • apt-cache policy <package>

  • dpkg --list <package> (you can use wildcards!)

And if you don't know what package a given command belongs to, you can find out in several ways:

  • apt-cache search '<name>'

  • apt-file search '<path>'

And the output is always consistent, reliable, standard, because you're not asking individual software made by distinct developers, you're querying your system about its status.

As an example, here's the result of a search of all the commands your mentioned in a single output:

$ dpkg --list wget gedit nano mysql-server skype php? firefox totem wine google-chrome*

| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
ii firefox 42.0+build2-0ubuntu0.12.04 Safe and easy web browser from Mozilla
ii gedit 3.4.1-0ubuntu1 official text editor of the GNOME desktop environment
ii google-chrome-stable 46.0.2490.80-1 The web browser from Google
ii mysql-server 5.5.46-0ubuntu0.12.04.2 MySQL database server (metapackage depending on the latest version)
ii nano 2.2.6-1 small, friendly text editor inspired by Pico
ii php5 5.3.10-1ubuntu3.21 server-side, HTML-embedded scripting language (metapackage)
ii skype client for Skype VOIP and instant messaging service
ii totem 3.0.1-0ubuntu21.1 Simple media player for the GNOME desktop based on GStreamer
ii wget 1.13.4-2ubuntu1.2 retrieves files from the web
ii wine 1.4-0ubuntu4.1 Microsoft Windows Compatibility Layer (meta-package)

[#27200] Wednesday, April 26, 2023, 5 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 43
Total Questions: 125
Total Answers: 102

Location: Gabon
Member since Sat, Jul 25, 2020
3 Years ago