10 Basic APT Commands For Beginners

Mastering these basic apt commands will elevate your CLI skills

As you may know, APT (Advanced Package Tool) is a command-line utility for managing packages on Ubuntu, Debian and derivative systems. Among others, it’s the tool you use to upgrade the system, add a repository, check if a package is available in a repo or install a package.

For Ubuntu and derivative systems, also dpkg and snap package managers are available, but in this article I will only cover APT.

1. APT Commands For Beginners: Update the Package List

sudo apt update

Technically speaking, this command does not update any package on the system. It only checks all the available repositories and updates the list. If there is a new version of Chromium available, after you run apt update, you will be able to install the new version on your system with apt install.

10 Basic APT Commands Every Ubuntu User Should Know

2. APT Commands for Beginners: Upgrade Installed Packages

sudo apt update
sudo apt upgrade

The apt update command updates the repository files and discovers the available software updates, while the apt upgrade commands upgrade does the actual upgrade of the packages.

3. APT Commands for Beginners: Install a Package

sudo apt update
sudo apt install <package-name>

It is a common practice to update the repository index with apt update, before installing anything new with apt install.

The apt install command installs the latest version of the package found inside the added repositories.

For example, to install GIMP, you can do sudo apt install gimp.

10 Basic APT Commands Every Ubuntu User Should Know

4. Mastering Apt: Remove a Package

sudo apt remove <package-name>

This removes a package, but keeps the current configuration files.

For example, sudo apt remove gimp removes GIMP.

10 Basic APT Commands Every Ubuntu User Should Know

5. APT Commands For Beginners: Purge a Package (Remove Configuration Files)

sudo apt purge <package-name>

This removes both the package and the configuration files. For example sudo apt purge gimp removes GIMP and all the customizations and saved configs.

This can also be used ever of gimp has been already removed with apt remove, deleting only the configuration files, if the software is not installed.

10 Basic APT Commands Every Ubuntu User Should Know

6. Mastering APT: Search for a Package

apt search <package-name>

This command looks inside the available repositories and shows if any package with or containing that name is available. No sudo is needed here, as this does not change any system file. For example, apt search mixxx shows the Mixxx version which is available via the already existent repositories.

10 Basic APT Commands Every Ubuntu User Should Know

7. APT Commands For Beginners: Show Package Information

sudo apt update
apt show <package-name>

It is common practice to refresh the repository index before using apt show, so that you see the information about the latest version of the package available. This is what apt show mixxx command outputs:

10 Basic APT Commands Every Ubuntu User Should Know

8. APT Commands For Beginners: List Upgradable Packages

sudo apt update
apt list --upgradable

This lists all the packages that have updates available.

10 Basic APT Commands Every Ubuntu User Should Know

9. APT Commands For Beginners: Clean Up Unused Packages

sudo apt autoremove

The sudo apt remove commands uninstalls all the packages that are not used anymore, because they were installed as dependencies for other packages.

10 Basic APT Commands Every Ubuntu User Should Know

10. APT Commands For Beginners: Fix Broken Install

sudo apt --fix-broken install

This command resolves and installs any missing or broken dependencies. Also, it offers to remove the dependencies which are not used anymore, similar to sudo apt autoremove.

10 Basic APT Commands Every Ubuntu User Should Know

By mastering these 10 commands you will be able to use the apt package manager efficiently on your Ubuntu, Linux Mint or another derivative system.

If you want to elevate your commnad-line interface skills, you might also be interested in:

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *