Operations 5 min read

Mastering Ubuntu APT: Core Commands for Installing, Searching, and Cleaning Packages

This guide walks you through Ubuntu's APT tool, covering the essential update‑upgrade‑install workflow, how to search and remove packages, using PPA repositories for newer versions, and switching to faster local mirrors for quicker downloads.

Ubuntu
Ubuntu
Ubuntu
Mastering Ubuntu APT: Core Commands for Installing, Searching, and Cleaning Packages

1. Core Commands – The Three‑Step Workflow

Step 1: Refresh the package list

sudo apt update

This command contacts the configured servers to retrieve the latest package information; it does not install anything. Running it before any installation is recommended.

Step 2: Upgrade installed packages

sudo apt upgrade

The system lists upgradable packages and asks for confirmation (press Y). If dependency changes or held packages appear, review the output before proceeding, especially for kernel or driver updates.

Step 3: Install software

sudo apt install <package-name>

Multiple packages can be installed at once, e.g., sudo apt install git vim vlc.

2. Searching and Uninstalling

Search for packages

apt search <keyword>

Example: apt search python. Pipe the output to grep for better filtering.

Remove a package (keep config files)

sudo apt remove <package-name>

Purge a package (delete config files)

sudo apt purge <package-name>

Clean up unused dependencies

sudo apt autoremove

Running this periodically frees disk space.

3. PPA – Extending Your Repositories

Official repositories are stable but may contain older versions. Personal Package Archives (PPA) let you install newer releases, though they delegate part of system updates to third‑party maintainers. Prefer official sources when possible.

Example – installing the latest OBS Studio:

# Add the PPA
sudo add-apt-repository ppa:obsproject/obs-studio
# Refresh the list (Ubuntu may do this automatically)
sudo apt update
# Install OBS Studio
sudo apt install obs-studio

4. Switching Mirrors – Speeding Up Downloads

The default Ubuntu mirrors are overseas and can be slow for users in China. You can switch to domestic mirrors (e.g., Alibaba Cloud, Tsinghua, USTC).

GUI method (recommended)

Open "Software & Updates".

In the "Download from" dropdown, choose "Other..." → "China".

Click "Select Best Server"; the system will test speeds.

Select the fastest server and click "Choose Server".

Close the window; you will be prompted to reload the sources.

Command‑line method (advanced)

Edit /etc/apt/sources.list and replace the domain names with those of a domestic mirror. Beginners should prefer the GUI method because this involves modifying system files.

Mastering APT gives you the essence of Linux software management: a single line of command can replace downloading and running graphical installers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxCommand LineAPTPackage ManagementUbuntuPPA
Ubuntu
Written by

Ubuntu

Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.