snap 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

snap 命令安装:


-bash/zsh: snap command not found

#Debian
apt-get install snap

#Ubuntu
apt-get install snap

#Kali Linux
apt-get install snap

#Fedora
dnf install snapd

#Raspbian
apt-get install snap

snap 命令补充说明:


snap 命令工具用于与 snapd 守护进程交互,以控制 snappy 软件平台。

snap 可以安装、配置、刷新和删除 snap 包。 snapd 是 CLI (它是一种后台服务),负责处理系统上的快照。从“快照列表”开始查看已安装的快照。

snap 命令语法:


snap [OPTIONS]

snap 命令选项:


Application Options
   --version
          Print the version and exit

Help Options
   -h, --help
          Show this help message

snap 命令 COMMANDS:


abort
   Abort a pending change

   The abort command attempts to abort a change that still has pending tasks.

   Usage: snap [OPTIONS] abort [abort-OPTIONS]

      Abort a pending change
          The abort command attempts to abort a change that still has pending tasks.

   --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.)

Help Options
   -h, --help
          Show this help message

ack
   Adds an assertion to the system

   The ack command tries to add an assertion to the system assertion database.

   The assertion may also be a newer  revision  of  a  preexisting  assertion  that  it  will
   replace.

   To succeed the assertion must be valid, its signature verified with a known public key and
   the assertion consistent with and its prerequisite in the database.

Help Options
   -h, --help
          Show this help message

alias
   Sets up a manual alias

   The alias command aliases the given snap application to the given alias.

   Once this manual alias is setup the respective application command  can  be  invoked  just
   using the alias.

Help Options
   -h, --help
          Show this help message

aliases
   Lists aliases in the system

   The aliases command lists all aliases available in the system and their status.

   $ snap aliases <snap>

   Lists only the aliases defined by the specified snap.

   An alias noted as undefined means it was explicitly enabled or disabled but is not defined
   in the current revision of the snap; possibly temporarely (e.g because of  a  revert),  if
   not this can be cleared with snap alias --reset.

Help Options
   -h, --help
          Show this help message

buy
   Buys a snap

   The buy command buys a snap from the store.

Help Options
   -h, --help
          Show this help message

changes
   List system changes

   The changes command displays a summary of the recent system changes performed.

Help Options
   -h, --help
          Show this help message

connect
   Connects a plug to a slot

   The connect command connects a plug to a slot.  It may be called in the following ways:

   $ snap connect <snap>:<plug> <snap>:<slot>

   Connects the provided plug to the given slot.

   $ snap connect <snap>:<plug> <snap>

   Connects  the  specific  plug  to  the  only  slot  in  the provided snap that matches the
   connected interface. If more than one potential slot exists, the command fails.

   $ snap connect <snap>:<plug>

   Connects the provided plug to the slot in the core snap with  a  name  matching  the  plug
   name.

Help Options
   -h, --help
          Show this help message

disable
   Disables a snap in the system

   The  disable command disables a snap. The binaries and services of the snap will no longer
   be available. But all the data is still available and  the  snap  can  easily  be  enabled
   again.

   Usage: snap [OPTIONS] disable [disable-OPTIONS]

      Disables a snap in the system
          The  disable command disables a snap. The binaries and services of the snap will no
          longer be available. But all the data is still available and the snap can easily be
          enabled again.

Help Options
   -h, --help
          Show this help message

disconnect
   Disconnects a plug from a slot

   The  disconnect command disconnects a plug from a slot.  It may be called in the following
   ways:

   $ snap disconnect <snap>:<plug> <snap>:<slot>

   Disconnects the specific plug from the specific slot.

   $ snap disconnect <snap>:<slot or plug>

   Disconnects everything from the provided plug or slot.  The snap name may be  omitted  for
   the core snap.

Help Options
   -h, --help
          Show this help message

