0
0
Linux-cliHow-ToBeginner · 3 min read

How to Use Snap Command in Linux: Syntax and Examples

The snap command in Linux is used to install, update, and manage snap packages, which are self-contained software packages. You can use commands like snap install, snap remove, and snap list to manage snaps easily from the terminal.
📐

Syntax

The basic syntax of the snap command is snap [command] [options] [package]. Here are common parts explained:

  • command: The action you want to perform, like install, remove, or list.
  • options: Extra flags to modify behavior, such as --classic for classic confinement.
  • package: The name of the snap package you want to manage.
bash
snap install <package-name>
sudo snap remove <package-name>
snap list
snap refresh <package-name>
💻

Example

This example shows how to install the vlc media player using snap, list installed snaps, and then remove it.

bash
sudo snap install vlc
snap list
sudo snap remove vlc
Output
vlc 3.0.18 snap installed Name Version Rev Tracking Publisher Notes vlc 3.0.18 2344 stable videolan✓ - vlc removed
⚠️

Common Pitfalls

Some common mistakes when using snap include:

  • Not using sudo for commands that require admin rights like install or remove.
  • Trying to install a snap package that does not exist or is misspelled.
  • Ignoring confinement options like --classic when needed, which can cause the snap to not work properly.
bash
snap install vlc
# Wrong: missing sudo, may fail
sudo snap install vlc --classic
# Right: use sudo and classic confinement if required
📊

Quick Reference

CommandDescription
snap install Install a snap package
snap remove Remove a snap package
snap listList installed snap packages
snap refresh Update a snap package
snap find Search for snap packages
snap info Show details about a snap package

Key Takeaways

Use sudo with snap commands that change system state like install or remove.
The snap command manages self-contained software packages called snaps.
Common commands include install, remove, list, and refresh.
Use snap find to search for available snap packages.
Remember to use confinement options like --classic when the snap requires broader system access.