§2023-07-07
- Snap is a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and the systemd init system. The packages, called snaps, and the tool for using them, snapd, work across a range of Linux distributions[3] and allow upstream software developers to distribute their applications directly to users. Snaps are self-contained applications running in a sandbox with mediated access to the host system. Snap was originally released for cloud applications[4] but was later ported to also work for Internet of Things devices and desktop applications.
- Install snap on Arch
$ wget https://aur.archlinux.org/cgit/aur.git/snapshot/snapd.tar.gz
git clone https://aur.archlinux.org/snapd.git
cd ..
tar xvf src/snapd.tar.gz
cd snapd
makepkg -si
- Run on arch linux, for exmaple instll cwebot
$ sudo systemctl start snapd
$ sudo ln -s /var/lib/snapd/snap /snap --> or else, will err
$ sudo snap install --classic certbot
2023-07-07T10:33:54+08:00 INFO Waiting for automatic snapd restart...
Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not restarted your session
since you installed snapd, try doing that. Please see https://forum.snapcraft.io/t/9469
for more details.
certbot 2.6.0 from Certbot Project (certbot-eff✓) installed
WARNING: There is 1 new warning. See 'snap warnings'.
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
# relogin
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
I still cna not find in which file, such as ~/.bashrc or ~/.bash_profile, this /var/lib/snapd/snap/bin is added? --> from /etc/profile.d/snapd.sh
even you stopped snapd.service it stillbe activated by snapd.socket
by ChatGPT
Snap (short for Snappy) is a software packaging and distribution system developed by Canonical, the company behind Ubuntu Linux. It provides a way to package applications and their dependencies into a single compressed file, called a snap package, that can be easily installed and run on various Linux distributions.
Here's a high-level overview of how snap works:
-
Packaging: Developers use the Snapcraft tool to define the application's components, dependencies, and metadata in a snapcraft.yaml file. This file specifies how to build the snap package, including the necessary libraries, binaries, and other assets.
-
Building: The Snapcraft tool takes the snapcraft.yaml file and builds the snap package by fetching the required components from various sources, such as upstream projects, package managers, or other snaps. It ensures that all dependencies and runtime requirements are included in the package.
-
Isolation: Snap packages are designed to be sandboxed and isolated from the underlying system. They include their own set of dependencies and libraries, known as "snaps." This isolation helps to avoid conflicts between different applications and provides enhanced security by limiting access to system resources.
-
Distribution: Snap packages are distributed through a central repository called the Snap Store. Developers can publish their snaps to the Snap Store, where users can browse and install them. The Snap Store also provides automatic updates for installed snaps, ensuring users have the latest versions.
-
Installation: Users can install snaps using the snap command-line tool, which is available on most Linux distributions. The snap command fetches the snap package from the Snap Store and installs it on the system. During installation, the snap package is mounted as a read-only file system, and the application runs from within the snap's sandboxed environment.
-
Runtime Environment: When a snap is run, it runs in its own confined runtime environment called a "snapd" session. Snapd manages the execution of snaps and enforces their security policies, such as access to system resources like network interfaces, hardware devices, and user data.
-
Interfaces: Snap packages can declare interfaces that define the access permissions they require. For example, a snap might need network access or access to a specific hardware device. Users can control these permissions by connecting or disconnecting interfaces using the snap command.