download
   Downloads the given snap

   The download command downloads the given snap and its supporting assertions to the current
   directory under .snap and .assert file extensions, respectively.

   Usage: snap [OPTIONS] download [download-OPTIONS]

      Downloads the given snap
          The download command downloads the given snap and its supporting assertions to  the
          current directory under .snap and .assert file extensions, respectively.

   --channel
          Use this channel instead of stable

   --edge Install from the edge channel

   --beta Install from the beta channel

   --candidate
          Install from the candidate channel

   --stable
          Install from the stable channel

   --revision
          Download the given revision of a snap, to which you must have developer access

Help Options
   -h, --help
          Show this help message

enable
   Enables a snap in the system

   The enable command enables a snap that was previously disabled.

   Usage: snap [OPTIONS] enable [enable-OPTIONS]

      Enables a snap in the system
          The enable command enables a snap that was previously disabled.

Help Options
   -h, --help
          Show this help message

find
   Finds packages to install

   The find command queries the store for available packages in the stable channel.

   Usage: snap [OPTIONS] find [find-OPTIONS]

   Aliases: search

Finds packages to install
   The find command queries the store for available packages in the stable channel.

   --private
          Search private snaps

   --section [="show-all-sections-please"] <default: "no-section-specified">
          Restrict the search to a given section

Help Options
   -h, --help
          Show this help message

get
   Prints configuration options

   The get command prints configuration options for the provided snap.

       $ snap get snap-name username
       frank

   If multiple option names are provided, a document is returned:

       $ snap get snap-name username password
       {
           "username": "frank",
           "password": "..."
       }

   Nested values may be retrieved via a dotted path:

       $ snap get snap-name author.name
       frank

   Usage: snap [OPTIONS] get [get-OPTIONS]

      Prints configuration options
          The get command prints configuration options for the provided snap.

              $ snap get snap-name username
              frank

          If multiple option names are provided, a document is returned:

              $ snap get snap-name username password
              {
                  "username": "frank",
                  "password": "..."
              }

          Nested values may be retrieved via a dotted path:

              $ snap get snap-name author.name
              frank

   -t     Strict typing with nulls and quoted strings

   -d     Always return document, even with single key

   -l     Always return list, even with single key

Help Options
   -h, --help
          Show this help message

help
   Help

   The help command shows helpful information. Unlike this. ;-)

   Usage: snap [OPTIONS] help [help-OPTIONS]

      Help
          The help command shows helpful information. Unlike this. ;-)

   --man  Generate the manpage

Help Options
   -h, --help
          Show this help message

info
   Show detailed information about a snap

   The info command shows detailed information about a snap, be it by name or by path.

   Usage: snap [OPTIONS] info [info-OPTIONS]

      Show detailed information about a snap
          The info command shows detailed information about a snap, be it by name or by path.

   --verbose
          Include a verbose list of a snap's notes (otherwise, summarise notes)

Help Options
   -h, --help
          Show this help message

install
   Installs a snap to the system

   The install command installs the named snap in the system.

   Usage: snap [OPTIONS] install [install-OPTIONS]

      Installs a snap to the system
          The install command installs the named snap in the system.

   --channel
          Use this channel instead of stable

   --edge Install from the edge channel

   --beta Install from the beta channel

   --candidate
          Install from the candidate channel

   --stable
          Install from the stable channel

   --devmode
          Put snap in development mode and disable security confinement

   --jailmode
          Put snap in enforced confinement mode

   --classic
          Put snap in classic mode and disable security confinement

   --revision
          Install the given revision of a snap, to which you must have developer access

   --dangerous
          Install  the  given  snap file even if there are no pre-acknowledged signatures for
          it, meaning it was not verified and could be dangerous (--devmode implies this)

   --unaliased
          Install the given snap without enabling its automatic aliases

Help Options
   -h, --help
          Show this help message

