myfreax

如何在CentOS 8安装snap

Snap Store是一个图形桌面应用程序,Snap Store通过有用的描述、评级、评论和屏幕截图展示特色和流行的Linux应用程序

4 min read
By myfreax
如何在CentOS 8安装snap

Snap Store是一个图形桌面应用程序,用于在Linux发现、安装和管理snaps。Snap Store通过有用的描述、评级、评论和屏幕截图展示特色和流行的Linux应用程序。

可以通过浏览类别或搜索找到应用程序。Snap Store还可用于切换频道、查看和更改snaps权限以及查看和提交评论和评级。

Snap Store是基于GNOME的软件,针对Snap体验进行了优化。教程说明如何在CentOS 8安装snap。

Snap与软件的所有依赖打包在一起的应用程序,你只需要在Snap构建一次,即可在所有流行的Linux发行版上运行。它们会自动更新并优雅地回滚。

因为Snap软件会打包软件所有依赖,它将会占用大量的空间,如果你给Linux的分区不是很大,不建议你使用snap安装软件。

你可以从Snap Store搜索和安装Snap打包的软件 ,这是一个拥有数百万用户的应用商店。

如果您运行的是Ubuntu 16.04 LTS (Xenial Xerus)或更高版本,包括Ubuntu 18.04 LTS (Bionic Beaver)和Ubuntu 20.04 LTS (Focal Fossa),则无需执行任何操作。

但是在CentOS 8 Linux你可能需要自己手动安装它,由于CentOS的仓库不包含Snapd软件包,因此需要先启用EPEL软件仓库。

EPEL的全称是Extra Packages for Enterprise Linux,也是Fedora项目的一个兴趣小组SIG,它为Fedora/RHEL/CentOS提供一组附加的软件。

首先运行命令sudo dnf install epel-release启动EPEL。然后再安装snapd软件包运行命令sudo yum install snapd

snapd是一个systemd服务,将会在后台运行,服务将用于自动更新软件,创建软件的snaps与回滚。

在安装snapd时,软件包将会包含snap命令,用于从snap store安装,配置,卸载软件。

安装完成后,需要启用snapd套接字的systemd单元,snapd的socket用于与命令snap通信。你可运行命令snap version查看snap的版本,验证是否安装成功。

sudo yum install epel-release -y
sudo yum install snapd -y
sudo systemctl start snapd.socket
sudo systemctl status snapd.socket
sudo systemctl start snapd.service
sudo systemctl status snapd.service
sudo ln -sf /var/lib/snapd/snap /snap
snap version
snap    2.56.2-1.el8
snapd   2.56.2-1.el8
series  16
centos  8
kernel  4.18.0-408.el8.x86_64

至此你已在CentOS 8安装snap。

this revision of snap "certbot" was published using classic confinement

error: This revision of snap "certbot" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to,

which may put your system at risk.If you understand and want to proceed repeat the command including --classic.

当你安装某些软件如果你遇到上面的错误提示时,你可以在运行snap install命令时添加--classic选项。

例如上面示例中,我们在CentOS7安装Certbot。由于CertBot发布软件是以经典的发布。

因此在安装Certbot时应添加--classic选项,运行命令snap install --classic  certbot

error: cannot install "certbot": classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap

提示很明确,让我们创建符号链接/var/lib/snapd/snap目录到/snap。在终端中运行命令sudo ln -sf /var/lib/snapd/snap /snap。就可以解决问题。

sudo ln -sf /var/lib/snapd/snap /snap

snap安装/卸载

在这个章节中我们将介绍一些基础的命令,包括搜索,安装,列出已安装的软件,卸载软件。

如果你需要搜索软件,使用snap的子命令find搜索软件,例如搜索certbot。可运行命令snap find certbot

查看snap软件信息,使用snap的子命令info,例如查看VLC播放器的信息。可运行命令snap find vlc。

安装软件,使用snap的子命令install,例如安装certbot获取Let's Encrypt SSL证书。可运行命令snap install certbot

卸载软件,使用snap的子命令remove,例如查看卸载VLC播放器,可运行命令snap install certbot

列出已安装的软件,使用snap的子命令list,可运行命令snap list

Related Articles