python安装snaps_如何管理Ubuntu Snaps:没人告诉你的东西

 2023-09-06 阅读 31 评论 0

摘要:python安装snapsCanonical’s Snaps are definitely the real deal. The secure and portable Linux package management system is more than a geeky tool for showing off your tech creds. Just consider the growing list of companies that have already bought in and

python安装snaps

Canonical’s Snaps are definitely the real deal. The secure and portable Linux package management system is more than a geeky tool for showing off your tech creds. Just consider the growing list of companies that have already bought in and are providing their desktop software through snaps, including Blender, Slack, Spotify, Android Studio, and Microsoft’s (Microsoft!) Visual Studio Code. And don’t forget that the real growth of the snap system is in the world of IoT devices and servers rather than desktops.

Canonical的快照绝对是真正的交易。 安全,可移植的Linux软件包管理系统不仅仅是展示技术信誉的令人讨厌的工具。 只需考虑不断增加的已经购买并通过快照提供桌面软件的公司,包括Blender,Slack,Spotify,Android Studio和Microsoft(Microsoft!)Visual Studio Code。 并且不要忘记,快照系统的真正增长是在IoT设备和服务器而不是台式机领域。

But as the popularity of snaps grows — some new Linux distros come with the snapd service installed by default — you might be forgiven for wondering how you’re supposed to make them work. Don’t get me wrong: there are all kinds of web-based guides for finding, installing, and removing snaps. And there are places developers can go for help building their applications as snaps. But right now I’m talking about configuring their behavior or troubleshooting when things go wrong.

但是随着快照的流行(默认情况下会安装一些新的Linux发行版中包含的快照服务),您可能会因为想知道如何使它们工作而被原谅。 不要误会我的意思:有各种基于Web的指南可用于查找,安装和删除快照。 开发人员可以在某些地方寻求帮助,以快速构建其应用程序。 但是现在我正在谈论配置他们的行为或在出现问题时进行故障排除

Just for the record, you search for new snaps to install using something like:

仅作记录,您可以使用以下方法搜索要安装的新快照:

snap find aws

When you find a package you like, you install it using:

找到所需的软件包后,可以使用以下方法安装它:

snap install aws-cli

Oh, and you delete ‘em with remove.

哦,您用删除功能删除了它们。

snap remove aws-cli

There. You can’t say I never taught you anything. But that’s not what this article is about. What we are going to talk about is real management stuff, like changing configurations or troubleshooting things that broke.

那里。 你不能说我从没教过你什么。 但这不是本文的目的。 我们要谈论的是真正的管理内容,例如更改配置或对故障进行故障排除。

了解快照文件系统 (Understanding the snap file system)

Well, how’s that going to be different from the way you’d normally do it on Linux? Configuration files are usually going to be in /etc/, processes will reveal their deepest secrets through systemctl, and logs will find their way to /var/log/.

那么,这与您通常在Linux上进行操作的方式有何不同? 配置文件通常将位于/ etc /中 ,进程将通过systemctl揭示其最深层的秘密,日志将找到进入/ var / log /的方式

Not so fast there, pilgrim. That’s not always how things work in Snapland. You see, a snap is really nothing more than a single compressed file (named using the .snap extension) containing the entire file system needed for running a package. These files are never actually decompressed and “installed,” but are mounted dynamically at run time and exposed to the user as a virtual environment.

朝圣者那里不是那么快。 Snapland并不总是这样。 您会看到,快照实际上只不过是包含运行包所需的整个文件系统的单个压缩文件(使用.snap扩展名命名)。 这些文件从不实际解压缩和“安装”,而是在运行时动态安装并作为虚拟环境向用户公开。

This means that the resources used by a program might not actually exist on the host system. Thus, for example, the Nextcloud snap creates its own versions of Apache and MySQL for its backend. So if, say, you want to configure a new virtual host in /etc/apache2/sites-available/ or create a new MySQL user the traditional way, you’re out of luck.

这意味着程序使用的资源可能在主机系统上实际上不存在。 因此,例如,Nextcloud快照为其后端创建了自己的Apache和MySQL版本。 因此,例如,如果您想在/ etc / apache2 / sites-available /中配置新的虚拟主机,或者以传统方式创建新MySQL用户,那么您就不走运了。

The advantages of this approach are significant: installation and setup will generally be much smoother and you’re far less likely to run into dependency issues and conflicts. But it also at least appears to mean that you get less access to the vital organs that power your software.

