一、通过apt-get安装指定版本

apt-get install <<package name>>=<<version>>

二、查询指定软件有多少个版本

说明:在Linux用这个查询并不能完全的把所有版本都列举出来,因为每个版本都与系统版本和CPU架构有关,比如一个软件支持Ubuntu系统的16.04的CPU架构为amd64的版本只有1.0和1.2,其余都不支持,所以列举时就只有两款。

列举版本列表:

0、通过网站搜索:

https://packages.ubuntu.com/

1、

apt-cache madison <<package name>>

将列出所有来源的版本。如下输出所示:

apt-cache madison vim
vim | 2:7.3.547-1 | http://debian.mirrors.tds.net/debian/ unstable/main amd64 Packages
vim | 2:7.3.429-2 | http://debian.mirrors.tds.net/debian/ testing/main amd64 Packages
vim | 2:7.3.429-2 | http://http.us.debian.org/debian/ testing/main amd64 Packages
vim | 2:7.3.429-2 | http://debian.mirrors.tds.net/debian/ testing/main Sources
vim | 2:7.3.547-1 | http://debian.mirrors.tds.net/debian/ unstable/main Sources

madison是一个apt-cache子命令,可以通过man apt-cache查询更多用法。

2、

apt-cache policy <<package name>>

将列出所有来源的版本。信息会比上面详细一点,如下输出所示:

apt-cache policy gdb
gdb:
Installed: 7.7.1-0ubuntu5~14.04.2
Candidate: 7.7.1-0ubuntu5~14.04.2
Version table:
*** 7.7.1-0ubuntu5~14.04.2 0
500 http://fr.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
100 /var/lib/dpkg/status
7.7-0ubuntu3 0
500 http://fr.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

policy是一个apt-cache子命令,可以通过man apt-cache查询更多用法。

3、

apt-cache showpkg <<package name>>

4、

apt-get install -s <<package-name>>

说明:这个命令只是模拟安装时会安装哪些软件列表,但不会例举出每个软件有多少个版本

5、

aptitude versions <<package name>>

参考:https://manpages.debian.org/unstable/aptitude/aptitude.8.en.html

6、

apt-show-versions -a <<package name>>

说明:列举出所有版本,且能查看是否已经安装。还可以通过apt-show-versions -u <<package name>>来查询是否有升级版本。

参考:http://manpages.ubuntu.com/manpages/trusty/man1/apt-show-versions.1p.html

7、

whohas -d Debian,Ubuntu <<package name>> | tr -s ' ' '\t' | cut -f 1-3 | column -t

8、

rmadison -u debian,ubuntu,bpo <<package name>> | cut -d "|" -f 1-3

单个详情:

1、

apt-cache show <<package name>>

说明:查询指定包的详情,不管是否已经安装。

2、

dpkg -l <<package name>>

说明:效果和上面基本一致,但是结果是列表详情展示,会提示是否已经删除了之后还有依赖包没有删除等。

3、

dpkg -s <<package name>>

说明:必须是安装的包才能显示详情。

4、

dpkg-query -s <<package name>>

说明:同上,效果一致。

使用技巧:

1、可以在查询后面带上一些参数来实现筛选

apt-cache show package | grep Version
apt-show-versions | more

参考:

http://wiki.ubuntu.org.cn/Apt%E5%92%8Cdpkg%E5%BF%AB%E9%80%9F%E5%8F%82%E8%80%83(apt-get常用语法)

https://superuser.com/questions/393681/how-to-find-out-which-versions-of-a-package-can-i-install-on-apt

https://stackoverflow.com/questions/18885820/how-to-check-the-version-before-install-packages-using-apt-get

https://askubuntu.com/questions/340530/how-can-i-check-the-available-version-of-a-package-in-the-repositories

https://serverfault.com/questions/108080/ubuntu-debian-show-list-of-available-versions-of-a-specific-package

https://askubuntu.com/questions/473886/list-all-versions-of-a-package

https://askubuntu.com/questions/447/how-can-i-see-all-versions-of-a-package-that-are-available-in-the-archive

http://www.wkii.org/view-package-version-ubuntu.html

