Master Guide - Essential APT Package Management Commands Complete List
1. Update Package Lists
sudo apt-get update
Updates the local package index with the latest changes from repositories.
2. Upgrade Installed Packages
sudo apt-get upgrade
Upgrades all installed packages to their latest versions (without removing or installing new packages).
sudo apt-get dist-upgrade
Upgrades packages intelligently, handling dependencies (may install/remove packages if needed).
sudo apt-get full-upgrade
Similar todist-upgrade, ensures all packages are upgraded (Ubuntu's newer equivalent).
3. System Upgrade (Release Upgrade)
sudo do-release-upgrade
Upgrades Ubuntu to the next major release (e.g., 20.04 → 22.04).
4. Check & Fix Package Issues
sudo apt-get check
Verifies dependency integrity and checks for broken packages.
sudo apt-get --fix-broken install
Fixes broken or incomplete package installations.
sudo apt update --fix-missing
Updates package lists while fixing missing package indexes.
5. Clean Up Packages
sudo apt-get autoclean
Removes obsolete downloaded package files from the cache.
sudo apt-get clean
Deletes all downloaded package files from the cache.
sudo apt-get autoremove
Removes unnecessary dependencies that are no longer needed.
6. Install Essential Build Tools
sudo apt-get install build-essential module-assistant
Installs essential tools for compiling software.
sudo m-a prepare
Prepares the system for building kernel modules (via Module-Assistant).
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
Installs tools and headers for kernel module development (for AMD x86-64 systems).
7. Package Management & Queries
List Packages
sudo apt list --installed
Lists all installed packages.
apt list --upgradable
Lists packages with available upgrades.
Search Packages
sudo apt-cache search <package_name>
Searches for a package in repositories.
apt-cache depends <package-name>
Checks dependencies for a package.
apt depends <package-name>
Shows package dependencies.
apt rdepends <package-name>
Shows reverse dependencies (packages that depend on the specified package).
Install/Remove Packages
sudo apt install <package>
Installs a package.
sudo apt remove <package_name>
Uninstalls a package (keeps config files).
sudo apt purge <package_name>
Removes a package along with its configuration files.
sudo apt remove <package_name_1> <package_name_2>
Removes multiple packages at once.
Mastering Package Removal with `apt-get remove --purge`
When managing packages on Debian-based systems, `apt-get remove` is a crucial command. Adding the `--purge` option takes it a step further by removing configuration files associated with the package. In this article, we'll explore the nuances of using `apt-get remove --purge` with different wildcard patterns.
Understanding the Patterns
The placement of the wildcard (*) in the package name can significantly impact the removal process. Let's break down three scenarios:
1. apt-get remove --purge *[package-name]*: This command removes packages containing [package-name] anywhere in their name. The wildcards before and after the package name ensure that any package with the specified string is targeted.
2. apt-get remove --purge *[package-name]: This command removes packages ending with [package-name]. The wildcard before the package name allows for any prefix, while the absence of a wildcard after the package name means only exact suffix matches are targeted.
3. apt-get remove --purge [package-name]*: This command removes packages starting with [package-name]. The wildcard after the package name allows for any suffix, while the absence of a wildcard before the package name means only exact prefix matches are targeted.
Examples and Use Cases
Suppose we want to remove packages related to "firefox". Here's how the different patterns would work:
- sudo apt-get remove --purge *firefox*: Removes any package with "firefox" in its name, such as "firefox", "firefox-locale-en", or "ubfox-firefox".
- sudo apt-get remove --purge *firefox: Removes packages ending with "firefox", such as "ubfox-firefox" or "my-firefox".
- sudo apt-get remove --purge firefox*: Removes packages starting with "firefox", such as "firefox", "firefox-locale-en", or "firefox-addon".
Best Practices
When using apt-get remove --purge with wildcards, exercise caution to avoid unintended removals. Always:
- Double-check the package names and patterns.
- Use apt-get -s remove --purge to simulate the removal before applying it.
- Be mindful of the wildcard placement to target the correct packages.
By mastering the apt-get remove --purge command with different wildcard patterns, you'll be able to efficiently manage packages and keep your system organized.
Summary Workflow
Update →
sudo apt-get updateUpgrade →
sudo apt-get upgrade/full-upgradeFix Issues →
sudo apt-get check/--fix-broken installClean Up →
sudo apt-get autoremove/autocleanInstall/Remove → Use
install,remove, orpurgeas needed.
Comments
Post a Comment
Your feedback is valuable