ubuntu内移除snap

ubuntu 移除snap

snap 是 ubuntu 的集中式管理的软件商城,但在使用过程中软件更新没有很及时。ubuntu 20.04 在安装开始就有预装了 snap,所以我想把它移除掉,省出系统空间。

具体参考链接:https://cloud.tencent.com/developer/article/2168090,可以直接跳转查看步骤。

查看 snap 服务

先查看 snapd 服务是否在运行。

bash 复制代码
$ sudo systemctl status snapd
[sudo] password for sanren1024: 
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2023-12-04 09:59:36 CST; 10min ago
TriggeredBy: ● snapd.socket
   Main PID: 853 (snapd)
      Tasks: 15 (limit: 9387)
     Memory: 64.3M
     CGroup: /system.slice/snapd.service
             └─853 /usr/lib/snapd/snapd

12月 04 09:59:33 vm-ubuntu2004 systemd[1]: Starting Snap Daemon...
12月 04 09:59:36 vm-ubuntu2004 snapd[853]: overlord.go:272: Acquiring state lock file
12月 04 09:59:36 vm-ubuntu2004 snapd[853]: overlord.go:277: Acquired state lock file
12月 04 09:59:36 vm-ubuntu2004 snapd[853]: daemon.go:247: started snapd/2.60.4 (series 16; classic) ubuntu/>
12月 04 09:59:36 vm-ubuntu2004 snapd[853]: daemon.go:340: adjusting startup timeout by 1m10s (pessimistic e>
12月 04 09:59:36 vm-ubuntu2004 snapd[853]: backends.go:58: AppArmor status: apparmor is enabled and all fea>
12月 04 09:59:36 vm-ubuntu2004 systemd[1]: Started Snap Daemon.

上述结果中显示 Active: active (running) 表示 snapd 线程正在运行。

停止 snap 服务

停止 snap 相关服务。

bash 复制代码
$ sudo systemctl disable snapd
Removed /etc/systemd/system/multi-user.target.wants/snapd.service.
$ sudo systemctl disable snapd.socket
Removed /etc/systemd/system/sockets.target.wants/snapd.socket.
$ sudo systemctl disable snapd.seeded.service
Removed /etc/systemd/system/multi-user.target.wants/snapd.seeded.service.
Removed /etc/systemd/system/cloud-final.service.wants/snapd.seeded.service.

这样停止了 snap 服务。

查看 snap 安装的软件

查看 snap 已经安装的软件。

bash 复制代码
$ snap list
Name               Version           Rev    Tracking         Publisher   Notes
bare               1.0               5      latest/stable    canonical✓  base
core20             20230801          2015   latest/stable    canonical✓  base
core22             20230801          864    latest/stable    canonical✓  base
gnome-3-38-2004    0+git.efb213a     143    latest/stable/...  canonical✓  -
gnome-42-2204      0+git.ff35a85     141    latest/stable    canonical✓  -
gtk-common-themes  0.1-81-g442e511   1535   latest/stable/...  canonical✓  -
snap-store         41.3-71-g709398e  959    latest/stable/...  canonical✓  -
snapd              2.60.4            20290  latest/stable    canonical✓  snapd

卸载 snap 软件

卸载 snap 软件,先卸载普通应用软件,后现在 base 软件。

bash 复制代码
$ snap remove snap-store
$ snap remove gtk-common-themes
$ snap remove gnome-42-2204
$ snap remove gnome-3-38-2004
$ snap remove core20
$ snap remove core22
$ snap remove bare
$ snap remove snapd   # 最后移除这个服务,这是所有服务的基础。

这样 snap 就可以从系统中移除。

禁止 snap 重新安装

若只是上述方式移除了 snap,后面在使用过程中系统会提示软件升级,若安装了,snap 又会被重新安装。因此要禁止 snap 重新安装。

编辑配置文件

bash 复制代码
$ sudo gedit /etc/apt/preferences.d/nosnap.pref

添加内容

text 复制代码
Package: snapd
Pin: release a=*
Pin-Priority: -10

保存退出。

相关推荐
有谁看见我的剑了?4 小时前
linux 添加硬盘后系统识别不到硬盘处理
linux·运维·服务器
yc_12246 小时前
用 Visual Studio 远程调试 Linux:从零到流畅的完整指南
linux·ide·visual studio
计算机安禾6 小时前
【Linux从入门到精通】第31篇:防火墙漫谈——iptables与firewalld防护指南
linux·运维·php
下一页盛夏花开6 小时前
ubuntu 20中安装QT以后出现红色空心断点
linux·运维·ubuntu
sanshanjianke7 小时前
Thunderobot 911ME 笔记本 Linux 风扇控制研究
linux
fengyehongWorld10 小时前
TeraTerm ttl脚本登录wsl
linux·teraterm
乌托邦的逃亡者10 小时前
Linux中如何检测IP冲突
linux·运维·tcp/ip
一曦的后花园11 小时前
linux搭建promethes并对接node-exporter指标
linux·运维·服务器
乌托邦的逃亡者11 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
拾贰_C12 小时前
【OpenClaw | openai | QQ】 配置QQ qot机器人
运维·人工智能·ubuntu·面试·prompt