这种方法的优势非常明显:安装和设置通常会更加顺畅,并且您遇到相依性问题和冲突的可能性也要小得多。 但这至少也似乎意味着您对驱动软件的重要器官的访问较少。

So, then, where does everything snappy happen? Take a look through your host file system for yourself: you’ll probably find more snap directories than you can shake a stick at (should you be so inclined). Here are the directories the snap install process probably created:

那么,什么都快发生在哪里呢? 亲自浏览一下主机文件系统:您可能会发现比快照目录更多的快照目录(如果您倾向的话)。 以下是快照安装过程可能创建的目录:

/snap//var/snap//var/lib/snapd//home/username/snap/

/ snap // var / snap // var / lib / snapd // home /用户名/ snap /

That many? What for? Let’s go through those one at a time. Feel free to poke around your own Linux machine to see all this for yourself.

那么多? 做什么的? 让我们一次浏览一下那些。 随意在自己的Linux机器上四处浏览,以亲自体验所有这些。

The actual .snap files are kept in the /var/lib/snapd/snaps/ directory. When running, those files will be mounted within the root directory /snap/. Looking over there — in the /snap/core/ subdirectory — you’ll see what looks like a regular Linux file system. It’s actually the virtual file system that’s being used by active snaps.

实际的.snap文件保存在/ var / lib / snapd / snaps /目录中。 运行时,这些文件将安装在根目录/ snap /中 。 在那儿/ snap / core /子目录中,您会看到看起来像常规Linux文件系统的东西。 实际上,活动快照正在使用虚拟文件系统。

ls /snap/core/current
bin   dev  home  lib64  meta  opt   root  sbin  srv  tmp  var
boot  etc  lib   media  mnt   proc  run   snap  sys  usr  writable

And here’s a subdirectory containing (read-only) configuration files used by the Nextcloud snap. That’ll only be there, of course, if you’ve installed Nextcloud (snap install nextcloud).

这是一个包含Nextcloud快照使用的(只读)配置文件的子目录。 当然,只有在您安装Nextcloud的情况下,它才会在那里( 快照安装nextcloud )。

ls /snap/nextcloud/current/conf/
httpd.conf  mime.types  ssl.conf

Ok. Now what about /var/snap/? Very much like traditional inhabitants of /var/, the files within /var/snap/ contain various forms of user data and log files — the kind of data that’s generated and consumed by applications during operations. This example shows directories for data used by some desktop-related snaps, including the AWS CLI and the Slack team communication tool. (OK, technically speaking, the AWS CLI isn’t a desktop tool.)

好。 现在/ var / snap /呢? 与/ var /的传统居民非常相似, / var / snap /中的文件包含各种形式的用户数据和日志文件,即应用程序在操作过程中生成和使用的数据类型。 此示例显示了一些与桌面相关的快照所使用的数据的目录,包括AWS CLI和Slack团队通信工具。 (好的,从技术上来讲,AWS CLI不是桌面工具。)

ls /var/snap
aws-cli  core18           gnome-system-monitor  gnome-calculator
brave    gnome-3-26-1604  gnome-characters      gtk-common-themes
core     gnome-3-28-1804  gnome-logs            slack

Dive deep into the subdirectories within /var/snap/on your machine and see what you can discover.

深入研究计算机上/ var / snap /中的子目录,然后发现可以发现的内容。

That leaves just the ~/snap directory that exists in a user’s home directory on at least some Linux file systems. It’ll contain directories using some of the names you’ll see in /var/snap. What’s going on in there?

至少在某些Linux文件系统上,仅在用户主目录中存在〜/ snap目录。 它包含使用您在/ var / snap中会看到的一些名称的目录。 那里发生了什么事?

ls ~/snap
aws-cli  brave  gnome-calculator  slack

As far as I can tell, these directories are meant to store versioned data related to settings used by your user account.

据我所知,这些目录用于存储与您的用户帐户使用的设置相关的版本化数据。

快照管理工具 (Snap administration tools)

So far I’ve shown you how to find various classes of data kept in configuration files (within /var/snap/), virtual file systems (/snap/), and collections of user settings (~/snap). I also showed you where not to look — /var/lib/snapd/ — which is where the .snap files themselves live; nothing to see here, move along now.

到目前为止,我已经向您展示了如何找到保存在配置文件(在/ var / snap /内 ),虚拟文件​​系统( / snap / )和用户设置集合( 〜/ snap )中的各种数据类别。 我还展示了哪里都不看- 在/ var / lib中/ snapd / -这哪里是.snap文件本身生活; 没什么可看的,现在继续前进。

