1. Introduction
When using Ubuntu, the apt install
command is essential for installing and managing software. This command allows you to easily install software from the package repository.
In this article, we provide a detailed guide on apt install
, covering everything from basic usage to advanced applications, troubleshooting, and frequently asked questions. Whether you’re a beginner or an intermediate user, this guide will help you manage Ubuntu packages smoothly.
2. What is the apt Command?
What is apt?
apt
(Advanced Package Tool) is a command-line tool used for package management on Ubuntu and other Debian-based Linux distributions. With APT, you can perform the following operations:
- Install software
- Update software
- Remove unnecessary software
- Resolve dependencies
Ubuntu’s package management primarily relies on the apt
command.
Difference Between apt and apt-get
Previously, apt-get
was the standard command, but apt
is now recommended. The key differences are summarized in the table below:
Command | Features |
---|---|
apt | A newer, user-friendly command with improved progress display |
apt-get | A legacy command that offers more granular control (recommended for advanced users) |
For general package management, use apt
. If you need advanced control, apt-get
may be useful.

3. Basic apt Command Usage
Updating the Package List
Before installing software, update the package list to ensure you have the latest version information.
sudo apt update
Running this command refreshes Ubuntu’s package manager with the latest available software list.
Tip: If you install software without updating, you may not get the latest version. It’s recommended to run this command regularly.
Installing a Package
To install new software, use the following command:
sudo apt install package-name
For example, to install curl
, run:
sudo apt install curl
During installation, you will see a message indicating the package size and asking for confirmation. Press “Y” to proceed.
Removing a Package
To remove software you no longer need, use the following command:
sudo apt remove package-name
For example, to remove curl
, run:
sudo apt remove curl
If you want to remove the package along with its configuration files, use:
sudo apt purge package-name
4. Advanced apt Command Usage
Upgrading Specific Packages
Instead of upgrading the entire system, you can update a specific package to its latest version.
sudo apt install --only-upgrade package-name
Example: To upgrade vim
, run:
sudo apt install --only-upgrade vim
Removing Unused Packages Automatically
To clean up unnecessary packages that were installed as dependencies but are no longer needed, use the following command:
sudo apt autoremove
This helps free up disk space by removing redundant packages.
Displaying Package Details
To view detailed information about a package, use:
apt show package-name
Example: To check details of git
, run:
apt show git
Listing Installed Packages
To view all installed packages on your system, run:
apt list --installed
5. Common Troubleshooting
Dependency Issues
If you encounter dependency issues while installing a package, try running:
sudo apt install -f
This command attempts to fix broken dependencies.
Adding and Removing Repositories
Some software requires additional repositories. You can add a repository using:
sudo add-apt-repository ppa:repository-name
sudo apt update
To remove an unwanted repository, use:
sudo add-apt-repository --remove ppa:repository-name
sudo apt update
6. FAQ (Frequently Asked Questions)
Should I Use apt or apt-get?
For most users, apt
is recommended for a more user-friendly experience. However, advanced users may still prefer apt-get
for specific tasks.
What’s the Difference Between apt update
and apt upgrade
?
apt update
→ Updates the package listapt upgrade
→ Upgrades installed packages to the latest versions
How Do I Upgrade Only a Specific Package?
Use the following command:
sudo apt install --only-upgrade package-name
How Do I Check Where a Package is Installed?
Run the following command:
dpkg -L package-name
How Do I Check the Source of a Package?
To find out which repository a package is coming from, use:
apt-cache policy package-name
7. Conclusion
In this guide, we have covered everything from the basics of apt install
to advanced usage, troubleshooting, and FAQs.
By mastering the apt
command, you can efficiently manage your Ubuntu environment.
📌 Useful Links:
Keep exploring and learning more about Ubuntu to optimize your system management!