ubuntu虚拟机中如何卸载软件
小樊
39
2025-11-22 19:21:31
Ubuntu 虚拟机卸载软件的常用方法
一 命令行卸载 APT 系列
- 查找包名
- 列出并过滤:dpkg -l | grep 关键词
- 查看已选择安装列表:dpkg --get-selections | grep 关键词
- 卸载命令
- 仅移除程序本体:sudo apt remove 包名(或 sudo apt-get remove 包名)
- 连同配置文件一起清除:sudo apt purge 包名(或 sudo apt-get --purge remove 包名)
- 清理无用的依赖:sudo apt autoremove
- 说明:apt 是 apt-get 的更友好封装,语法更一致,二者在卸载场景可互换使用。
二 命令行卸载 DPKG 系列
- 仅移除:sudo dpkg -r 包名
- 清除(含配置):sudo dpkg -P 包名
- 适用场景:离线 .deb 安装或 apt 不可用时可直接用 dpkg 管理。
三 图形界面卸载
- 打开 Ubuntu 软件中心,搜索目标应用,进入应用详情页选择卸载。
- 如使用 GNOME 软件(部分版本),也可在“已安装”页找到应用后点击移除。
四 常见场景示例
- 卸载 Firefox(示例)
- 查询包名:dpkg --get-selections | grep firefox
- 连同配置清除:sudo apt purge firefox firefox-locale-en
- 清理依赖:sudo apt autoremove
- 卸载 网易云音乐(示例)
- 查询包名:dpkg -l | grep netease-cloud-music
- 移除程序:sudo apt remove netease-cloud-music
- 如需清理残留配置:rm -r ~/.config/netease-cloud-music
- 精简预装应用(示例)
- 移除 LibreOffice 公共文件:sudo apt-get remove libreoffice-common
- 移除 Amazon 链接:sudo apt-get remove unity-webapps-common
- 移除 Thunderbird:sudo apt-get purge thunderbird*
- 移除 Rhythmbox:sudo apt-get -y purge rhythmbox*
- 移除 VLC:sudo apt-get purge vlc
- 提示:上述为常见示例,具体包名以你的系统为准,执行前建议先查询确认。
五 注意事项与建议
- 使用 purge 会删除配置文件;若计划重装并保留原有配置,请仅用 remove。
- 卸载前确认无关键依赖正在使用,避免影响系统稳定;不确定时先查询包信息:apt show 包名。
- 卸载完成后执行 sudo apt autoremove,清理不再需要的依赖与旧包缓存。
- 在 VNC/SSH 会话中操作与物理机一致,无需额外步骤;若提示找不到包,先更新索引:sudo apt update。