Now what about actual administration? This is a bit more complicated. Some snaps — like Nextcloud — expose a fully-featured admin interface. I talk about that in my Administrating Nextcloud as a Snap article. But it seems that the simplicity of snaps sometimes means that there just isn’t much hands-on configuration that’s possible.

现在如何进行实际管理? 这有点复杂。 一些快照(例如Nextcloud)公开了功能齐全的管理界面。 我在《 管理Nextcloud作为快照》一文中谈到了这一点。 但是似乎快照的简单性有时意味着没有太多可能的动手配置。

However, that’s not always the case. But first, you’ll need to know about snap services. Some more complex applications require multi-layer software stacks. Nextcloud, for instance, creates and manages its own versions of Apache, MySQL, PHP, and Redis. Each one of those “layers” is, in snap terms, called a service.

但是,并非总是如此。 但是首先,您需要了解snap服务 。 一些更复杂的应用程序需要多层软件堆栈。 例如,Nextcloud创建并管理自己的Apache,MySQL,PHP和Redis版本。 简而言之,这些“层”中的每一层都称为服务。

If any snaps installed on your machine have their own services, you’ll be able to list them along with their status using this snapd command:

如果您计算机上安装的任何快照都有自己的服务,则可以使用以下快照命令列出它们及其状态:

snap services
Service                    Startup  Current   Notes
nextcloud.apache           enabled  active    -
nextcloud.mdns-publisher   enabled  active    -
nextcloud.mysql            enabled  active    -
nextcloud.nextcloud-cron   enabled  active    -
nextcloud.nextcloud-fixer  enabled  inactive  -
nextcloud.php-fpm          enabled  active    -
nextcloud.redis-server     enabled  active    -
nextcloud.renew-certs      enabled  active    -

You can also control the run and startup status of a service. This example will stop Nextcloud’s Apache service and ensure that it doesn’t launch when the system reboots (although, just remember that this will disable Nextcloud — you probably don’t want to do that):

您还可以控制服务的运行和启动状态。 此示例将停止Nextcloud的Apache服务,并确保在系统重新引导时该服务不会启动(尽管,请记住,这将禁用Nextcloud-您可能不想这样做):

snap stop --disable nextcloud.apache

You can also use systemctl to manage snap service processes:

您还可以使用systemctl来管理快照服务进程:

systemctl status snap.nextcloud.apache

If your snap includes at least one service, you can view its logs using snapd:

如果您的快照至少包含一项服务,则可以使用快照查看其日志:

snap logs nextcloud

You can also specify a particular service:

您还可以指定特定的服务:

snap logs nextcloud.mysql

For some snaps (like Nextcloud), snapd makes useful configurations available from the command line. You can display available settings using snap get:

对于某些快照(如Nextcloud),快照可从命令行提供有用的配置。 您可以使用snap get显示可用设置:

snap get nextcloud
Key        Value
mode       production
nextcloud  {...}
php        {...}
ports      {...}
private    {...}

Drop down a level by adding the name of a specific setting. This example shows us that Nextcloud is currently listening on only ports 80 (HTTP) and 443 (HTTPS).

通过添加特定设置的名称来降低级别。 此示例向我们显示Nextcloud当前仅在端口80(HTTP)和443(HTTPS)上侦听。

snap get nextcloud ports
Key          Value
ports.http   80
ports.https  443

You could change a setting using the set command. This one would tell Nextcloud to listen on port 8080 for insecure HTTP requests instead of 80.

您可以使用set命令更改设置。 这将告诉Nextcloud在端口8080上侦听不安全的HTTP请求,而不是80。

snap set nextcloud ports.http=8080

Snapd also offers some system-wide configuration settings that are described here, documentation of environment variables is maintained here, and information on keeping your snaps updated can be found here.

Snapd还提供了此处描述的一些系统范围的配置设置, 此处 维护了环境变量的文档,并且可以在此处找到有关更新快照的信息。

All that’ll get you started when things need fixing. So get to it.

当需要修复时,所有这些都可以帮助您入门。 所以去吧。

Looking for more? You might enjoy my books and Pluralsight courses on Linux, AWS, and Docker-related topics.

寻找更多? 您可能会喜欢我的 书籍和 有关Linux,AWS和Docker相关主题的 Pluralsight课程

翻译自: https://www.freecodecamp.org/news/managing-ubuntu-snaps/

python安装snaps

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/7198.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息