【Linux】snap

Posted by 西维蜀黍 on 2022-04-01, Last Modified on 2023-05-02

Service Management

List

# Display basic information about installed snap software
$ snap list

# Check for recent snap changes in the system
$ snap changes

Install

# Search for a package
$ snap find package_name

# Install a package
$ snap install package_name

Update

# Update a package
$ snap refresh package_name

# Update a package to another channel (track, risk, or branch)
$ snap refresh package_name --channel=channel

# Update all packages
$ snap refresh

Uninstall

# Uninstall a package
$ snap remove package_name

Inspecting logs

If you need to see the log output for a snap’s services, use the logs command:

$ sudo snap logs lxd
2018-09-14T10:38:23Z lxd.daemon[11096]: => LXD is ready
(...)

$ sudo snap logs lxd.daemon
(...)

By default, only the last 10 lines are output. This can be changed with the -n= option which can accept either a number or all for the entire log:

$ sudo snap logs -n=all lxd.daemon

Adding the -f option will keep log output open so you can follow new entries as they occur:

$ sudo snap logs lxd -f

Reference