Snap Command Guide
The snap command is a powerful tool for managing software packages on Linux distributions that support Snapcraft, most notably Ubuntu. It allows users to easily find, install, update, and remove applications in a sandboxed environment, ensuring system stability and security. This guide provides a comprehensive overview of common snap commands and their usage.
Finding and Installing Snaps
Before installing a snap, you can search for available packages and view detailed information about them.
Searching for Packages
To find a specific package in the Snap Store:
snap find <package>
Viewing Package Information
To get detailed information about a package, including its version, description, and available channels:
snap info <package>
Installing Snaps
To install a snap package:
sudo snap install <package>
You can also install from specific channels, such as beta:
sudo snap install <package> --channel=beta
Managing Installed Snaps
Once snaps are installed, you can manage them through various commands.
Listing Installed Snaps
To see all snaps currently installed on your system:
snap list
To view all revisions of installed snaps, including older ones:
snap list --all
Updating Snaps
To manually update all installed snaps:
sudo snap refresh
To update a specific snap:
sudo snap refresh <package>
To update a snap to a specific channel:
sudo snap refresh <package> --channel=beta
Reverting Snaps
If an update causes issues, you can revert to a previous version:
sudo snap revert <package>
To revert to a specific revision number:
snap revert <package> --revision 5
Removing Snaps
To uninstall a snap package:
sudo snap remove <package>
Authentication and Transactions
Snapcraft requires authentication for certain operations and provides tools to track transactions.
Logging In and Out
To log in to your Snapcraft account (you must create an account online first):
sudo snap login
To log out:
snap logout
Transaction Management
To view a summary of recent snap transactions:
snap changes
To view details of a specific transaction (e.g., item 123):
snap change 123
To watch a transaction in real-time:
snap watch 123
To abort an ongoing transaction:
snap abort 123
Advanced Installation and Development
For developers or advanced users, snap offers options for downloading and installing snaps manually.
Downloading Snaps
To download a snap package and its assertions without installing it:
snap download <package>
Installing Local Snaps
To install a locally downloaded snap with its assertions:
snap ack foo.assert
snap install foo.snap
To install a local snap without assertions (use with caution, as integrity is not verified):
snap install --dangerous foo.snap
Development Modes
For development purposes, you can install snaps in devmode or classic mode:
snap install --devmode foo
snap install --classic foo
Snap Interfaces and Permissions
Snaps use interfaces to manage permissions and access system resources.
Viewing Interfaces
To see available snap interfaces:
snap interfaces
Connecting and Disconnecting Interfaces
To connect a snap's plug to a slot (e.g., connecting foo:camera to :camera):
snap connect foo:camera :camera
To disconnect an interface:
snap disconnect foo:camera
Enabling, Disabling, and Setting Properties
You can control the state and configuration of snaps.
Enabling and Disabling Snaps
To disable a snap (stops it from running):
snap disable foo
To enable a disabled snap:
snap enable foo
Setting and Getting Properties
To set a property for a snap (e.g., setting bar to 10 for snap foo):
snap set foo bar=10
To read a snap's property:
snap get foo bar
For more information on Snapcraft and the snap command, refer to the official Snapcraft documentation.