snap 格式 Ubuntu 应用包

发布时间: 更新时间: 总字数:1005 阅读时间:3m 作者: 分享 复制网址

.snap包是Ubuntu 16.04 LTS发布时引入的新应用格式包,当前主流的Linux发行版均支持snap格式的包。本文介绍snap包的相关使用。

介绍

snap 包的优势:

  • 安全,snap 安装时在根目录下会出现如 /dev/loop0 的挂载点,这就是 snap 软件包的目录
    • Snap 使用 squashFS 文件系统(一种开源的压缩,只读文件系统,基于GPL协议发行)
    • 一旦 snap 被安装后,其就有一个只读的文件系统和一个可写入的区域。应用自身的执行文件、库、依赖包都被放在这个只读目录,意味着该目录不能被随意篡改和写入
    • 每个snap默认都被严格限制(confined),即限制系统权限和资源访问。当然可通过授予权限策略来获得对系统资源的访问
    • snap 包支持通过 interface(接口) 定义来做资源交换

使用

help

snap-help
snap --help
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap <command> [<options>...]

Commonly used commands can be classified as follows:

         Basics: find, info, install, remove, list
        ...more: refresh, revert, switch, disable, enable, create-cohort
        History: changes, tasks, abort, watch
        Daemons: services, start, stop, restart, logs
    Permissions: connections, interface, connect, disconnect
  Configuration: get, set, unset, wait
    App Aliases: alias, aliases, unalias, prefer
        Account: login, logout, whoami
      Snapshots: saved, save, check-snapshot, restore, forget
         Device: model, reboot, recovery
      ... Other: warnings, okay, known, ack, version
    Development: download, pack, run, try

For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.

$ snap help --all
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap <command> [<options>...]

Commands can be classified as follows:

  Basics (basic snap management):
    find             Find packages to install
    info             Show detailed information about snaps
    install          Install snaps on the system
    remove           Remove snaps from the system
    list             List installed snaps

  ...more (slightly more advanced snap management):
    refresh          Refresh snaps in the system
    revert           Reverts the given snap to the previous state
    switch           Switches snap to a different channel
    disable          Disable a snap in the system
    enable           Enable a snap in the system
    create-cohort    Create cohort keys for a set of snaps

  History (manage system change transactions):
    changes          List system changes
    tasks            List a change's tasks
    abort            Abort a pending change
    watch            Watch a change in progress

  Daemons (manage services):
    services         Query the status of services
    start            Start services
    stop             Stop services
    restart          Restart services
    logs             Retrieve logs for services

  Permissions (manage permissions):
    connections      List interface connections
    interface        Show details of snap interfaces
    connect          Connect a plug to a slot
    disconnect       Disconnect a plug from a slot

  Configuration (system administration and configuration):
    get              Print configuration options
    set              Change configuration options
    unset            Remove configuration options
    wait             Wait for configuration

  App Aliases (manage aliases):
    alias            Set up a manual alias
    aliases          List aliases in the system
    unalias          Remove a manual alias, or the aliases for an entire snap
    prefer           Enable aliases from a snap, disabling any conflicting aliases

  Account (authentication to snapd and the snap store):
    login            Authenticate to snapd and the store
    logout           Log out of snapd and the store
    whoami           Show the email the user is logged in with

  Snapshots (archives of snap data):
    saved            List currently stored snapshots
    save             Save a snapshot of the current data
    check-snapshot   Check a snapshot
    restore          Restore a snapshot
    forget           Delete a snapshot
    export-snapshot  Export a snapshot
    import-snapshot  Import a snapshot

  Device (manage device):
    model            Get the active model for this device
    reboot           Reboot into selected system and mode
    recovery         List available recovery systems

  Warnings (manage warnings):
    warnings         List warnings
    okay             Acknowledge warnings

  Assertions (manage assertions):
    known            Show known assertions of the provided type
    ack              Add an assertion to the system

  Introspection (introspection and debugging of snapd):
    version          Show version details
    debug            Run debug commands

  Development (developer-oriented features):
    download         Download the given snap
    pack             Pack the given directory as a snap
    run              Run the given snap command
    try              Test an unpacked snap in the system
    prepare-image    Prepare a device image

For more information about a command, run 'snap help <command>'.

基础使用

安装

安装软件,可使用如下命令或图形界面的 Ubuntu software store 完成:

sudo snap install snap-store

卸载

sudo snap remove snap-store

搜索

snap find snap-store

查看 snap 信息

snap info snap-store

查看已安装的 snap

snap list

更新snap

//channel来指定通道版本
sudo snap refresh snap-store channel=latest/stable

Account

$ snap login
Personal information is handled as per our privacy notice at
https://www.ubuntu.com/legal/dataprivacy/snap-store

Email address: 8@xiexianbin.cn
Password of "8@xiexianbin.cn":
Login successful

扩展

最新评论
加载中...
Home Archives Categories Tags Statistics