IT teams running workloads on Ubuntu Linux have not one but two software package managers to work with: snap and apt.
Although both snap and apt automate the installation, management, and removal of software packages, they work in different ways. An organization’s choice between snap and apt depends on its IT priorities.
What are instant bundles?
Snap is a package management system from Canonical, the company that develops the Ubuntu Linux distribution. Snapcraft is the official name of the system that manages snap packages, but the system is commonly referred to as snap. Although Snap was created for Ubuntu, it was extended in 2016 to support most popular Linux distributions.
Snap bundles an application as an archive containing the binary code, data, and libraries needed to run said application, including all external dependencies.
When you run the app, snap unpacks the archive and the app runs in a sandboxed environment — similar, but not identical to, a Docker container.
For example, to install the gedit text editor, you would use the command below.
snap install gedit
When you run this command, snap downloads the snap package for gedit from the snap repositories configured for your system. You can also remove installed snap packages with the snap delete gedit ordered.
What is fit?
Apt is a Linux package management tool used on Ubuntu and a variety of other Linux distributions. Introduced in 1998, apt has become a widely supported and popular option for installing, updating, and removing Linux software.
Apt manages Debian packages, known as debs. Like snaps, each deb contains the application code, data, and libraries needed to install an application. Debs also defines application dependencies, such as any other software the application needs to run. When you install a Debian package through apt, apt automatically installs the application’s dependencies.
Apt permanently installs data into Ubuntu’s file system, from which applications run. Applications run as standard processes directly on the host system, rather than in sandboxed environments.
And, like snap, apt installs packages using simple commands.
apt install gedit
Uninstall the package with the apt remove gedit ordered.
Differences between snap and apt
Snap and apt seem similar on the surface: they both allow application management via packages and let you install and remove software with simple commands. In fact, many snap and apt commands, such as install and remove commands, are identical.
Where snap and apt differ, however, is in how they package the software. Snap includes everything needed to run an app – including its dependencies – in a single package, but apt expects users to deploy dependencies as separate packages alongside the app package.
This may seem like a minor difference, but it has several important implications for how snap and apt software work:
- Software versions. Apt installs the software directly on your system, so you can only install one version of each application used. However, while there are ways to deal with conflicting application versions with apt, it’s not a clear or simple process. Snap makes it easy to install multiple app versions on the same system.
- Creating packages. Snap packages are easier to create than apt packages in that you can bundle dependencies into the package, rather than defining them and expecting the user’s system to have the correct dependencies.
- Parcel collection. Because all application data and dependencies in a snap-in package are self-contained, you can remove the entire application by deleting the snap-in. Although apt also deletes all data associated with an application, in most cases there is a risk that apt may fail to delete some data when you delete an application. It leaves cruelty on your system.
- Security. In some ways, snaps are more secure because they can run without root privileges, although snap expects root privileges by default to install snap packages on your system. Debs require root privileges. Theoretically, it’s possible to unpack a Debian package and run the data as a non-root user, but that’s not how packages work, and it will produce a plethora of errors and problems.
In all of these respects, snap provides a cleaner and simpler software management experience. On the other hand, apt packages also have their advantages. For one thing, they are smaller because they don’t bundle dependencies. Installing software with apt makes more efficient use of storage space. Applications installed via apt are also likely to start faster because application packages do not need to be unpacked before running. instead, packages unpack at install time.
Also, apt is an older and widely used package management system, which has some advantages. Snap is, at the time of publication, primarily bundled with Ubuntu, and while it may work on other distributions, it is not installed by default. If you want to create packages for use on multiple Linux distributions, apt is a better choice.
When to use snap or apt
Snap is a good choice for IT operations teams whose primary package management needs revolve around in-house built software. Because snap makes it easier to create packages and provides better control over package management and performance, it provides a smoother overall experience for IT teams that need to both build and deploy software, such as a combined DevOps team. Snap is also an option for use cases where an IT team cannot run software as the root user for security reasons, as discussed above.
Apt makes sense when most of the software you run on Ubuntu comes from third parties. Apt is also a better choice for businesses that run multiple types of Linux, given the support for apt in most Linux distributions.
But you can also use snap and apt simultaneously. They can run on the same system, but installing the same software in snap and Debian packages will waste resources.