How to Use the Command 'snap' (with Examples)
- Linux
- December 17, 2024
The snap
command is a powerful tool designed for managing “snap” packages—self-contained software applications that simplify installation and improve security. Much like the apt
command for .deb
packages, snap
manages the installation, removal, and updating of software on your system. This modern package management system is designed to alleviate dependency issues and ease the deployment of both the software and its required libraries across different Linux distributions. Below are several use cases illustrating how to effectively use the snap
command with practical examples.
Use Case 1: Search for a Package
Code:
snap find query
Motivation: Searching for a package is often the first step when looking to install new software. This command helps you find snap packages available in the snap store based on a specific query. Whether you are looking for a text editor, a graphics software, or any other application, this command helps you identify the exact package name you need.
Explanation:
snap
: The command-line interface for managing snap packages.find
: The subcommand used to search the snap store.query
: A keyword or name related to the software you are interested in. This can be partial if you are unsure of the full name.
Example Output:
Name Version Developer Notes Summary
vlc 3.0.11.1 videolan - The VLC media player
chromium 87.0.4280 canonical - Chromium web browser, open-source version of Chrome
Use Case 2: Install a Package
Code:
snap install package
Motivation: Once you’ve found the application you need, the next logical step is to install it. Installing through snap ensures that you get the latest packaged version without the hassles of dependency conflicts.
Explanation:
snap
: The command indicating access to snap’s feature set.install
: The subcommand used to download and install a package from the snap store.package
: The name of the package you wish to install, previously identified using thesnap find query
command.
Example Output:
vlc 3.0.11.1 from VideoLAN✓ installed
Use Case 3: Update a Package
Code:
snap refresh package
Motivation: Updating your installed packages ensures you have the latest features and security fixes. Regularly refreshing your snap packages keeps your software in alignment with the latest developments and patches provided by the developers.
Explanation:
snap
: The base command for managing snaps.refresh
: This subcommand signals an update operation.package
: The specific application you wish to update to its latest version.
Example Output:
vlc (stable) 3.0.12 from VideoLAN✓ refreshed
Use Case 4: Update a Package to Another Channel
Code:
snap refresh package --channel=channel
Motivation: Sometimes you may want to test a beta version of an application or need a specific branch for compatibility reasons. This command allows you to switch between different release channels such as stable, beta, edge, etc.
Explanation:
snap
: The snapshot manager.refresh
: Initiates an update.package
: The name of the software you’re updating.--channel=channel
: Specifies the release channel. For instance, stable, candidate, beta, or edge, allowing for different levels of testing and stability.
Example Output:
vlc (beta) 4.0.0-beta1 from VideoLAN✓ refreshed
Use Case 5: Update All Packages
Code:
snap refresh
Motivation: To streamline your system’s software routine, updating all snap packages at once is efficient. This ensures your entire suite of snap applications receives the latest updates all at one go.
Explanation:
snap
: Command interface for interacting with snap packages.refresh
: Without specifying a package, this targets all installed packages, updating them to their latest versions.
Example Output:
All snaps up-to-date.
Use Case 6: Display Basic Information About Installed Snap Software
Code:
snap list
Motivation: When managing different software applications and ensuring that everything is up-to-date, having a comprehensive list of installed snap packages is invaluable. This helps you track which applications are snap-managed and review their current versions.
Explanation:
snap
: The interface for snap commands.list
: Retrieves and displays a list of all snap packages currently installed on the system.
Example Output:
Name Version Rev Tracking Publisher Notes
core 16-2.40 7917 latest/stable canonical✓ core
vlc 3.0.11.1 1700 latest/stable videolan✓ -
Use Case 7: Uninstall a Package
Code:
snap remove package
Motivation: Removing unused or unwanted applications is crucial for maintaining system space and resources. This command is essential when you decide you no longer need a particular snap package.
Explanation:
snap
: Command line facilitator for managing snaps.remove
: Subcommand indicating the user’s intent to uninstall.package
: The specific software package you wish to remove.
Example Output:
vlc removed
Use Case 8: Check for Recent Snap Changes in the System
Code:
snap changes
Motivation: Staying informed about what’s happening with your system’s software can help troubleshoot issues or verify updates. This command provides a history of recent changes, which is crucial for system administrators and users who need to track modifications.
Explanation:
snap
: The operating command for snap package management.changes
: A query to fetch recent changes, installations, removals, and updates to snap packages.
Example Output:
ID Status Spawn Ready Summary
29 Done today at 00:12 - UTC today at 00:13 - UTC Auto-refresh snap "core"
30 Done today at 00:12 - UTC today at 00:12 - UTC Remove "vlc" snap
Conclusion
The snap
command-line tool is versatile and crucial for managing snap packages efficiently. From searching for new software, installing, updating, and removing packages to viewing updates and managing channels, these examples ensure that users leverage the full power of snap packages to maintain an up-to-date and efficient system. Whether you are engaged in personal use or responsible for system administration, mastering these commands equips you with the knowledge to manage applications confidently and securely.