首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >查看Linux库/可执行版本信息

查看Linux库/可执行版本信息
EN

Unix & Linux用户
提问于 2012-12-19 06:32:49
回答 4查看 235.1K关注 0票数 68

在Windows中,EXE和DLL具有版本信息,至少包括以下字段:

  1. 文件版本
  2. 产品版本
  3. 内部名称
  4. 产品名称
  5. 版权

在Linux库/可执行文件中:

  • 哪些字段存在?
  • 如何查看这些信息?
  • 要阅读哪些工具/库?
EN

回答 4

Unix & Linux用户

发布于 2012-12-19 07:32:44

未显式存储在精灵文件中的版本信息。您在其中拥有的是库的名称,soname,其中包括主要版本。完整版本通常作为库文件名的一部分存储。

如果您有库,比如libtest.so,那么通常有:

  • libtest.so.1.0.1 -库文件本身,包含完整的版本
  • libtest.so.1 -到libtest.so.1.0.1的符号链接,其名称与soname相同
  • libtest.so -用于链接的到libtest.so.1的符号链接。

在库文件libtest.so.1.0.1中,动态部分将有一个名为SONAME的条目,即这个库称为libtest.so.1。当您将程序链接到此库时,链接的程序将将库的soname存储在动态部分的NEEDED条目下。

如果要验证ELF文件到底在哪个文件中,可以尝试运行:

代码语言:javascript
复制
readelf -a -W elffile

其中elffile可以是一个可执行文件的库。

如果您只想获得库版本,可以使用:

代码语言:javascript
复制
readelf -d  /path/to/library.so |grep SONAME

AFAIK,在可执行文件中没有这样的信息(至少在默认情况下不是这样)。

或者你可以依靠程序本身或者你的打包系统,就像Rahul Patil所写的那样。

票数 60
EN

Unix & Linux用户

发布于 2012-12-19 07:11:42

您可以使用ldconfig -v | grep libraryname,也可以命令有选项command -Vbinaryfile --version

例子:

代码语言:javascript
复制
test@ubuntukrb12:~# ls --version
ls (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

另外,你也可以根据你正在使用的发行版来使用yum或智能。

在RHEL5 5/CENTOS5 5/Fedora中,您可以使用yum info packagename,或者如果安装了它,则使用rpm --version packagename

代码语言:javascript
复制
 [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.

在Ubuntu中,您可以使用aptitude show pkgnamedpkg --version pkgname

代码语言:javascript
复制
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 <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Uncompressed Size: 306 k
Depends: libbind9-80, libc6 (>= 2.14), libdns81, libisc83, libisccc80, libisccfg82
Conflicts: bind9utils
Replaces: bind9 (<= 1:9.5.0~b2-1), bind9 (<= 1:9.5.0~b2-1)
Description: Utilities for BIND
 This package provides various utilities that are useful for maintaining a working BIND installation.
票数 20
EN

Unix & Linux用户

发布于 2019-02-22 15:24:35

运行此程序以获取版本信息- strings libssl.so.1.0.0 | grep "1\.0"

代码语言:javascript
复制
SSLv3 part of OpenSSL 1.0.2p-fips  14 Aug 2018
OpenSSL 1.0.2p-fips  14 Aug 2018
TLSv1 part of OpenSSL 1.0.2p-fips  14 Aug 2018
DTLSv1 part of OpenSSL 1.0.2p-fips  14 Aug 2018
票数 10
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/58846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档