700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Ubuntu系统三种安装软件包的方法(apt/aptitude/deb命令)和常用的镜像源

Ubuntu系统三种安装软件包的方法(apt/aptitude/deb命令)和常用的镜像源

时间:2019-01-15 21:23:18

相关推荐

Ubuntu系统三种安装软件包的方法(apt/aptitude/deb命令)和常用的镜像源

阅读摘要

Ubuntu安装软件包 apt 安装aptitude安装使用Deb包安装镜像源 阿里云清华大学开源软件镜像站中科大源网易Ubuntu apt-get命令安装软件包时遇到的问题 Question1Question2Question3解决方案

Ubuntu安装软件包

apt 安装

sudo apt search package #搜索包 sudo apt show package #获取包的相关信息,如说明、大小、版本等 sudo apt depends package #了解使用依赖 sudo apt rdepends package #查看该包被哪些包依赖 sudo apt-cache pkgnames #执行pkgnames子命令列出当前所有可用的软件包 sudo apt policy package #使用policy命令显示软件包的安装状态和版本信息。sudo apt install package #安装包 sudo apt install package=version #安装指定版本的包 sudo apt install package --reinstall #重新安装包 sudo apt -f install #修复安装, "-f = --fix-missing" sudo apt remove package #删除包sudo apt purge package #删除包,包括删除配置文件等sudo apt autoremove #自动卸载所有未使用的软件包sudo apt source package #下载该包的源代码 sudo apt update #更新apt软件源信息 sudo apt upgrade #更新已安装的包sudo apt full-upgrade #在升级软件包时自动处理依赖关系 sudo apt dist-upgrade #升级系统 sudo apt dselect-upgrade #使用dselect升级 sudo apt build-dep package #安装相关的编译环境 sudo apt clean && sudo apt autoclean #清理无用的包sudo apt clean #清理已下载的软件包,实际上是清楚/var/cache/apt/archives目录中的软件包sudo apt autoclean #删除已经卸载的软件包备份 sudo apt-get check #检查是否有损坏的依赖

例子:

root@gegewu1:/etc/zabbix# sudo apt purge zabbix-server-mysql

正在读取软件包列表... 完成

正在分析软件包的依赖关系树

正在读取状态信息... 完成

下列软件包是自动安装的并且现在不需要了:

libevent-2.1-6 libmysqlclient20

使用'sudo apt autoremove'来卸载它(它们)。

下列软件包将被【卸载】:

zabbix-server-mysql*

升级了 0 个软件包,新安装了 0 个软件包,要卸载 1 个软件包,有 13 个软件包未被升级。

解压缩后会消耗 0 B 的额外空间。

您希望继续执行吗? [Y/n] y

apt和apt-get的区别:

随着 apt install package 命令的使用频率和普遍性逐步超过 apt-get install package,越来越多的其它 Linux 发行版也开始遵循 Ubuntu 的脚步,开始鼓励用户使用 apt 而不是 apt-get。

详情请跳转至:apt 和 apt-get的区别(建议使用apt)

aptitude安装

sudo apt install aptitude # 安装

sudo aptitude update更新可用的包列表sudo aptitude upgrade 升级可用的包sudo aptitude dist-upgrade 将系统升级到新的发行版sudo aptitude install pkgname 安装包sudo aptitude remove pkgname删除包sudo aptitude purge pkgname 删除包及其配置文件sudo aptitude search string 搜索包sudo aptitude show pkgname 显示包的详细信息sudo aptitude clean 删除下载的包文件sudo aptitude autoclean 仅删除过期的包文件

使用Deb包安装

sudo dpkg -i <package.deb> #安装包sudo dpkg -r <package.deb> #删除包sudo dpkg -p <package.deb> #彻底删除包(包括配置文件)dpkg -l #列出当前已安装的包

镜像源

阿里云

deb /ubuntu/ bionic main restricted universe multiversedeb /ubuntu/ bionic-security main restricted universe multiversedeb /ubuntu/ bionic-updates main restricted universe multiversedeb /ubuntu/ bionic-proposed main restricted universe multiversedeb /ubuntu/ bionic-backports main restricted universe multiversedeb-src /ubuntu/ bionic main restricted universe multiversedeb-src /ubuntu/ bionic-security main restricted universe multiversedeb-src /ubuntu/ bionic-updates main restricted universe multiversedeb-src /ubuntu/ bionic-proposed main restricted universe multiversedeb-src /ubuntu/ bionic-backports main restricted universe multiverse

清华大学开源软件镜像站

#默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释deb https://mirrors.tuna./ubuntu/ bionic main restricted universe multiverse# deb-src https://mirrors.tuna./ubuntu/ bionic main restricted universe multiversedeb https://mirrors.tuna./ubuntu/ bionic-updates main restricted universe multiverse# deb-src https://mirrors.tuna./ubuntu/ bionic-updates main restricted universe multiversedeb https://mirrors.tuna./ubuntu/ bionic-backports main restricted universe multiverse# deb-src https://mirrors.tuna./ubuntu/ bionic-backports main restricted universe multiversedeb https://mirrors.tuna./ubuntu/ bionic-security main restricted universe multiverse# deb-src https://mirrors.tuna./ubuntu/ bionic-security main restricted universe multiverse# 预发布软件源,不建议启用# deb https://mirrors.tuna./ubuntu/ bionic-proposed main restricted universe multiverse# deb-src https://mirrors.tuna./ubuntu/ bionic-proposed main restricted universe multiverse

