LearnAI ToolsCareerPractice BuildsPlayDevelopmentContact
Lesson 1012 min read

Installing Software with apt

Install, update and remove software on Ubuntu and Debian with apt, understand repositories and dependencies, and meet dnf, snap and Homebrew.

On this page 11 sections

Introduction

On Linux you rarely download installers from websites. Instead, a package manager installs software from trusted online repositories with a single command, handles everything the software depends on, and keeps it all updated. On Ubuntu and Debian that package manager is apt.

What You Will Learn
  • What packages, repositories and dependencies are.
  • How to refresh package lists, search, install and remove software.
  • How to keep the whole system up to date.
  • The equivalent commands on other systems.

Packages and Repositories

  • A package is a bundle containing a program and information about it: its version, description and what else it needs.
  • A repository is an online collection of packages maintained by your distribution. Ubuntu’s repositories hold tens of thousands of packages that have been built and checked for your exact system.
  • Dependencies are other packages a program needs in order to run. apt installs them automatically.

Updating the Package List

apt update downloads the latest list of available packages and versions. It does not install or upgrade anything; it just makes sure apt knows what exists. Run it before installing, because installing from an old list can fail. Changing system software needs sudo:

sudo apt update
Output

Click Run to see what this code prints.

Each Get: line is a list downloaded from a repository. The last line says that 2 installed packages have newer versions available — you will upgrade them shortly.

Priya wants jq, a tool for reading JSON data in the terminal. apt search finds packages; --names-only searches just their names:

apt search --names-only "^jq$"
Output

Click Run to see what this code prints.

apt show displays details about a package before you install it:

apt show jq | head -n 6
Output

Click Run to see what this code prints.

Installing a Package

sudo apt install -y jq
Output

Click Run to see what this code prints.

apt worked out that jq needs two libraries (libjq1 and libonig5), downloaded all three and set them up. Without -y, it shows the plan and asks you to confirm with Y first. The new command works straight away:

jq --version
echo '{"name": "Priya", "skills": ["git", "linux"]}' | jq '.skills[0]'
Output

Click Run to see what this code prints.

apt list --installed jq
Output

Click Run to see what this code prints.

Mini Challenge · Put It in Order

Put the steps of installing a new tool with apt in order.

  1. apt search <name> to find the exact package
  2. apt show <package> to check it is the right one
  3. sudo apt install <package>
  4. Run the new command to confirm it works
  5. sudo apt update

Upgrading and Removing

To see which installed packages have updates waiting:

apt list --upgradable
Output

Click Run to see what this code prints.

sudo apt upgrade installs all available updates, including security fixes — run sudo apt update && sudo apt upgrade regularly. To uninstall a package, use remove:

sudo apt remove -y jq
Output

Click Run to see what this code prints.

jq --version
Output

Click Run to see what this code prints.

apt noticed the two libraries are no longer needed by anything; sudo apt autoremove cleans them up. apt purge removes a package together with its configuration files.

CommandWhat it does
sudo apt updateRefresh the list of available packages
sudo apt upgradeInstall updates for everything already installed
apt search <word>Search for packages
apt show <package>Show details about a package
sudo apt install <package>Install a package and its dependencies
sudo apt remove <package>Uninstall a package (keeps config files)
sudo apt purge <package>Uninstall and delete its config files
sudo apt autoremoveRemove dependencies nothing needs any more
Mini Challenge · Predict the Output

You run sudo apt update and it finishes successfully. What has changed on your system?

Choose one answer

Other Package Managers

SystemToolInstall example
Ubuntu, Debianaptsudo apt install jq
Fedora, RHEL, Rockydnfsudo dnf install jq
Alpine (common in Docker)apkapk add jq
Archpacmansudo pacman -S jq
macOSHomebrewbrew install jq
Many distributionssnap / flatpaksudo snap install <app> (self-contained apps)

Programming languages have their own package managers too — pip for Python, npm for JavaScript — which install libraries for your projects rather than system programs.

Common Mistakes

Avoid These Mistakes
  • Skipping apt update and getting “Unable to locate package” or download errors.
  • Downloading random .deb files or install scripts from websites instead of using the repositories.
  • Never running apt upgrade, leaving known security holes unpatched.
  • Mixing up update (refresh the list) and upgrade (install new versions).

Frequently Asked Questions

apt is the newer, friendlier command for people; apt-get is the older one that scripts often use because its output never changes. They install the same packages.

Ubuntu freezes versions for each release and then only adds security and bug fixes, which keeps the system stable. For the very latest version of a tool, projects often provide their own repository, a snap or a container image.

No. Reading information (search, show, list) works without sudo; changing the system (update, install, upgrade, remove) needs it.

Key Takeaways

  • apt installs software from your distribution’s trusted repositories, with dependencies.
  • sudo apt update refreshes package lists; sudo apt upgrade installs updates.
  • apt search and apt show help you find the right package.
  • sudo apt install / remove / purge / autoremove manage what is installed.
  • Other systems use dnf, apk, pacman or brew with the same ideas.

Summary

You can now install and maintain software like a Linux administrator. Next you will look at how the shell itself is configured: environment variables, the PATH, and your personal .bashrc.

Next Lesson →

Environment Variables, PATH and .bashrc