Maîtriser apt install sur Ubuntu : Guide complet de la gestion des paquets, des mises à jour et du dépannage

1. Introduction

When using Ubuntu, the apt install command is essential for installing and managing software. With this command, you can easily install applications from package repositories.

This article provides a complete guide—from basics to advanced usage, troubleshooting, and frequently asked questions—so that beginners and intermediate users alike can smoothly manage packages in Ubuntu.

2. What Is the apt Command?

What is apt?

apt (Advanced Package Tool) is a command-line utility used for package management on Ubuntu and Debian-based Linux distributions. Using APT allows you to perform the following actions:

  • Install software
  • Update software
  • Remove unnecessary software
  • Resolve dependency issues

Package management on Ubuntu is primarily carried out using the apt command.

Difference Between apt and apt-get

Previously, apt-get was the standard tool, but apt is now recommended. Their differences are summarized in the following table:

CommandCharacteristics
aptMore user-friendly with improved progress indicators
apt-getLegacy command offering more granular control (advanced users only)

Use apt for basic package management, and switch to apt-get when performing specific advanced operations.

3. Basic apt Operations

Update the Package List

Before installing software, update the package list to ensure the latest information is available.

sudo apt update

This command refreshes the list of available software for the Ubuntu package manager.
Tip: If you install software with outdated package information, the latest versions may not be retrieved—so run this command regularly.

Install a Package

Use the following command to install new software:

sudo apt install package-name

For example, to install curl:

sudo apt install curl

During installation, a message such as “This package requires XX MB. Continue?” will appear. Press “Y” to proceed.

Remove a Package

To remove software you no longer need, use the following command:

sudo apt remove package-name

For example, to remove curl:

sudo apt remove curl

To completely delete a package along with its configuration files, use:

sudo apt purge package-name

4. Advanced apt Usage

Upgrade a Specific Package

You can upgrade only a specific package without updating the entire system:

sudo apt install --only-upgrade package-name

Example – Upgrade vim:

sudo apt install --only-upgrade vim

Automatically Remove Unnecessary Packages

To remove unused packages installed as dependencies, run:

sudo apt autoremove

View Package Details

Check detailed information about a package using:

apt show package-name

Example – View details for git:

apt show git

List Installed Packages

To display all installed packages, run:

apt list --installed

5. Troubleshooting

Dependency Issues

If you encounter dependency problems when installing a package, try the following command:

sudo apt install -f

This command fixes broken dependencies.

Add or Remove Repositories

To install software that requires a specific repository, add it using:

sudo add-apt-repository ppa:repository-name
sudo apt update

To remove a repository you no longer need:

sudo add-apt-repository --remove ppa:repository-name
sudo apt update

6. FAQ

Should I use apt or apt-get?

On modern Ubuntu systems, apt is recommended.

Difference Between apt update and apt upgrade

  • apt update → Updates the package list
  • apt upgrade → Upgrades installed packages to the latest versions

How to Upgrade Only a Specific Package

Use the following command:

sudo apt install --only-upgrade package-name

Check Where a Package Is Installed

You can verify the installation location with:

dpkg -L package-name

Check the Repository Source of a Package

Utilisez la commande suivante :

apt-cache policy package-name

7. Conclusion

Cet article a expliqué tout, depuis l’utilisation de base de apt install sur Ubuntu jusqu’aux techniques avancées et au dépannage.
En maîtrisant la commande apt, vous pouvez gérer votre environnement Ubuntu de manière plus efficace.

📌 Lien de référence :

Continuez à en apprendre davantage sur Ubuntu pour atteindre une administration système efficace et optimisée !