interface
   Lists snap interfaces

   The interface command shows details of snap interfaces.

   If no interface name is provided, a list of interface names with at least  one  connection
   is shown, or a list of all interfaces if --all is provided.

   Usage: snap [OPTIONS] interface [interface-OPTIONS]

      Lists snap interfaces
          The interface command shows details of snap interfaces.

          If  no  interface  name  is  provided,  a list of interface names with at least one
          connection is shown, or a list of all interfaces if --all is provided.

   --attrs
          Show interface attributes

   --all  Include unused interfaces

Help Options
   -h, --help
          Show this help message

interfaces
   Lists interfaces in the system

   The interfaces command lists interfaces available in the system.

   By default all slots and plugs, used and offered by all snaps, are displayed.

   $ snap interfaces <snap>:<slot or plug>

   Lists only the specified slot or plug.

   $ snap interfaces <snap>

   Lists the slots offered and plugs used by the specified snap.

   $ snap interfaces -i=<interface> [<snap>]

   Filters the complete output so only plugs and/or slots matching the provided  details  are
   listed.

   Usage: snap [OPTIONS] interfaces [interfaces-OPTIONS]

      Lists interfaces in the system
          The interfaces command lists interfaces available in the system.

          By default all slots and plugs, used and offered by all snaps, are displayed.

          $ snap interfaces <snap>:<slot or plug>

          Lists only the specified slot or plug.

          $ snap interfaces <snap>

          Lists the slots offered and plugs used by the specified snap.

          $ snap interfaces -i=<interface> [<snap>]

          Filters  the  complete  output  so  only  plugs  and/or slots matching the provided
          details are listed.

   -i     Constrain listing to specific interfaces

Help Options
   -h, --help
          Show this help message

known
   Shows known assertions of the provided type

   The known command shows known assertions of the provided type.  If header=value pairs  are
   provided  after  the  assertion  type,  the  assertions shown must also have the specified
   headers matching the provided values.

   Usage: snap [OPTIONS] known [known-OPTIONS]

      Shows known assertions of the provided type
          The known command shows known assertions of the  provided  type.   If  header=value
          pairs  are  provided  after the assertion type, the assertions shown must also have
          the specified headers matching the provided values.

   --remote

Help Options
   -h, --help
          Show this help message

list
   List installed snaps

   The list command displays a summary of snaps installed in the current system.

   Usage: snap [OPTIONS] list [list-OPTIONS]

      List installed snaps
          The list command displays a summary of snaps installed in the current system.

   --all  Show all revisions

Help Options
   -h, --help
          Show this help message

login
   Authenticates on snapd and the store

   The login command authenticates on snapd and the snap store and saves credentials into the
   ~/.snap/auth.json  file.  Further  communication  with snapd will then be made using those
   credentials.

   Login only works for local users in the sudo, admin or wheel groups.

   An account can be setup at https://login.ubuntu.com

Help Options
   -h, --help
          Show this help message

logout
   Log out of the store

   This command logs the current user out of the store

Help Options
   -h, --help
          Show this help message

logs
   Retrieve logs of services

   The logs command fetches logs of the given services and  displays  them  in  chronological
   order.

   Usage: snap [OPTIONS] logs [logs-OPTIONS]

      Retrieve logs of services
          The  logs  command  fetches  logs  of  the  given  services  and  displays  them in
          chronological order.

   -n <default: "10">
          Show only the given number of lines, or 'all'.

   -f     Wait for new lines and print them as they come in.

Help Options
   -h, --help
          Show this help message

pack
   Pack the given target dir as a snap

   The pack command packs the given snap-dir as a snap.

Help Options
   -h, --help
          Show this help message

prefer
   Prefer aliases from a snap and disable conflicts

   The prefer command enables all aliases of the given  snap  in  preference  to  conflicting
   aliases of other snaps whose aliases will be disabled (removed for manual ones).

Help Options
   -h, --help
          Show this help message

