Linux executable file version

How to view a PE EXE/DLL file version information?

In Windows there is a version information page in an executable/library file properties window. How to view that info in Ubuntu?

Do you mean how to view such information from Linux binaries/libraries or windows EXE/DLL using a Linux utility ?

As I’ve clearly specified in the question title, I mean PE (Windows) EXE and DLL files (to view using a Linux utility of course).

7 Answers 7

I’m working in a tool called pev to retrieve information about PE files on the command line.

The file version can be fetched with

In Ubuntu the command should be peres -v program.exe | awk ‘‘ after sudo apt install pev

pev -p works fine in Ubuntu 16.04. Just used to check Windows version remotely: pev -p /mnt/windows_host/Windows/explorer.exe

From the gnome-exe-thumbnailer script, suggested by Scott Ritchie:

wrestool --extract --raw --type=version inputfile.exe 

extracts the version information, printing some binary data mixed with UTF-16 text. The script converts it to readable text by piping it through:

tr '\0, ' '\t.\0' \ | sed 's/\t\t/_/g' \ | tr -c -d '[:print:]' \ | sed -r -n 's/.*Version[^0-9]*(2+\.7+(\.13?)?).*/\1/p' 

The overall command is then wrestool —extract —raw —type=version inputfile.exe | tr ‘\0, ‘ ‘\t.\0’ | sed ‘s/\t\t/_/g’ | tr -c -d ‘[:print:]’ | sed -r -n ‘s/.*Version[^0-9]*(3+\.5+(\.61?)?).*/\1/p’ .

+1 wrestool is provided by the icoutil package which is available as a standard Debian package since way back.

As an alternative to using tr and sed to parse the output from @mechanical-snail ‘s solution, here is a GNU strings and GNU grep version:

$ wrestool --extract --raw --type=version putty.exe | strings -el | grep Version -A 1 FileVersion Release 0.65 ProductVersion Release 0.65 

Another alternative is a recent version of exiftool by Phil Harvey (it is based on perl, easy to install with sudo apt-get install libimage-exiftool-perl , also available for Mac and Windows). It has lots of formatting options.

# Example with exiftool 10.47 $ exiftool -FileVersion -ProductVersion putty.exe File Version : Release 0.67 Product Version : Release 0.67 

I just download the source code and build it locally. Download the tar.gz file from the website (The «Download Version xx.yy» link at the top of owl.phy.queensu.ca/~phil/exiftool), extract the files and see the INSTALLATION section of the README file for how to build it using perl and then installing it to /usr/local/bin

If you install the gnome-exe-thumbnailer package, you can simply look at the version number in nautilus , caja , nemo and thunar .

Читайте также:  Установить anaconda linux mint

The code to do this manually is available in /usr/bin/gnome-exe-thumbnailer.sh

@Scott.. Thanks. it works.. the relevant code is very simple to use in another script. I assume that what you mean by «you can simply look at the version number in nautilus», is that that the version number appears grafted into the .exe’s icon in Nautilus.. an interesting idea.. Personally, I rarely use the icon-view, but the code snippet is great for me..

For the sake of completeness, here’s something you can do if you can’t install new applications, but you do have p7zip and Vim:

  1. Extract the metadata with 7z x whatever.exe .rsrc/VERSION/1
  2. Open the resulting .rsrc/VERSION/1 file in Vim
  3. Type :e ++enc=utf16le at the Vim command line to request that the file’s contents be reinterpreted as little-endian UTF-16.

The method mentioned in @ssokolow’s answer does not work exactly for me.

However, the 7z ‘s (version 16.02 or above) «list» option will list that information already.

So, I defined the following Bash function:

You can put this function in your .bash_aliases file and use like this:

I just found out myself how to create a nice python dict with the information (I was looking around myself and wound up here for some reason) and would like to present my method here:
Github Gists — spookyahell/exe2version_info.py