中科大源

deb https://mirrors./ubuntu/ bionic main restricted universe multiversedeb-src https://mirrors./ubuntu/ bionic main restricted universe multiversedeb https://mirrors./ubuntu/ bionic-updates main restricted universe multiversedeb-src https://mirrors./ubuntu/ bionic-updates main restricted universe multiversedeb https://mirrors./ubuntu/ bionic-backports main restricted universe multiversedeb-src https://mirrors./ubuntu/ bionic-backports main restricted universe multiversedeb https://mirrors./ubuntu/ bionic-security main restricted universe multiversedeb-src https://mirrors./ubuntu/ bionic-security main restricted universe multiversedeb https://mirrors./ubuntu/ bionic-proposed main restricted universe multiversedeb-src https://mirrors./ubuntu/ bionic-proposed main restricted universe multiverse

网易

deb /ubuntu/ trusty main restricted universe multiversedeb /ubuntu/ trusty-security main restricted universe multiversedeb /ubuntu/ trusty-updates main restricted universe multiversedeb /ubuntu/ trusty-proposed main restricted universe multiversedeb /ubuntu/ trusty-backports main restricted universe multiversedeb-src /ubuntu/ trusty main restricted universe multiversedeb-src /ubuntu/ trusty-security main restricted universe multiversedeb-src /ubuntu/ trusty-updates main restricted universe multiversedeb-src /ubuntu/ trusty-proposed main restricted universe multiversedeb-src /ubuntu/ trusty-backports main restricted universe multiverse

遇到的问题

Ubuntu apt-get命令安装软件包时遇到的问题Question1root@soft3-94:~# apt-get install libssl-devReading package lists… DoneBuilding dependency treeReading state information… DoneYou might want to run ‘apt-get -f install’ to correct these:The following packages have unmet dependencies:activity-log-manager : Depends: libglib2.0-0 (>= 2.43.2) but 2.40.0-2 is to be installedalsa-base : Depends: kmod (>= 17-1)libssl-dev : Depends: libssl1.1 (= 1.1.1-1ubuntu2.1~18.04.6) but it is not going to be installedE: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).Question2root@soft3-94:/var/lib/dpkg# apt-get install updateReading package lists… DoneBuilding dependency treeReading state information… DoneE: Unable to locate package updateroot@soft3-94:/var/lib/dpkg# apt-get install libssl-devReading package lists… DoneBuilding dependency treeReading state information… DoneYou might want to run ‘apt-get -f install’ to correct these:The following packages have unmet dependencies:activity-log-manager : Depends: libglib2.0-0 (>= 2.43.2) but 2.40.0-2 is to be installedalsa-base : Depends: kmod (>= 17-1)libssl-dev : Depends: libssl1.1 (= 1.1.1-1ubuntu2.1~18.04.6) but it is not going to be installedE: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution).Question3root@soft3-94:/var/lib/dpkg# apt-get -f installReading package lists… DoneBuilding dependency treeReading state information… DoneCorrecting dependencies… DoneThe following extra packages will be installed:kmod libglib2.0-0 libglib2.0-bin libkmod2The following packages will be upgraded:kmod libglib2.0-0 libglib2.0-bin libkmod24 upgraded, 0 newly installed, 0 to remove and 1422 not upgraded.3 not fully installed or removed.Need to get 0 B/1368 kB of archives.After this operation, 2181 kB disk space will be freed.Do you want to continue? [Y/n] yperl: warning: Setting locale failed.perl: warning: Please check that your locale settings:LANGUAGE = (unset),LC_ALL = (unset),LC_PAPER = “zh_CN.UTF-8”,LC_ADDRESS = “zh_CN.UTF-8”,LC_MONETARY = “zh_CN.UTF-8”,LC_NUMERIC = “zh_CN.UTF-8”,LC_TELEPHONE = “zh_CN.UTF-8”,LC_IDENTIFICATION = “zh_CN.UTF-8”,LC_MEASUREMENT = “zh_CN.UTF-8”,LC_TIME = “zh_CN.UTF-8”,LC_NAME = “zh_CN.UTF-8”,LANG = “en_US.UTF-8”are supported and installed on your system.perl: warning: Falling back to the standard locale (“C”).locale: Cannot set LC_ALL to default locale: No such file or directorydpkg-deb: error: archive ‘/var/cache/apt/archives/libkmod2_24-1ubuntu3.4_amd64.deb’ has premature member ‘control.tar.xz’ before ‘control.tar.gz’, giving updpkg: error processing archive /var/cache/apt/archives/libkmod2_24-1ubuntu3.4_amd64.deb (–unpack):subprocess dpkg-deb --control returned error exit status 2E: Sub-process /usr/bin/dpkg returned an error code (1)E: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。解决方案各种依赖导致的安装失败,这个可能就是源的问题,替换镜像源链接即可。解决方案:(1)备份原镜像源文件:mv /etc/apt/sources.list /etc/apt/sources.list.bak;(2)创建编辑/etc/apt/sources.list新文件: sudo vim /etc/apt/sources.list ;(3)选择上面任一镜像源地址粘贴,保存退出;(4)修改后使用sudo apt-get update更新缓存,sudo apt-get upgrade升级包。如果有报错的及时删除后再更新就行了。————————————————版权声明:本文为CSDN博主「桑榆非晚晚」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:/ITerated/article/details/106947459

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。