Games

How to install programs via the terminal on Ubuntu 18.04 (apt and snap)

Introduction

In the world of Ubuntu and Linux distributions, the terminal is an invaluable tool for experienced users and novices alike. From managing files to installing software, the command line interface (CLI) offers a powerful and efficient way to interact with your system. Among the multitude of tasks you can perform in the terminal, installing software via package managers is one of the most common and important. This article aims to provide a comprehensive guide on how to install programs on Ubuntu 18.04 using two of the most popular package management systems: apt and snap. We will walk you through step-by-step instructions, offer tips and best practices, and highlight some useful commands.

Understanding Package Management in Ubuntu

What is a Package Manager?

A package manager is a tool that simplifies the process of installing, updating, and removing software on a computer. In the Linux environment, package managers handle the complexities involved in software installation, such as resolving dependencies and streamlining the update process. Ubuntu 18.04 uses two primary package management systems: apt (Advanced Package Tool) and snap.

APT vs. Snap: What’s the Difference?

While both apt and snap serve the purpose of installing software, they function in different ways:

  • APT: APT is the traditional package manager for Debian-based systems, including Ubuntu. It installs software from repositories, which are collections of software packages maintained by the community or the operating system developers. APT focuses on system-level applications and libraries.

  • Snap: Snap, on the other hand, is a relatively newer package management system developed by Canonical, the company behind Ubuntu. Snap packages, or “snaps,” contain all the necessary dependencies bundled together, making them easier to distribute and install across various Linux distributions. This form of packaging enhances portability and isolation from the system environment.

See also  Kubuntu 21.04 Beta

Installing Software using APT

Step 1: Update Your Package Index

Before installing any software, it’s crucial to ensure that your package index is up to date. Open your terminal and run the following command:

bash
sudo apt update

This command updates the list of available packages and their versions. It does not install any new packages or upgrade the existing ones.

Step 2: Upgrade Installed Packages

While not strictly necessary every time you install a new program, it’s a good practice to keep your system updates current. You can upgrade all outdated packages with:

bash
sudo apt upgrade

Confirm the installation when prompted.

Step 3: Install Software

To install software using APT, you simply use the install command followed by the software name. For example, if you want to install the text editor vim, you would type:

bash
sudo apt install vim

Step 4: Verify Installation

Once the installation is complete, you can verify that the software has been installed by checking its version:

bash
vim –version

Depending on the software, you can also run it to ensure it launches correctly.

Common APT Commands

  • Remove a Package: To uninstall a package, you can use the remove command. For example:

    bash
    sudo apt remove vim

  • Search for Packages: To find software packages available for installation, use the search command, like this:

    bash
    apt search

  • Get Package Information: If you want more details about a specific package, use:

    bash
    apt show

Installing Software using Snap

Unlike APT, installing software through Snap is typically straightforward and often involves fewer steps. Here’s how to get started:

Step 1: Install Snapcraft (If Necessary)

Snap comes pre-installed on Ubuntu 18.04, but if for some reason it’s missing, you can install it:

bash
sudo apt install snapd

Step 2: Search for Snap Packages

Before installation, you may want to search for available snap packages. Use the following command:

bash
snap find

For example, to find vlc, you would type:

bash
snap find vlc

Step 3: Install a Snap Package

To install a snap package, simply use the install command followed by the package name. For instance, to install VLC media player, you can execute:

bash
sudo snap install vlc

Step 4: Launch the Application

After the snap installation is complete, you can usually find the application in your system’s launcher. You can also run it directly from the terminal by typing:

bash
vlc

Common Snap Commands

  • Remove a Snap Package: To uninstall a package, use:

    bash
    sudo snap remove

  • List Installed Snaps: To see which snap packages you have installed, type:

    bash
    snap list

  • Update Snap Packages: Snaps are automatically updated, but if you want to manually trigger an update, use:

    bash
    sudo snap refresh

Additional Tips for Efficient Software Management

1. Utilize the --assume-yes Option

When running commands, especially for installations, you might want to avoid the confirmation prompts. You can achieve this by adding the --assume-yes option. For example:

bash
sudo apt install –assume-yes

2. Keeping APT Clean

Occasionally, the APT package manager may accumulate unnecessary files. You can use the following command to clean up:

bash
sudo apt autoremove

This command will remove unused packages and free up space.

3. Switch Between Package Managers

Some applications may be available as both deb packages (for APT) and snaps. In such cases, it is often recommended to choose one method to avoid conflicts. Typically, snaps are preferred for their dependency isolation, while APT remains a favorite for stability.

Conclusion

Installing software on Ubuntu 18.04 via the terminal using APT and Snap is both straightforward and efficient. While APT lets you manage system-level applications seamlessly, Snap provides portability and ease of use for modern applications. By mastering these tools, you’ll enhance your ability to customize and optimize your Ubuntu experience, taking full advantage of all that the Linux ecosystem has to offer.

Frequently Asked Questions (FAQ)

1. Can I install both APT and Snap packages on the same system?

Yes, you can install applications using both APT and Snap on the same Ubuntu system without any issues. Just be cautious about the version conflicts that might arise.

2. Is Snap slower than APT when it comes to installation?

Generally, Snap installations might be slightly slower due to the packaging system involving more dependencies and isolation. However, this is often offset by the improved stability and security.

3. How do I remove a Snap package that I no longer need?

To uninstall a Snap package, use the command sudo snap remove <package-name>, replacing <package-name> with the actual name of the application you wish to remove.

4. What if a package is not found in the APT or Snap repository?

If a package is not available in the default repositories, you may need to look for alternative PPAs (Personal Package Archives) for APT or explore other Snap sources. Always ensure that you trust the sources you are using.

5. Are there advantages to using the command line over graphical interfaces?

Using the command line can be quicker and more efficient for those familiar with it. It provides more flexibility, allows for batch operations, and is especially useful on systems without graphical environments.

See also  How to install Runescape on a Chromebook

About the author

Jeffrey Collins

Jeffrey Collins

Jeffery Collins is a Microsoft Office specialist with over 15 years of experience in teaching, training, and business consulting. He has guided thousands of students and professionals in mastering Office applications such as Excel, Word, PowerPoint, and Outlook. From advanced Excel functions and VBA automation to professional Word formatting, data-driven PowerPoint presentations, and efficient email management in Outlook, Jeffery is passionate about making Office tools practical and accessible. On Softwers, he shares step-by-step guides, troubleshooting tips, and expert insights to help users unlock the full potential of Microsoft Office.