Ubuntu通过apt-get安装指定版本和查询指定软件有多少个版本的更多相关文章

  1. ubuntu采用apt方式安装多个版本php-fpm

    适用系统:Ubuntu 16.04 LTS / Ubuntu 14.04 LTS 安装 PHP Ondřej Surý 的 PHP PPA 为 Ubuntu 16.04/14.04 提供了 PHP7. ...

  2. ubuntu 用 apt get 安装某个包的某个版本

    1.首先用如下命令查询你的机器安装了哪些版本: dpkg -l 'apache2*' 2.然后用如下命令查询远程库存在哪些版本: apt-cache madison "libqt5gui5& ...

  3. Ubuntu下apt方式安装与更新Git

    本人使用的系统 Ubuntu 18.04.1 ,使用apt安装Git: sudo apt insatll git 安装后发现不是最新的版本,更新方法: sudo add-apt-repository ...

  4. ubuntu - 14.04,安装VirtualBox 5.0(虚拟机软件)!

    VirtualBox是一款免费.开源的虚拟机软件,可以运行在多种操作系统上,真的是一款值得我们使用的虚拟机软件! 官方网址:https://www.virtualbox.org/ ubuntu14.0 ...

  5. Ubuntu通过apt-get安装指定版本和查询软件源有多少个版本

    一.通过apt-get安装指定版本 apt-get install <<package name>>=<<version>> 二.查询指定软件有多少个版 ...

  6. Ubuntu 系统下如何安装pip3工具

    一.[导读]Ubuntu 系统内置了 Python2 和 Python3 两个版本的开发环境,却没有内置相应的 pip3 管理工具,本文将介绍如何在Ubuntu下如何快速安装 pip3 工具,并升级到 ...

  7. Ubuntu系统Apache Maven安装

    操作系统:Linux x64 / Ubuntu 14.04 Apache Maven版本:3.3.9 建议预先搭建Java开发环境:详见上一篇<Linux Ubuntu系统下Java开发环境搭建 ...

  8. Ubuntu配置apt安装源为清华源[含自动配置脚本]

    Ubuntu配置apt安装源为清华源[含自动配置脚本] 一.备份原配置文件 Ubuntu 的软件源配置文件是/etc/apt/sources.list.将系统自带的该文件做个备份,以防万一. sudo ...

  9. Ubuntu和centos离线安装软件包(apt和yum)

    linux安装软件包要解决包依赖问题,不能简单安装包本身. 离线安装基本思想都是先在一台设备上安装下载所有依赖包,然后拷贝所有依赖包到新设备上安装. Ubuntu下apt离线安装包 执行apt upd ...

随机推荐

  1. Python处理JSON(转)

    参考: 概念 序列化(Serialization):将对象的状态信息转换为可以存储或可以通过网络传输的过程,传输的格式可以是JSON.XML等.反序列化就是从存储区域(JSON,XML)读取反序列化对 ...

  2. 教程 | 一文入门Python数据分析库Pandas

    首先要给那些不熟悉 Pandas 的人简单介绍一下,Pandas 是 Python 生态系统中最流行的数据分析库.它能够完成许多任务,包括: 读/写不同格式的数据 选择数据的子集 跨行/列计算 寻找并 ...

  3. hdu1695 容斥原理 莫比乌斯反演

    给定两个数b,d,问[1,b]和[1,d]区间上有多少对互质的数.(x,y)和(y,x)算一个. 对于[1,b]部分,用欧拉函数直接求.对于大于b的部分,求n在[1,b]上有多少个互质的数,用容斥原理 ...

  4. 【LeetCode】42. Trapping Rain Water

    Trapping Rain Water Given n non-negative integers representing an elevation map where the width of e ...

  5. java程序员学习路线图 java程序员进阶路线

  6. 具体解释java中的volatilekeyword

    一.为什么要有volatilekeyword 预计非常多java刚開始学习的人都被volatile这个keyword迷惑过.尽管网上有非常多讨论volatile的文章,但它们有的过于讲述底层原理,而没 ...

  7. 【服务器防护】linux 如何查看防火墙是否开启

    service iptables status可以查看到iptables服务的当前状态.但是即使服务运行了,防火墙也不一定起作用,你还得看防火墙规则的设置 iptables -L在此说一下关于启动和关 ...

  8. Mac 开发者设置强迫症

    Latest commit 2461787 on Mar 1 原文链接 强迫症的 Mac 设置指南 如何配置一个高效的 Mac 工作环境 English Version Table of Conten ...

  9. ThinkPHP CURD方法中field方法详解

    导读:ThinkPHP CURD方法的field方法属于模型的连贯操作方法之一,主要目的是标识要返回或者操作的字段,可以用于查询和写入操作. 1.用于查询在查询操作中field方法是使用最频繁的.$M ...

  10. [sh]sed 4个功能

    [root@lanny test]# cat test.txt test liyao lanny 经典博文: http://oldboy.blog.51cto.com/2561410/949365 h ...