大家如果使用snap的话,你可以发现如下的命令:
liuxg@liuxg:~$ snap --help
Usage:
snap [OPTIONS] <command>
The snap tool interacts with the snapd daemon to control the snappy software platform.
Application Options:
--version Print the version and exit
Help Options:
-h, --help Show this help message
Available commands:
abort Abort a pending change
ack Adds an assertion to the system
buy Buys a snap
change List a change's tasks
changes List system changes
connect Connects a plug to a slot
create-user Creates a local system user
disable Disables a snap in the system
disconnect Disconnects a plug from a slot
download Download a given snap
enable Enables a snap in the system
find Finds packages to install
get Get snap configuration
help Help
install Installs a snap to the system
interfaces Lists interfaces in the system
known Shows known assertions of the provided type
list List installed snaps
login Authenticates on snapd and the store
logout Log out of the store
refresh Refreshes a snap in the system
remove Removes a snap from the system
revert Reverts the given snap to the previous state
run Run the given snap command
set Set snap configuration
try Tests a snap in the system
大家可以发现一个叫做"run"的命令.在大多数的情况下,我们并不需要运行这个命令.它在我们运行应用的时候被自动调用.但是,它有一个选项"--shell"非常有用,可以帮助我们调试我们的应用.比如,我们可以通过如下的方式:
$ snap try prime --devmode
$ cp /usr/bin/strace prime
$ sudo snap run --shell <snap.app>
$ (sudo) ./strace
这样我们就可以在一个shell中来调试我们的应用.我们以https://github.com/liu-xiao-guo/helloworld-snap例子为例.在安装完我们的snap应用后.我们可以使用如下的命令查看我们的环境:
liuxg@liuxg:~$ env | grep SNAP
liuxg@liuxg:~$ sudo -S snap run --shell hello-xiaoguo.hello-world
[sudo] password for liuxg:
root@liuxg:/home/liuxg# env | grep SNAP
SNAP_USER_COMMON=/root/snap/hello-xiaoguo/common
SNAP_REEXEC=
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:
SNAP_COMMON=/var/snap/hello-xiaoguo/common
SNAP_USER_DATA=/root/snap/hello-xiaoguo/x1
SNAP_DATA=/var/snap/hello-xiaoguo/x1
SNAP_REVISION=x1
SNAP_NAME=hello-xiaoguo
SNAP_ARCH=amd64
SNAP_VERSION=1.0
SNAP=/snap/hello-xiaoguo/x1
从上面我们可以看出来,在shell中已经有我们的snap的环境变量等信息。
本文永久更新地址://m.ajphoenix.com/linux/25618.html