How to install software on Ubuntu with apt-get: a beginner's guide

Learn to install software on Ubuntu with apt-get step by step. Practical commands, package updates and solutions for the most common errors.

If you’re getting started on Ubuntu coming from Windows, the first question that comes up is simple: how do I install a program? There is no .exe installer, no “Next, Next, Finish” — instead, you use the terminal and a package manager called APT (Advanced Package Tool). And once you understand how it works, it becomes a lot faster than the Windows way.

This tutorial is for people who have never used Linux on a server or desktop and want to learn the essential command: apt-get. We’ll cover what a package manager is, how to install and remove software, how to update everything at once, and the most common errors you’ll run into in the first few days. Estimated time: 15 to 20 minutes reading calmly and testing the commands.

The good news: after this guide, installing any software on Ubuntu becomes a one-line command. The bad news: you’ll have to forget a few Windows habits.

Prerequisites

What you need

An Ubuntu 22.04 LTS or 24.04 LTS instance running — it can be desktop, WSL2 on Windows or a VPS via SSH. Access to a user with sudo permission. Active internet connection (apt-get downloads everything from online repositories).

If you’re on a freshly provisioned VPS, connect over SSH before continuing:

SSH command ssh user@server-ip
Default port 22
Tested system Ubuntu 24.04 LTS

What apt-get is and why it exists

On Windows, every program brings its own installer, its own DLLs, and it’s up to you to manage versions and updates manually. On Ubuntu (and on every Debian-based distribution), there is a different approach: a central repository holds thousands of pre-tested packages, and a package manager downloads, installs, updates and removes those packages for you — along with all their dependencies.

apt-get is that package manager. It talks to remote servers (repositories) listed in /etc/apt/sources.list, downloads the required .deb files and installs them in the right place on the system. You don’t decide where the program ends up — the package already carries that information.

There are two nearly identical commands: apt and apt-get. apt is newer, friendlier, with a colored progress bar. apt-get is the original, more verbose, and considered more stable for scripts. We use apt-get in this guide because it’s the recommended standard to learn — but everything here works if you replace it with apt.

Updating the package index

Before installing anything, you need to update the local list of available packages. This is the part that confuses beginners most: the command does not upgrade software — it only downloads the latest list of what exists in the repositories. It’s like updating a store’s catalog before placing an order.

01

Update the package index:

sudo apt-get update

sudo is needed because the command writes to /var/lib/apt/lists/, which belongs to root. You’ll see a list of URLs being queried (Hit, Get, Ign) — that’s normal. At the end, something like Reading package lists... Done appears.

02

Check how many packages have updates available:

apt list --upgradable

This command doesn’t need sudo because it only reads the local cache. If a list with several packages appears, your system is outdated and it’s a good idea to run an upgrade (next section).

Run update before any install

If you haven’t run apt-get update in weeks, apt-get install can fail with a 404 error — because the version it’s trying to download has already been replaced by a newer one on the servers. On production servers, run update at least once a week.

Installing a program

Now the part you came for. We’ll install two common programs as examples: curl (a command-line HTTP client, useful for downloading files and testing APIs) and htop (an interactive process monitor, much nicer than the default top).

01

Install the curl package:

sudo apt-get install curl

apt will show what will be installed, how much space it takes, and ask for confirmation with [Y/n]. Press Enter (the uppercase is the default) or type Y. If you want to skip the confirmation, use the -y flag:

sudo apt-get install -y curl

The -y flag is useful in scripts and automation, but while learning it’s better to see what’s going to be installed before confirming.

02

Install multiple packages at once:

sudo apt-get install -y htop git unzip

You can list as many packages as you want separated by spaces. apt resolves every dependency in a single transaction — faster than installing one by one.

03

Confirm the program is installed:

curl --version
htop --version

If the command answers with the version, it’s installed and working. If command not found appears, something failed — jump to the troubleshooting section.

Searching for packages by name

You don’t always know the exact package name. For example: to install the Nginx web server, the package is named nginx. But to install PHP 8.3, it could be php8.3-fpm, php8.3-cli or other names — depending on which variant you want.

01

Search by keyword:

apt search nginx

A list of every package mentioning “nginx” in the name or description will appear. The output can be long — use apt search nginx | less to paginate.

02

See details for a specific package before installing:

apt show nginx

This shows the current version, download size, installed size, dependencies, official website link and full description. Useful to decide if it’s the right package before spending bandwidth on the download.

Updating installed software

Unlike Windows, on Ubuntu you update every installed program with a single command — including the operating system itself.

01

Update the index (always first):

sudo apt-get update
02

Apply the updates:

sudo apt-get upgrade

apt shows which packages will be updated, how much extra space they’ll take, and asks for confirmation. To run without prompting, use sudo apt-get upgrade -y.

dist-upgrade vs upgrade

