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.
1. Core Commands – The Three‑Step Workflow
Step 1: Refresh the package list
sudo apt updateThis 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 upgradeThe 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 autoremoveRunning 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-studio4. 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
