Learning Ubuntu Apt Get Through Examples


VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

The Ubuntu package manager is one of the most popular Linux-based software distribution tools. This tutorial will teach you how to install, update and remove apps from your computer using apt-get commands by looking at a few examples.

The “apt vs apt-get” is a Linux command-line tool that allows users to install, remove and update packages. The two commands are very similar, but the difference between them is significant.

Learning Ubuntu Apt Get Through Examples

You may be wondering how to install or update software packages if you’re new to Linux. You’ve come to the correct spot if you want to learn how to use Ubuntu Apt Get commands to manage software packages.

In this video, you’ll learn how to update or upgrade current software packages, as well as install new ones and uninstall old ones.

Continue reading to learn how to manage software packages.


This lesson will be a hands-on example, but no special tools are required; as long as you’re running Ubuntu 16 or above, you’ll be OK. The samples in this course are based on Ubuntu 20.04.3 LTS.

System Package Repositories are being updated.

The apt-get program is often used to refresh the list of packages available in your system. It is also suggested that you do so before installing, updating, or upgrading any program.

Managing Software on Ubuntu Using AppImage

To update your system’s package list, open your terminal and perform the apt-get command below. When asked, enter your sudo password.

The command below refreshes the system package list by checking for updated software versions from the entries in the /etc/apt/sources.list file.

You’ll notice a message that states Hit if there isn’t a package version update. Otherwise, a message will appear with the word Get, and the program will download the package details (not the total package). It displays ign when there is a problem getting package information.

Repositories for Packages are being updated. Repositories for Packages are being updated.

Software Package Upgrades

You’ve just changed your machine’s software package list using sources.list, but until you conduct an upgrade, software packages will remain in their current version. Based on the entries in the sources.list file, upgrade software programs that have available updates.

To update all installed software packages on your system to newer versions, use the Ubuntu Apt Get command. When requested to confirm, choose Y to proceed.

With the -y option, you may skip the confirmation question. If you haven’t double-checked the list, you can wind up updating or installing items you didn’t want.

Software Package Upgrades Software Package Upgrades

You could opt to update simply a single piece of software. If so, use the apt-get upgrade command to provide the package name, as shown below.

upgrade vsftpd sudo apt-get

Upgrades to a Particular Software Package Upgrades to a Particular 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: upgrade vsftpd sudo apt-get google-chrome firefox

Using Ubuntu Apt Get to Upgrade Application Packages Intelligently

How do you effectively handle software package conflicts apart from updating installed software packages? The apt-get upgrade package merely updates existing packages; however, the dist-upgrade command will delete any existing packages that are incompatible with the new versions.

To update existing software packages on your PC, use the command below. This command also fulfills any requirements by adding or removing packages.

apt-get dist-upgrade sudo

A smart conflict resolution method is included into the apt-get dist-upgrade command. When updating packages, if there is a conflict, the command upgrades the critical packages first, then the lower priority packages.

Upgrading a Linux Operating System Upgrading a Linux Operating System

The command do-release-upgrade is used to update an Ubuntu version to the next release version. This also executes apt-get dist-upgrade to update the packages.

Specific Software Packages: Finding and Installing

You’ve learnt how to update package repositories as well as the operating system. But how do you go about looking for new applications to install? You may use the apt-cache command to find all available or specified software packages.

Run the command below to get a list of all software packages that are currently accessible in your area (pkgnames). The previous update against the sources.list configuration file yielded this list.

Searching for All Software Packages That Are Available Searching for All Software Packages That Are Available

The apt-cache pkgnames tool, by default, returns a large number of software packages, which makes scrolling through them a chore. So, if you know the name of the software program, why not look for it specifically?

Use the command below to look for particular software package repositories, such as vsftpd. You don’t need to prepend the sudo command since you’re merely looking for a software package.

Looking for a Specific Software Package Looking for a Specific Software Package

Replace search with the show option if you know the specific package name, as in: display PackageName using apt-cache Replace PackageName with the name of the package. This command displays package information such as the origin, architecture, and version.

Run the command below to install the software package (vsftpd) on your system after you’ve found it.

apt-get install vsftpd sudo

New Software Package Installation New Software Package Installation

Reinstalling a Program

Perhaps you’re experiencing difficulties with some program and don’t want to tear it down to figure out what’s wrong. If this is the case, you may try reinstalling the program to resolve the problem.

To —reinstall the program (vsftpd) on your machine, use the apt-get install command.

apt-get install vsftpd sudo –reinstall

Using the Apt-Get command to reinstall software Using the Apt-Get command to reinstall software

Getting Rid of Installed Software

Your system’s installed software uses storage by default. What if the program is no longer useful? Getting rid of the program is the best option. You may improve the performance of your system by doing so.

To uninstall a particular piece of software (vsftpd), use the command below.

apt-get uninstall vsftpd sudo

Getting Rid of Installed Software Getting Rid of Installed Software

Using Ubuntu Apt Get to Remove Software and Any Supporting Files

Even when you remove most software from your computer, it leaves behind remnants such as folders and configuration files. How can you get rid of those residues that lead to your storage running out? Allow the Ubuntu Apt Get command to clean up the leftovers for you.

You may have previously removed a program, but its configuration files are still there. If that’s the case, the apt-get command’s purge parameter will suffice.

To uninstall the program (vsftpd) and delete the leftover files and directories from your PC, use the commands below.

apt-get purge vsftpd sudo

deleting all of a software's configuration files deleting all of a software’s configuration files

If you’d rather uninstall (delete) the program and purge (—purge) its configuration files all at once, use the command below.

sudo apt-get uninstall vsftpd —purge

Software and associated configuration files are being removed. Software and associated configuration files are being removed.

Errors in Dependency Resolution

When it comes to installing, updating, or upgrading software, things don’t always go as planned. You’re certain to run across issues, such as dependency errors caused by a damaged package database. But don’t be concerned! The Ubuntu Apt Get command allows you to purge your local repository of unnecessary package files that may be generating the dependency problem.

Application packages are saved in.deb files, which are downloaded and installed when you install any program on your PC. When you delete and reinstall a piece of software, apt now utilizes the.deb files from your local repo rather than redownloading it from the internet.

However, if a newer version of the program becomes available and you attempt to reinstall it, the old contents in your local repo will become unusable. As a consequence, a dependence error occurs.

To delete downloaded and cached package files from your local repo (/var/cache/apt/archives), use the apt-get clean command.

The lock files in the /var/cache/apt/archives and /var/cache/apt/archives/partial folders are not removed by the apt-get clean command. Lock files are used to prevent two package managers from working on the same files at the same time.

Removing Package Files from the Local Repo Removing Package Files from the Local Repo

The autoclean option is used to delete downloaded software packages that are no longer referenced by installed applications.

Remove remaining files (.deb files) from the /var/cache/apt/archives directory using the command below (autoclean).

Getting Rid of Remaining Files (.deb files) Getting Rid of Remaining Files (.deb files)


You’ve learned how to use Ubuntu Apt Get commands to install and upgrade software packages, as well as update the operating system itself, in this article. You’ve also mentioned overcoming installation difficulties by deleting unneeded package files from earlier software package installations.

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

Related:Using PHP to Run and List Cron Jobs on a Linux System

Ubuntu Apt Get Through Examples is a tutorial on how to use the “sudo apt” command. It also provides examples of commands that will help users learn more about Ubuntu.

Related Tags

  • apt-get command not found
  • apt-get update
  • apt-get flags
  • apt linux
  • apt-get packages