apt-get upgrade is conservative — it doesn’t remove or install new packages to resolve conflicts. If an update needs deeper changes (new kernel, replaced packages), use sudo apt-get dist-upgrade. On production servers, run dist-upgrade during a maintenance window, since it can restart services.

Removing software

01

Remove a program keeping its configuration:

sudo apt-get remove package-name

This uninstalls the program but preserves configuration files in /etc/. Useful if you plan to reinstall later with the same configs.

02

Remove a program wiping everything:

sudo apt-get purge package-name

purge also deletes the configuration files. Use when you want a complete cleanup.

03

Clean up orphan dependencies:

sudo apt-get autoremove

When you install a package, apt also installs its dependencies. When you remove that package, the dependencies stay — because they might be used by others. autoremove deletes the ones that aren’t being used by anyone anymore.

Final verification

To confirm everything is working, let’s check the overall state:

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove -y

This one-liner refreshes the index, applies pending upgrades and cleans up orphans — it’s the command many people run weekly on servers. The && makes the next command only run if the previous one finishes without error.

If the final output says 0 upgraded, 0 newly installed, 0 to remove, your system is fully up to date.

Troubleshooting

Error “Could not get lock /var/lib/dpkg/lock”

This error happens when another apt process is running at the same time — usually unattended-upgrades, which performs automatic updates in the background. Wait a few minutes and try again.

If it persists, check active processes:

ps aux | grep -i apt
Don't delete the lock manually without checking

Forcing sudo rm /var/lib/dpkg/lock-frontend while another apt is running corrupts the package database and can leave the system in an unusable state. Only do this if you’re absolutely certain no apt process is active.

Error “Unable to locate package”

It usually means one of two things: either you typed the wrong package name (try apt search), or your index is outdated. Run sudo apt-get update and try again.

In some cases, the package exists but only in extra repositories (universe, multiverse) that aren’t enabled. Enable them with:

sudo add-apt-repository universe
sudo apt-get update

404 error when downloading packages

It means the version indexed locally no longer exists on the server — someone updated the repository after your last apt-get update. The fix is simple: run sudo apt-get update again to fetch the current index.

Next steps

Now that you’ve got the basics of apt-get down, it’s worth exploring:

  • PPA repositories: add third-party sources to install software outside the official repos (add-apt-repository).
  • Package pinning: lock specific versions via /etc/apt/preferences.d/ to avoid unwanted upgrades in production.
  • Unattended-upgrades: configure automatic security updates on headless servers.
  • Snap and Flatpak: alternative managers for desktop apps with sandboxing — they complement apt rather than replace it.
  • dpkg: the low-level manager behind apt. Useful for installing manually downloaded .deb files (sudo dpkg -i package.deb).

If you’re learning Ubuntu to put an application into production, a Hostini VPS with Ubuntu 24.04 LTS pre-installed already comes with apt-get configured, universe repositories enabled and SSH access ready — you skip the OS install step and go straight to running your commands.

Frequently asked questions

What's the difference between apt and apt-get?

apt is a newer, friendlier interface that combines functions from apt-get and apt-cache into a single command, with progress bar and colored output. apt-get is still the recommended standard for scripts and automation because its output is stable across versions. For interactive terminal use, prefer apt; for shell scripts, stick with apt-get.

Why do I need to run sudo apt update before installing?

The apt update command does not upgrade software — it only downloads the latest list of packages available in the repositories. Without it, apt-get install can fail with 404 errors trying to fetch a version that has already been replaced on the servers, or install an outdated version. On active servers, run apt update at least once a week.

What should I do when I see 'Could not get lock /var/lib/dpkg/lock'?

It means another apt process is already running — usually unattended-upgrades in the background. Wait a few minutes and try again. If it persists, check with ps aux | grep -i apt and only remove the lock manually (sudo rm /var/lib/dpkg/lock-frontend) if you're certain no apt process is active, otherwise you'll corrupt the package database.

How do I find the exact name of the package I want to install?

Use apt search keyword to search the repositories. For example, apt search firefox lists all available variants with a short description. If you want full details for a specific package, use apt show package-name — it shows version, dependencies, size and project homepage.

Can I install software that isn't in the official repositories?

Yes, but with caution. You can add PPA repositories (Personal Package Archive) or third-party repositories like Docker and Node.js. Always confirm the repository comes from the project's official source and add the corresponding GPG key. Untrusted repositories can install malicious packages with root privileges.

How do I remove software installed via apt-get?

Use sudo apt remove package-name to uninstall while keeping configuration files, or sudo apt purge package-name to wipe everything, including configs in /etc. Then run sudo apt autoremove to clean up orphan dependencies that were left behind by the removed package.

Topics:
Next steps Ryzen cloud with NVMe storage and always-on DDoS protection.Go live on a Hostini VPS →
Was this tutorial helpful?
Chat on WhatsApp