'''Licensed under the MIT License :)''' import pefile import pprint pe = pefile.PE('example.exe') string_version_info = <> for fileinfo in pe.FileInfo[0]: if fileinfo.Key.decode() == 'StringFileInfo': for st in fileinfo.StringTable: for entry in st.entries.items(): string_version_info[entry[0].decode()] = entry[1].decode() pprint.pprint(string_version_info) 

I am licensing it under the MIT License. may anybody who feels the need to create useful scripts or other things with it.

And see Github Gists — spookyahell/peinfo.py for an example implementation of this method in another script.

Источник

Extracting version number from a filename

where XXX.XX is a version number and I need the version number only. How to do it in linux? I have this code:

#!/bin/bash current_ver=$(find /mnt/builds/current -name '*.run'|awk -F/ '') 

So this gives me just the name of the file correctly (minus the location, which I don’t want). But how do I only get the XXX.XX version number into a variable such as $version

4 Answers 4

You actually don’t need any external tools. You can do this entirely within bash, by chopping variables according to patterns..

[ghoti@pc ~]$ name="installer-x86_64-XXX.XX-diagnostic.run" [ghoti@pc ~]$ vers=$; echo $vers x86_64-XXX.XX-diagnostic.run [ghoti@pc ~]$ vers=$; echo $vers XXX.XX-diagnostic.run [ghoti@pc ~]$ vers=$; echo $vers XXX.XX [ghoti@pc ~]$ 

Or if you prefer, you can chop off pieces right-hand-side first:

[ghoti@pc ~]$ name="installer-x86_64-XXX.XX-diagnostic.run" [ghoti@pc ~]$ vers=$; echo $vers installer-x86_64-XXX.XX [ghoti@pc ~]$ vers=$; echo $vers XXX.XX [ghoti@pc ~]$ 

Of course, if you want to use external tools, that’s fine too.

[ghoti@pc ~]$ name="installer-x86_64-XXX.XX-diagnostic.run" [ghoti@pc ~]$ vers=$(awk -F- '' <<<"$name") [ghoti@pc ~]$ echo $vers XXX.XX [ghoti@pc ~]$ vers=$(sed -ne 's/-[^-]*$//;s/.*-//;p' <<<"$name") [ghoti@pc ~]$ echo $vers XXX.XX [ghoti@pc ~]$ vers=$(cut -d- -f3 <<<"$name") [ghoti@pc ~]$ echo $vers XXX.XX [ghoti@pc ~]$ 

Источник

Читайте также:  Linux hosts with port

Как узнать версию программы в Linux

book24 не заставляйте меня думать

sed (GNU sed) 4.7 Packaged by Debian Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Jay Fenlason, Tom Lord, Ken Pizzini, Paolo Bonzini, Jim Meyering, and Assaf Gordon. GNU sed home page: . General help using GNU software: . E-mail bug reports to: .

В Debian , Ubuntu и других производных Debian можно выполнить команду

Например, чтобы узнать версию sed нужно выполнить

Package: sed Essential: yes Priority: required Section: utils Installed-Size: 336 Origin: Ubuntu Maintainer: Ubuntu Developers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Architecture: amd64 Multi-Arch: foreign Version: 4.7-1 Pre-Depends: libacl1 (>= 2.2.51-8), libc6 (>= 2.14), libselinux1 (>= 1.32) Filename: pool/main/s/sed/sed_4.7-1_amd64.deb Size: 189668 MD5sum: 2e2c9a0370c20a2a1921572f250db43e Description: GNU stream editor for filtering/transforming text Original-Maintainer: Clint Adams SHA1: a8106de20fa00fc7f97a45d18ec411512cc64293 SHA256: a5428ddec609149eb6086cec20bf14a0300972a191eb0cc010e7f1c7f17186f4 Homepage: https://www.gnu.org/software/sed/ Task: minimal Description-md5: 2ed71305ee7a49ce4438c58140980d2f