refresh
   Refreshes a snap in the system

   The refresh command refreshes (updates) the named snap.

   Usage: snap [OPTIONS] refresh [refresh-OPTIONS]

      Refreshes a snap in the system
          The refresh command refreshes (updates) the named snap.

   --channel
          Use this channel instead of stable

   --edge Install from the edge channel

   --beta Install from the beta channel

   --candidate
          Install from the candidate channel

   --stable
          Install from the stable channel

   --devmode
          Put snap in development mode and disable security confinement

   --jailmode
          Put snap in enforced confinement mode

   --classic
          Put snap in classic mode and disable security confinement

   --amend
          Allow refresh attempt on snap unknown to the store

   --revision
          Refresh to the given revision

   --list Show available snaps for refresh but do not perform a refresh

   --time Show auto refresh information but do not perform a refresh

   --ignore-validation
          Ignore validation by other snaps blocking the refresh

Help Options
   -h, --help
          Show this help message

remove
   Removes a snap from the system

   The remove command removes the named snap from the system.

   By  default  all  the snap revisions are removed, including their data and the common data
   directory. When a --revision option is passed only the specified revision is removed.

   Usage: snap [OPTIONS] remove [remove-OPTIONS]

      Removes a snap from the system
          The remove command removes the named snap from the system.

          By default all the snap revisions are removed, including their data and the  common
          data  directory.  When a --revision option is passed only the specified revision is
          removed.

   --revision
          Remove only the given revision

Help Options
   -h, --help
          Show this help message

restart
   Restart services

   The restart command restarts the given services.

   If the --reload option is given, for each service whose app has a reload command, a reload
   is performed instead of a restart.

   Usage: snap [OPTIONS] restart [restart-OPTIONS]

      Restart services
          The restart command restarts the given services.

          If the --reload option is given, for each service whose app has a reload command, a
          reload is performed instead of a restart.

   --reload
          If the service has a reload command, use it instead of restarting.

Help Options
   -h, --help
          Show this help message

revert
   Reverts the given snap to the previous state

   The revert command reverts the given snap to its state before  the  latest  refresh.  This
   will  reactivate  the  previous  snap  revision,  and  will use the original data that was
   associated with that revision, discarding any data changes that were done  by  the  latest
   revision.  As  an  exception,  data  which  the  snap  explicitly  chooses to share across
   revisions is not touched by the revert process.

   Usage: snap [OPTIONS] revert [revert-OPTIONS]

      Reverts the given snap to the previous state
          The revert command reverts the given snap to its state before the  latest  refresh.
          This  will  reactivate  the  previous snap revision, and will use the original data
          that was associated with that revision, discarding any data changes that were  done
          by  the latest revision. As an exception, data which the snap explicitly chooses to
          share across revisions is not touched by the revert process.

   --devmode
          Put snap in development mode and disable security confinement

   --jailmode
          Put snap in enforced confinement mode

   --classic
          Put snap in classic mode and disable security confinement

   --revision
          Revert to the given revision

Help Options
   -h, --help
          Show this help message

run
   Run the given snap command

   Run the given snap command with the right confinement and environment

   Usage: snap [OPTIONS] run [run-OPTIONS]

      Run the given snap command
          Run the given snap command with the right confinement and environment

   --shell
          Run a shell instead of the command (useful for debugging)

   --strace [="with-strace"] <default: "no-strace">
          Run the command under strace (useful for debugging). Extra strace  options  can  be
          specified as well here.

   --gdb  Run the command with gdb

Help Options
   -h, --help
          Show this help message

services
   Query the status of services

   The services command lists information about the services specified, or about the services
   in all currently installed snaps.

Help Options
   -h, --help
          Show this help message

set
   Changes configuration options

   The set command changes the provided configuration options as requested.

       $ snap set snap-name username=frank password=$PASSWORD

   All configuration changes are persisted at once, and only after the  snap's  configuration
   hook returns successfully.

   Nested values may be modified via a dotted path:

       $ snap set author.name=frank

Help Options
   -h, --help
          Show this help message

