---
title: "Ubuntu Apt Get Mastery: A Guide with Practical Examples"
description: "Master Ubuntu Apt Get: Your Quick Guide to Installing and Removing Linux Software. Learn essential commands for efficient package management now!"
canonical: "https://adamtheautomator.com/ubuntu-apt-get/"
---

# Ubuntu Apt Get Mastery: A Guide with Practical Examples

> Master Ubuntu Apt Get: Your Quick Guide to Installing and Removing Linux Software. Learn essential commands for efficient package management now!

Source: https://adamtheautomator.com/ubuntu-apt-get/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Ubuntu Apt Get Mastery: A Guide with Practical Examples](https://adamtheautomator.com/wp-content/uploads/2021/12/Ubuntu-Apt-Get.jpg)

# Ubuntu Apt Get Mastery: A Guide with Practical Examples

[![](https://secure.gravatar.com/avatar/c14b031fe4a12b0e3f4d1e112e37261df83921ddc370cdafbad2a614e36f0cf4?s=192&d=mm&r=g)Chaitanya](https://adamtheautomator.com/author/chaitanya-g/)19 December 20235 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Updating System Package Repositories](#updating-system-package-repositories)
*   [Upgrading Software Packages](#upgrading-software-packages)
*   [Intelligently Upgrading Application Packages with Ubuntu Apt Get](#intelligently-upgrading-application-packages-with-ubuntu-apt-get)
*   [Searching and Installing Specific Software Packages](#searching-and-installing-specific-software-packages)
*   [Reinstalling a Software](#reinstalling-a-software)
*   [Removing Installed Software](#removing-installed-software)
*   [Removing Software and Any Supporting Files with Ubuntu Apt Get](#removing-software-and-any-supporting-files-with-ubuntu-apt-get)
*   [Resolving Dependency Errors](#resolving-dependency-errors)
*   [Conclusion](#conclusion)

If you’re new to Linux, you may be wondering how to install or update software packages. Well, you’ve come to the right place to get your head over managing software packages with Ubuntu [`Apt Get`](https://www.geeksforgeeks.org/apt-get-command-in-linux-with-examples/) commands.

In this tutorial, you’ll learn how to update or upgrade existing software packages and install new ones or get rid of them when you don’t need them anymore.

Now read on and start managing software packages!

## Prerequisites

This tutorial will be a hands-on demonstration but doesn’t require special tools, so long as you’re on Ubuntu 16 or higher version, you’re good to go. This tutorial uses Ubuntu 20.04.3 LTS version for the demos.

## Updating System Package Repositories

One of the most common uses of the `apt-get` command is to update the list of packages available in your system. And doing so is recommended before installing, updating, or upgrading any [software](https://adamtheautomator.com/appimage-ubuntu/).

Related:[Managing Software with AppImage on Ubuntu](https://adamtheautomator.com/appimage-ubuntu/)

Open your terminal and run the below `apt-get` command to `update` the package list on your system. Enter your sudo password when prompted.

The below command checks for newer software versions from the entries in _/etc/apt/sources.list_ file, and updates the system package list.

```bash
sudo apt-get update
```

When there is no package version update, you’ll see a note that says **Hit.** Otherwise, you’ll see a note saying **Get,** and the command downloads the package information (not the total package). When there is an error in retrieving the package information, it shows **ign**.

![Updating Package Repositories](https://adamtheautomator.com/wp-content/uploads/2021/12/image-287.png)

Updating Package Repositories

## Upgrading Software Packages

You’ve just updated your machine’s software package list based on _sources.list_, but software packages will stay in their current version unless you run an upgrade. Upgrade software packages that have available updates based on the entries in the _sources.list_ file.

Run the `Ubuntu Apt Get` command below to `upgrade` all installed software packages on your machine with newer versions available. You are prompted to confirm, and enter **Y** to continue.

> _You can bypass the confirmation prompt with the `-y` option. This may update/install packages that you did not intend to if you have not verified the list._

```bash
sudo apt-get upgrade
```

![Upgrading Software Packages](https://adamtheautomator.com/wp-content/uploads/2021/12/image-288.png)

Upgrading Software Packages

Perhaps you prefer to upgrade a specific software only. If so, specify the package name along with the `apt-get upgrade` command, as shown below.

```bash
sudo apt-get upgrade vsftpd
```

![Upgrading Specific Software Package](https://adamtheautomator.com/wp-content/uploads/2021/12/image-289.png)

Upgrading Specific Software Package

> _If you have 2-3 software to upgrade, you can specify them in the `apt-get upgrade` command separated by space, like the one below: `sudo apt-get upgrade vsftpd google-chrome firefox`_

## Intelligently Upgrading Application Packages with Ubuntu Apt Get

Apart from upgrading installed software packages, how do you intelligently manage software package conflicts? The `apt-get upgrade` package only **upgrades** existing packages but the `dist-upgrade` command will also remove existing packages if they are in conflict with the new versions.

Run the below command to upgrade existing software packages on your machine. This command also adds or removes any packages to fulfill any dependencies.

```bash
sudo apt-get dist-upgrade
```

> _The `apt-get dist-upgrade` command has an intelligent conflict resolution system. If there is a conflict when upgrading the packages, the command chooses the critical packages to upgrade first and then the lower priority packages._

![Upgrading a Linux Distribution](https://adamtheautomator.com/wp-content/uploads/2021/12/image-290.png)

Upgrading a Linux Distribution

> _To upgrade an Ubuntu version to the next release version, you would run the command `do-release-upgrade`. This runs `apt-get dist-upgrade` as well to update the packages._

## Searching and Installing Specific Software Packages

So far, you’ve learned to update package repositories and the operating system itself. But how do you search for new software packages to install? The [`apt-cache`](https://debian-handbook.info/browse/stable/sect.apt-cache.html) command lets you search for all available or specific software packages.

Run the command below to display all locally known available software packages (`pkgnames`). This list is derived from the last update against the _sources.list_ configuration file.

```bash
apt-cache pkgnames
```

![Searching All Available Software Packages](https://adamtheautomator.com/wp-content/uploads/2021/12/image-291.png)

Searching All Available Software Packages

The `apt-cache pkgnames` command naturally returns tons of software packages, and it’s a pain to scroll through them. So why not specifically search for one if you’re familiar with the software package’s name?

Run the below command to `search` for specific software package repositories, in this case, for `vsftpd`. Since you’re only searching for a software package, you do not need to prepend the `sudo` command.

```bash
apt-cache search vsftpd
```

![Searching Specific Software Packages](https://adamtheautomator.com/wp-content/uploads/2021/12/image-292.png)

Searching Specific Software Packages

> _If you know the exact package name, replace `search` with the `show` parameter, like this: `apt-cache show PackageName`. Replace `PackageName` with the actual package name. This command lets you view the package details, such as the origin, architecture, version, and so on._

Once you find the software package, run the command below to `install` that software package (`vsftpd`) on your machine.

```bash
sudo apt-get install vsftpd
```

![Installing New Software Package](https://adamtheautomator.com/wp-content/uploads/2021/12/image-293.png)

Installing New Software Package

## Reinstalling a Software

Perhaps you’re having trouble with some software, and you’re not into breaking things down just to see what’s wrong with it. If so, reinstalling the software is one thing you can attempt to fix the software issue.

Run the following `apt-get install` command to `--reinstall` the software (`vsftpd`) on your system.

```bash
sudo apt-get install vsftpd --reinstall
```

![Reinstalling software with Apt-Get command](https://adamtheautomator.com/wp-content/uploads/2021/12/image-294.png)

Reinstalling software with Apt-Get command

## Removing Installed Software

Installed software in your system naturally consumes your storage. What if the software no longer serves a purpose? Removing that software is the ideal thing to do. Doing so lets you optimize your system’s performance.

Run the following command to `remove` a specific software (`vsftpd`) from your machine.

```bash
sudo apt-get remove vsftpd
```

![Removing Installed Software](https://adamtheautomator.com/wp-content/uploads/2021/12/image-295.png)

Removing Installed Software

## Removing Software and Any Supporting Files with Ubuntu Apt Get

Most of the software installed on your machine leaves residues, such as folders or configuration files, even after removing them. Those residues also contribute to your storage running out, so how do you remove them? Let the `Ubuntu Apt Get` command remove those residues for you.

Perhaps you already uninstalled a software but its configuration files remain. If so, using the `purge` parameter with the `apt-get` command will suffice.

Run the below command to `uninstall` the software (`vsftpd`) and remove the left-over files and folders (`purge`) from your machine.

```powershell
sudo apt-get purge vsftpd
```

![Removing all the config files for a software](https://adamtheautomator.com/wp-content/uploads/2021/12/image-296.png)

Removing all the config files for a software

Alternatively, run the command below if you prefer to uninstall (`remove`) the software and rid (`--purge`) its configuration files in one go.

```powershell
sudo apt-get remove --purge vsftpd
```

![Removing software and its configuration files](https://adamtheautomator.com/wp-content/uploads/2021/12/image-297.png)

Removing software and its configuration files

## Resolving Dependency Errors

Installing, updating, or upgrading software doesn’t always end up perfectly completed. You tend to get errors at some point, like dependency errors due to a corrupted package database. But don’t worry! The `Ubuntu Apt Get` command lets you clear your local repository of retrieved package files that are not required which may be causing the dependency error.

Application packages themselves are stored in _.deb_ files which are downloaded and installed on your machine when you install any software. Now, if you remove a specific software and reinstall it, apt uses the _.deb_ files from your local repo for reinstallation, rather than redownload from the internet.

But if a newer version of the software is available and you try to reinstall the software, the existing files in your local repo will no longer be usable. As a result, you get a dependency error.

Run the `apt-get clean` command below to remove downloaded and cached package files in your local repo (_/var/cache/apt/archives_).

> _The `apt-get clean` command does not remove the lock files from /var/cache/apt/archives and /var/cache/apt/archives/partial folders. Lock files are intended to prevent two different package managers from operating on the same files in conflict._

```bash
sudo apt-get clean
```

![Removing Retrieved Package Files in Local Repo](https://adamtheautomator.com/wp-content/uploads/2021/12/image-298.png)

Removing Retrieved Package Files in Local Repo

To remove downloaded packages of software that are no longer referenced by installed software use the `autoclean` parameter.

Run the below command to remove residual files (_.deb files_) (`autoclean`) from the _/var/cache/apt/archives_ directory.

```bash
sudo apt-get autoclean
```

![Removing Residual Files (.deb files)](https://adamtheautomator.com/wp-content/uploads/2021/12/image-299.png)

Removing Residual Files (_.deb files_)

## Conclusion

In this tutorial, you’ve learned how to use `Ubuntu Apt Get` commands to install or upgrade software packages and update the operating system itself. You’ve also touched on resolving installation errors by removing unnecessary package files of previous version install of software packages.

At this point, you already know how to manage software packages on your machine effectively. Now, why not automate upgrading software packages with a Bash script? Or might as well add cron jobs with a PHP script?

Related:[How To Execute and List Cron Jobs for a Linux System via PHP](https://adamtheautomator.com/list-cron-jobs/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-apt-get%2F&text=Ubuntu%20Apt%20Get%20Mastery%3A%20A%20Guide%20with%20Practical%20Examples)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-apt-get%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-apt-get%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Practical-Linux-Unix-Tee-Commands-for-the-Linux-Admin.jpg)

### [Master Unix tee Commands for Real-World Linux Admin Tasks](/unix-tee/)

Simplify Linux output management and streamline your workflow with the “Unix tee” command. This tutorial guides you through its practical applications.

![](https://adamtheautomator.com/wp-content/uploads/2024/03/openldap-4.jpg)

### [How to Install and Configure an OpenLDAP Ubuntu Server](/openldap/)

Unlock the power of OpenLDAP on Ubuntu for centralized user authentication, seamless access control management, and enhanced directory services!

![](https://adamtheautomator.com/wp-content/uploads/2024/03/pipe-command-in-linux-1.jpg)

### [Unleashing the Power of the Pipe Command in Linux](/pipe-command-in-linux/)

Unlock the prowess of the pipe command in Linux to streamline tasks, boost productivity, and simplify complex operations effortlessly!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