Команда dpkg -p, впрочем как и флаги --version, -V работает не со всеми программами

Например, если вы выполните

Скорее всего получите сообщение

dpkg-query: package 'virtualbox' is not available

Команда virtualbox --version просто запустит Virtualbox

Чтобы определить версию Virtualbox выполните

Oracle VM VirtualBox VM Selector v6.1.10_Ubuntu (C) 2005-2020 Oracle Corporation All rights reserved. No special options. If you are looking for --startvm and related options, you need to use VirtualBoxVM.

  • Поиск по сайту
  • aofeed - Telegram канал чтобы следить за выходом новых статей
  • aofeedchat - задать вопрос в Телеграм-группе

Источник

Viewing Linux Library / Executable version info

The version info in not explicitly stored in an ELF file. What you have in there is the name of the library, the soname , which includes the major version. The full version is usually stored as a part of the library file name.

If you have library, say libtest.so , then you usually have:

  • libtest.so.1.0.1 - The library file itself, containing the full version
  • libtest.so.1 - Symlink to libtest.so.1.0.1 , having the same name as soname
  • libtest.so - Symlink to libtest.so.1 used for linking.

In the library file libtest.so.1.0.1 , there will be an entry called SONAME in dynamic section, that will say this library is called libtest.so.1 . When you link a program against this library, the linked program will store the soname of the library under NEEDED entry in the dynamic section.

Читайте также:  Ft232r usb uart драйвер linux

If you want to verify, what exactly is in which ELF file, you can try to run:

where elffile can be either an library of an executable.

If you simply want to get the library version, you can play with:

readelf -d /path/to/library.so |grep SONAME 

AFAIK, there's no such info (at least not by default) in executable files.

Or you can rely on the program itself or your packaging system, as Rahul Patil wrote.

nice info, it's new to me never used readelf, if you don't mind , may i ask you where & why use readelf

Readelf (and similar tools) is useful, when you want to look inside an elf file :). I use it mostly when programming to look up symbols in libraries (when something doesn't work), or when there's some problem with a library. (man readelf)

You can use ldconfig -v | grep libraryname , also command has option command -V or binaryfile --version

test@ubuntukrb12:~# ls --version ls (GNU coreutils) 8.13 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. 

also you can use yum or aptitude based on distro you are using eg.

in RHEL5/CENTOS5/Fedora you can use yum info packagename or if it installed then use rpm --version packagename

 [root@ldap1 ~]# yum info bind97 Loaded plugins: downloadonly, fastestmirror, security Loading mirror speeds from cached hostfile * base: mirrors.sin3.sg.voxel.net * epel: mirror.imt-systems.com * extras: mirrors.sin3.sg.voxel.net * updates: mirrors.sin3.sg.voxel.net Installed Packages Name : bind97 Arch : i386 Epoch : 32 Version : 9.7.0 Release : 10.P2.el5_8.4 Size : 6.3 M Repo : installed Summary : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server URL : http://www.isc.org/products/BIND/ License : ISC Description: BIND (Berkeley Internet Name Domain) is an implementation of the DNS : (Domain Name System) protocols. BIND includes a DNS server (named), : which resolves host names to IP addresses; a resolver library : (routines for applications to use when interfacing with DNS); and : tools for verifying that the DNS server is operating properly. 

In Ubuntu You can use aptitude show pkgname or dpkg --version pkgname

root@ubuntukrb12:~# aptitude show bind9utils Package: bind9utils State: installed Automatically installed: yes Version: 1:9.8.1.dfsg.P1-4ubuntu0.4 Priority: optional Section: net Maintainer: Ubuntu Developers Architecture: amd64 Uncompressed Size: 306 k Depends: libbind9-80, libc6 (>= 2.14), libdns81, libisc83, libisccc80, libisccfg82 Conflicts: bind9utils Replaces: bind9 ( 

Источник

Оцените статью
Adblock
detector