start
   Start services

   The start command starts, and optionally enables, the given services.

   Usage: snap [OPTIONS] start [start-OPTIONS]

      Start services
          The start command starts, and optionally enables, the given services.

   --enable
          As well as starting the service now, arrange for it to be started on boot.

Help Options
   -h, --help
          Show this help message

stop
   Stop services

   The stop command stops, and optionally disables, the given services.

   Usage: snap [OPTIONS] stop [stop-OPTIONS]

      Stop services
          The stop command stops, and optionally disables, the given services.

   --disable
          As  well  as  stopping  the  service now, arrange for it to no longer be started on
          boot.

Help Options
   -h, --help
          Show this help message

switch
   Switches snap to a different channel

   The switch command switches the given snap to a different channel without doing a refresh.

   Usage: snap [OPTIONS] switch [switch-OPTIONS]

      Switches snap to a different channel
          The switch command switches the given snap to a different channel without  doing  a
          refresh.

   --channel

   --edge

   --beta

   --candidate

   --stable

Help Options
   -h, --help
          Show this help message

tasks
   List a change's tasks

   The tasks command displays a summary of tasks associated to an individual change.

   Usage: snap [OPTIONS] tasks [tasks-OPTIONS]

   Aliases: change

List a change's tasks
   The tasks command displays a summary of tasks associated to an individual change.

   --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.)

Help Options
   -h, --help
          Show this help message

try
   Tests a snap in the system

   The  try  command  installs  an  unpacked  snap into the system for testing purposes.  The
   unpacked snap content continues to  be  used  even  after  installation,  so  non-metadata
   changes  there  go  live  instantly. Metadata changes such as those performed in snap.yaml
   will require reinstallation to go live.

   If snap-dir argument is omitted, the try command  will  attempt  to  infer  it  if  either
   snapcraft.yaml  file  and  prime directory or meta/snap.yaml file can be found relative to
   current working directory.

   Usage: snap [OPTIONS] try [try-OPTIONS]

      Tests a snap in the system
          The try command installs an unpacked snap into the  system  for  testing  purposes.
          The  unpacked  snap  content  continues to be used even after installation, so non-
          metadata changes there go live instantly. Metadata changes such as those  performed
          in snap.yaml will require reinstallation to go live.

          If snap-dir argument is omitted, the try command will attempt to infer it if either
          snapcraft.yaml file and  prime  directory  or  meta/snap.yaml  file  can  be  found
          relative to current working directory.

   --devmode
          Put snap in development mode and disable security confinement

   --jailmode
          Put snap in enforced confinement mode

   --classic
          Put snap in classic mode and disable security confinement

Help Options
   -h, --help
          Show this help message

unalias
   Unalias a manual alias or an entire snap

   The  unalias command tears down a manual alias when given one or disables all aliases of a
   snap, removing also all manual ones, when given a snap name.

Help Options
   -h, --help
          Show this help message

version
   Shows version details

   The version command displays the versions of the running  client,  server,  and  operating
   system.

Help Options
   -h, --help
          Show this help message

watch
   Watch a change in progress

   The  watch  command  waits  for  the  given  change-id  to  finish  and shows progress (if
   available).

   Usage: snap [OPTIONS] watch [watch-OPTIONS]

      Watch a change in progress
          The watch command waits for the given change-id to finish and  shows  progress  (if
          available).

   --last Select last change of given type (install, refresh, remove, try, auto-refresh etc.)

Help Options
   -h, --help
          Show this help message

whoami
   Prints the email the user is logged in with

   The whoami command prints the email the user is logged in with.

Help Options
   -h, --help
          Show this help message

snap 命令实例:


snap 搜索包:

snap find package_name

snap 安装一个包:

snap install package_name

snap 更新所有软件包:

snap refresh

snap 显示已安装的 snap 软件的基本信息:

snap list

snap 卸载软件包:

snap remove package_name

snap 检查系统中最近的快照更改:

snap changes

snap 命令扩展阅读:




snap 命令评论

共收录到 491Linux 命令