Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Install and remove software on Linux

By updated

Improve this page

To install software on Linux, a single command is enough: sudo apt install name (Debian/Ubuntu) or sudo dnf install name (RHEL/Fedora). This guide shows you how to search for, install, check and remove packages with confidence.

What you will learn

  • Refresh the list of packages available
  • Search for a package by name or keyword
  • Install a package and check that it works
  • Remove a package cleanly
  • List the packages already installed

How do you refresh the package list?

Before any installation, you must refresh the list of available packages. Without this step, your system does not know the latest versions, and may not even know a package exists.

Terminal window
sudo apt update
Expected output
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Reading package lists... Done

This command changes nothing on your system. It only downloads the up-to-date list of available packages and versions.

Get into the habit of running apt update, or dnf check-update, before each installation session. Without this refresh, your machine works on an out-of-date catalogue: it may install an outdated version, or refuse a package that is actually available with an E: Unable to locate package that seems incomprehensible.

How do you search for a package?

You do not know the exact name of the package? Use the search, which looks through names and descriptions:

Terminal window
apt search text editor

To show the details of a package you found:

Terminal window
apt show vim
Output (excerpt)
Package: vim
Version: 2:9.1.0016-1ubuntu7.20
Description: Vi IMproved - enhanced vi editor

Search in English: package descriptions are written in English, and a search in another language usually returns nothing. On Ubuntu 24.04, the French words apt search editeur texte find no result, where apt search text editor finds 96 (measured).

Remember too that the package name does not always match the software name. The Vim editor installs from vim on Debian and from vim-enhanced on RHEL, and the case is frequent as soon as a piece of software is split into several packages. That is precisely what search is for: running it before install costs a few seconds and avoids a No match for argument.

How do you install a package?

The three steps below go from the installation itself to the check that the command works, then to the package that provides it.

  1. Start the installation with sudo (packages are installed in system directories that require administrator rights):

    Terminal window
    sudo apt install tree

    APT shows the list of packages that will be installed:

    Output on Ubuntu 24.04
    The following NEW packages will be installed:
    tree
    0 upgraded, 1 newly installed, 0 to remove and 92 not upgraded.

    When only the requested package is added, APT installs it without asking. As soon as it must add dependencies, it lists them and asks for confirmation: type Y (or Enter) to accept.

  2. Check that the installation worked:

    Terminal window
    tree --version
    Output on Ubuntu 24.04
    tree v2.1.1 (c) 1996 - 2023 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro

    If the command prints a version number, the software is installed.

  3. Check which package provides a command (useful when the name differs):

    Terminal window
    dpkg -S "$(command -v tree)"
    Output
    tree: /usr/bin/tree

Install several packages at once

You can install several packages in the same command, separated by spaces:

Terminal window
sudo apt install wget tree htop

How do you remove a package?

Removing is as simple as installing, but APT offers two levels: keep the configuration files or delete them too.

Simple removal (keeps the configuration files):

Terminal window
sudo apt remove tree

Complete removal (also deletes the configuration files):

Terminal window
sudo apt purge tree

Check: the command must no longer be available:

Terminal window
tree --version
Expected output
bash: tree: command not found

If you had run tree in the same terminal before the removal, Bash answers bash: /usr/bin/tree: No such file or directory instead: it had remembered the path of the command. The package is really gone; hash -r clears that memory.

How do you list installed packages?

To see which software is already installed on your system, query the package database directly:

Terminal window
dpkg -l | head -20

To check whether a given package is installed:

Terminal window
dpkg -l tree

How do you reinstall a package?

If a piece of software no longer works properly, you can reinstall it without removing it first. The package files are put back in place, which repairs a deleted or damaged file:

Terminal window
sudo apt reinstall tree

Troubleshooting

These 5 symptoms cover almost every installation failure met at the start, and they have one thing in common: none comes from the package itself. The cause is almost always an out-of-date list, an inexact name, or a forgotten sudo. Read the left column as the exact message displayed, and try the fix on the right before looking further.

SymptomLikely causeFix
E: Unable to locate packagePackage list out of datesudo apt update then try again
No match for argumentWrong package nameCheck with dnf search keyword
E: Could not open lock file ... (13: Permission denied) (APT) or This command has to be run with superuser privileges (DNF)Command run without sudoAdd sudo in front of the command
Removal takes away too many packagesReverse dependenciesAnswer n, check the dependencies
Package installed but command not foundThe binary has another nameLook with dpkg -L name or rpm -ql name

Key points

  • Always apt update (or dnf check-update) before installing.
  • apt install / dnf install handle dependencies automatically.
  • apt search / dnf search find the right package name: search in English.
  • apt remove keeps the configuration; apt purge deletes everything.
  • Always read the summary before confirming an installation or a removal.
  • Check with command --version that the installation worked.

Knowledge check

Check that the essentials of this guide stuck. The questions cover only what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn