Essential APT Commands to get started with Ubuntu / Linux

Managing software packages efficiently is crucial for maintaining a stable and functional Linux system. The APT (Advanced Package Tool) command-line utility is the backbone of package management on Debian-based distributions like Ubuntu, Linux Mint, and Devuan. This guide provides a comprehensive walkthrough of the most useful APT commands for installing, updating, and managing packages on your system.

Prerequisites

Before diving into the commands, ensure you have the following:

  • A Linux distribution that uses APT (e.g., Debian, Ubuntu, Linux Mint, Devuan)
  • Basic familiarity with the command-line interface (CLI) and package management

Overview of APT Commands

APT is a powerful tool that allows you to manage DEB packages efficiently. Whether you need to install, update, or remove packages, APT has you covered. Here are some essential commands to help you get started:

1. Updating the List of Available Packages

Before you install or upgrade packages, it’s essential to update the package database:

sudo apt update

This command fetches the latest package lists from the repositories and prepares your system for further package management tasks.

2. Listing Available Package Upgrades

To see which packages can be upgraded, use:

apt list --upgradable

3. Upgrading Packages

To upgrade all packages to their latest versions, run:

sudo apt upgrade

For a more thorough system upgrade, which might install or remove packages to resolve dependencies, use:

sudo apt full-upgrade

4. Upgrading Specific Packages

If you prefer to upgrade a specific package, use:

sudo apt --only-upgrade install [package_name]

5. Downgrading Packages

To revert to an older version of a package, specify the version:

sudo apt install [package_name]=[older_version]

6. Searching for a Package

To find a package by name or description:

apt search [package_name]

7. Installing a Package

To install a package from the repository:

sudo apt install [package_name]

8. Installing a Specific Package Version

To install a specific version of a package:

sudo apt install [package_name]=[package_version]

Affordable VPS Hosting With Dracula Servers

Looking for reliable and budget-friendly Virtual Private Server (VPS) hosting? Look no further than Dracula Servers. Dracula Servers offers a range of VPS hosting plans tailored to meet diverse needs. With competitive pricing, robust performance, and a user-friendly interface, it’s an excellent choice for individuals and businesses alike.

Explore the Dracula Servers website to discover hosting solutions that align with your requirements and take your online presence to new heights with their affordable and efficient VPS hosting services.

Visit Dracula Servers and experience reliable VPS hosting without breaking the bank.

9. Listing Available Package Versions

To see all available versions of a package:

apt-cache policy [package_name]

10. Holding a Package

To prevent a package from being upgraded:

sudo apt-mark hold [package_name]

To list held packages:

apt-mark showhold

To remove the hold:

sudo apt-mark unhold [package_name]

11. Installing a DEB Package

To install a DEB package from a local file:

sudo apt install [path_to_deb_file]

12. Uninstalling a Package

To remove a package:

sudo apt remove [package_name]

To remove unused dependencies:

sudo apt autoremove

To purge a package along with its configuration files:

sudo apt autoremove --purge [package_name]

13. Listing Installed Packages

To list all installed packages:

apt list --installed

To filter the list using grep:

apt list --installed | grep [pattern]

14. Viewing Package Details

To get detailed information about a package:

apt show [package_name]

15. Downloading a Package

To download a package without installing it:

apt download [package_name]

Editing sources.list

To edit the list of repositories:

sudo apt edit-sources

Alternatively, use a text editor:

sudo nano /etc/apt/sources.list

For Ubuntu, to auto-select the nearest mirror, update the repository URLs with:

mirror://mirrors.ubuntu.com/mirrors.txt

After making changes, update the package list:

sudo apt update

APT Documentation

For a quick help page:

apt --help

For detailed documentation, check the man page:

man apt

Wrap Up

This guide has covered various ways to use the APT command for managing packages on your Linux system. From installing and upgrading packages to handling dependencies and configuring repositories, APT is a versatile tool for maintaining your system. While APT is specific to DEB packages, other packaging formats like Flatpak and Snap offer additional options for installing software on Linux. Experiment with different commands and tools to find the best setup for your needs.

Check out More Linux Tutorials Here!

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
× Dracula Servers

Subscribe to DraculaHosting and get exclusive content and discounts on VPS services.