Ubuntu系统三种安装软件包的方法(apt/aptitude/deb命令)和常用的镜像源
阅读摘要
-
- Ubuntu安装软件包
- 镜像源
- Ubuntu apt-get命令安装软件包时遇到的问题
-
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 http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse 清华大学开源软件镜像站
-
#默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse 中科大源
-
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse 网易
-
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse 遇到的问题
-
Ubuntu apt-get命令安装软件包时遇到的问题 Question1 root@soft3-94:~# apt-get install libssl-dev Reading package lists… Done Building dependency tree Reading state information… Done You 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 installed alsa-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 installed E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution). Question2 root@soft3-94:/var/lib/dpkg# apt-get install update Reading package lists… Done Building dependency tree Reading state information… Done E: Unable to locate package update root@soft3-94:/var/lib/dpkg# apt-get install libssl-dev Reading package lists… Done Building dependency tree Reading state information… Done You 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 installed alsa-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 installed E: Unmet dependencies. Try ‘apt-get -f install’ with no packages (or specify a solution). Question3 root@soft3-94:/var/lib/dpkg# apt-get -f install Reading package lists… Done Building dependency tree Reading state information… Done Correcting dependencies… Done The following extra packages will be installed: kmod libglib2.0-0 libglib2.0-bin libkmod2 The following packages will be upgraded: kmod libglib2.0-0 libglib2.0-bin libkmod2 4 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] y perl: 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 directory dpkg-deb: error: archive ‘/var/cache/apt/archives/libkmod2_24-1ubuntu3.4_amd64.deb’ has premature member ‘control.tar.xz’ before ‘control.tar.gz’, giving up dpkg: error processing archive /var/cache/apt/archives/libkmod2_24-1ubuntu3.4_amd64.deb (–unpack): subprocess dpkg-deb --control returned error exit status 2 E: 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版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/ITerated/article/details/106947459
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix