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 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 updateClick 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.
Searching for Software
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$"Click Run to see what this code prints.
apt show displays details about a package before you install it:
apt show jq | head -n 6Click Run to see what this code prints.
Installing a Package
sudo apt install -y jqClick 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 --versionecho '{"name": "Priya", "skills": ["git", "linux"]}' | jq '.skills[0]'Click Run to see what this code prints.
apt list --installed jqClick Run to see what this code prints.
Put the steps of installing a new tool with apt in order.
- apt search <name> to find the exact package
- apt show <package> to check it is the right one
- sudo apt install <package>
- Run the new command to confirm it works
- sudo apt update
Upgrading and Removing
To see which installed packages have updates waiting:
apt list --upgradableClick 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 jqClick Run to see what this code prints.
jq --versionClick 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.
| Command | What it does |
|---|---|
| sudo apt update | Refresh the list of available packages |
| sudo apt upgrade | Install 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 autoremove | Remove dependencies nothing needs any more |
You run sudo apt update and it finishes successfully. What has changed on your system?
Other Package Managers
| System | Tool | Install example |
|---|---|---|
| Ubuntu, Debian | apt | sudo apt install jq |
| Fedora, RHEL, Rocky | dnf | sudo dnf install jq |
| Alpine (common in Docker) | apk | apk add jq |
| Arch | pacman | sudo pacman -S jq |
| macOS | Homebrew | brew install jq |
| Many distributions | snap / flatpak | sudo 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
- 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.