Debian Minimal如何安装与卸载软件
导读:Debian Minimal 安装与卸载软件指南 一 基础准备 更新索引与系统:先执行 sudo apt update,必要时执行 sudo apt full-upgrade,保持软件包索引与系统为最新状态。 工具选择:日常使用 apt(...
Debian Minimal 安装与卸载软件指南
一 基础准备
- 更新索引与系统:先执行 sudo apt update,必要时执行 sudo apt full-upgrade,保持软件包索引与系统为最新状态。
- 工具选择:日常使用 apt(更友好的命令行前端);脚本或兼容性需求可用 apt-get;底层处理 .deb 文件用 dpkg。
- 最小化系统建议:若提示缺少命令,先安装常用工具,例如 sudo apt install --no-install-recommends ca-certificates curl wget gnupg lsb-release。
- 软件源配置:确保 /etc/apt/sources.list 包含合适的 main 组件(必要时可添加 contrib non-free),保存后执行 sudo apt update。
二 使用 APT 安装与卸载
- 安装软件包:
- 安装单个或多个包:sudo apt install < 包名1> [< 包名2> …]
- 重新安装:sudo apt install --reinstall < 包名>
- 仅下载不安装:sudo apt-get download < 包名>
- 模拟安装(检查依赖与冲突):sudo apt-get install --simulate < 包名>
- 卸载软件包:
- 保留配置卸载:sudo apt remove < 包名>
- 连同配置彻底卸载:sudo apt purge < 包名>
- 清理不再需要的依赖:sudo apt autoremove
- 常用查询与维护:
- 搜索包:apt search < 关键词>
- 查看包信息:apt show < 包名>
- 列出已安装包:apt list --installed
- 查看可用版本策略:apt-cache policy < 包名>
- 防止/取消防止升级:sudo apt-mark hold < 包名> / sudo apt-mark unhold < 包名>
三 使用 DPKG 处理本地 .deb 包
- 安装本地包:下载 .deb 后执行 sudo dpkg -i < 文件.deb> 。
- 卸载:
- 保留配置:sudo dpkg -r < 包名>
- 彻底清除:sudo dpkg --purge < 包名>
- 依赖问题处理:dpkg 不自动解决依赖,若安装时报缺依赖,执行 sudo apt-get -f install 自动补齐依赖或修复破损状态。
- 其他实用:查看包内容 dpkg --contents < 文件.deb> 。
四 进阶与常见问题
- 添加第三方仓库:
- 添加仓库源:sudo add-apt-repository “”
- 更新索引:sudo apt update
- 安装密钥(若需要):使用 curl/wget 下载并导入 GPG 公钥,再更新索引。
- 系统级升级:执行 sudo apt full-upgrade(必要时配合 sudo apt-get dist-upgrade)。
- 锁文件与并发冲突:若出现 Could not get lock,确认无其他 apt/dpkg 进程后,可清理锁与缓存:sudo killall apt apt-get,随后 sudo apt clean。
- 源码编译安装(备选):下载源码后依次执行 ./configure、make,安装用 sudo make install;卸载依赖软件是否提供 make uninstall,如无则需手动清理。
- 通用建议:优先使用 apt 从仓库安装;dpkg 适合离线 .deb;源码安装更灵活但更依赖手动维护。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Debian Minimal如何安装与卸载软件
本文地址: https://pptw.com/jishu/764610.html
