This error indicates that one or more packages that your desired package depends on cannot be satisfied. This is often a more complex problem.
Common Causes and Solutions:
Dependency package version is too low or too high:
Cause: Package A, which you want to install, requires version 2.0 of package B, but you have version 1.0 installed, and version 2.0 is not available in the repositories. Or vice versa, you have version 3.0, which does not satisfy the dependency.
Solution:
First, try to fix it automatically: sudo apt -f install. This command attempts to automatically find and install missing dependencies or remove conflicting packages.
Check which package is causing the problem. The error message usually specifies which version of which package cannot be satisfied. You can try to manually install that specific version of the dependency.
Mixing sources from different distributions:
Cause: This is the most common reason. You have added a testing or unstable (Sid) repository to your stablesources.list, or even mixed in Ubuntu repositories. Library files (like libc6) are incompatible between different distributions, leading to severe dependency hell.
Solution:
Strictly prohibit mixing standard repositories from different distributions. Check your /etc/apt/sources.list and all files in the /etc/apt/sources.list.d/ directory.
Comment out or delete all repositories that are not for your current Debian version, then run sudo apt update, followed by sudo apt -f install.
Dependency issues with manually installed .deb packages:
Cause: You installed a .deb package with dpkg -i, but the system lacks its dependencies.
Solution: Use apt to install local .deb packages, as it automatically handles dependencies.
sudo apt install ./package_file.deb
If you have already installed it with dpkg, run sudo apt -f install to fix it.
This error means that the APT system is currently being used by another process.
Causes and Solutions:
Another package management tool is running:
Cause: You may have two terminals open, one running apt install while trying to run apt in the other. Alternatively, the system might be performing an automatic update in the background. The Synaptic graphical package manager also acquires this lock.
Solution: Close all other terminals or programs that might be installing or updating software. Wait a few minutes for the background process to finish, then try again.
Lock file left over from an abnormal exit:
Cause: A previous apt process was killed or crashed abnormally and did not have a chance to release the lock file.
Solution (use with caution):
First, confirm that no apt, apt-get, or dpkg processes are running:
ps aux | grep -i aptps aux | grep -i dpkg
If any processes are running, try to terminate them gracefully (kill <PID>).
If you confirm that no related processes are running, you can manually remove the lock files:
This is usually because the official repository server you are connecting to is located overseas, resulting in high network latency or instability.
Solution: Switch to a regional mirror.
For detailed steps, please refer to the System Configuration & Basic Usage section. After switching to a mirror in your country (like Tsinghua, Alibaba, or USTC in China), the speed will improve dramatically.
Open a terminal in the directory containing the .deb file and run:
sudo apt install ./your_package_name.deb
Note that the ./ before the filename is necessary. It tells apt that this is a local file, not a package to be found in the repositories.
Traditional Method: Use dpkg
dpkg is the low-level package management tool. It does not automatically handle dependencies.
Installation command:
sudo dpkg -i your_package_name.deb
If this command fails due to missing dependencies, you need to immediately run sudo apt -f install to fix the dependencies. apt will read the dependency problems reported by dpkg and automatically download and install the required packages from the repositories.
Action: Uninstalls the package itself but keeps its configuration files.
Advantage: If you plan to reinstall the software later, your previous configurations can be reused.
apt purge <package_name>:
Action: Uninstalls the package and deletes all of its configuration files (usually those in the /etc directory).
Advantage: "Cleans" the system of a software and all its configuration traces. Suitable if you are sure you will no longer use the software or want to completely reset its configuration.
apt autoremove:
Action: Automatically uninstalls "orphan" packages that were installed as dependencies for other packages but are no longer needed by any installed software.
Recommendation: Running sudo apt autoremove after uninstalling software is a good habit to keep your system clean.
apt-get is the most traditional and stable APT command-line tool. It is powerful, provides detailed output, and is especially suitable for use in scripts because its output format is very stable across different versions.
apt is a newer tool designed to provide a more user-friendly and concise interface. It consolidates some of the most common commands from tools like apt-get and apt-cache and provides additional features like a progress bar.
Which one should I use?
For daily interactive use (manually typing commands in the terminal), apt is recommended. Its output is more visually appealing, and the commands are more intuitive (e.g., apt list --installed is more readable than dpkg -l).
For scripting (e.g., automated deployment scripts), apt-get is recommended to ensure the script's stability on future Debian versions.
You can think of apt as a modern wrapper for apt-get, optimized for human users.
APT Pinning is an advanced apt technique that allows users to precisely control from which distribution (e.g., stable, testing, backports) packages are installed. It can even be used to force the installation of an older version of a package (downgrading).
Main Uses:
Use all packages from the stable system by default, but install the latest version of a specific software (like firefox) from testing or backports.
Downgrade a package to an older version if an update causes problems.
How it works:
APT uses "priorities" to decide which version of a package to install. By default, an installed package has a priority of 100, packages from the stable repository have 500, and testing and unstable also have 500. APT chooses the version with the highest priority. Pinning involves manually changing these default priorities through a configuration file.
Example: Install the latest kernel from backports while keeping the rest of the system stable
Add the backports repository: Make sure you have a backports line in /etc/apt/sources.list.
Create a pinning configuration file:
sudo nano /etc/apt/preferences.d/99-backports-pin
Edit the file content:
# Make the default priority of backports lower than stable to avoid upgrading all packagesPackage: *Pin: release n=trixie-backportsPin-Priority: 400# Specifically target linux-image-* and linux-headers-* to be installed from backports# Raise their priority to be higher than stable (500)Package: linux-image-* linux-headers-*Pin: release n=trixie-backportsPin-Priority: 501
Update and install:
sudo apt update
sudo apt install linux-image-amd64
apt will now automatically select the kernel from backports for installation.
How to downgrade a package:
Find available versions:
apt-cache policy <package_name># Example: apt-cache policy vim
This lists all available versions of vim from all repositories and their sources.
APT will warn you that you are attempting to downgrade; confirm to proceed. If you want to prevent it from being automatically upgraded later, you can lock the package with sudo apt-mark hold <package_name>.
These three commands are central to Debian system administration, but they have completely different purposes.
apt update
Action: Updates the local package index.
What it does: Connects to all repository servers defined in sources.list, fetches the latest list of their packages (including version numbers, dependencies, descriptions, etc.), and stores this information locally (in /var/lib/apt/lists/).
What it does not do: It does not download, install, or upgrade any packages. It just lets your system "know" what updates are available.
When to use: You must run this command before any upgrade or install operation.
apt upgrade
Action: Upgrades installed packages.
What it does: Based on the latest list fetched by apt update, it upgrades all installed packages on your system to their newest versions.
Core principle: It will never remove any existing packages or install any new ones. If upgrading a package requires uninstalling another one (due to a dependency conflict), the upgrade for that package will be held back.
When to use: For routine, safe system updates.
apt full-upgrade (equivalent to apt-get dist-upgrade)
Action: Performs a smarter, complete upgrade that may change the system's dependency structure.
What it does: Like upgrade, it upgrades all packages that can be upgraded. The difference is that when faced with complex dependency changes (e.g., a new version of package A no longer depends on package B but now depends on package C), it will intelligently install the new dependency (C) and remove the old, no-longer-needed dependency (B).
When to use:
It is mandatory for major version upgrades (e.g., Debian 11 -> 12).
When apt upgrade reports that some packages have been "kept back", running full-upgrade can usually resolve these issues.
It is the recommended command for keeping a system in sync on rolling-release branches like testing or sid.
Summary: A standard, complete system update process is:
sudo apt update && sudo apt full-upgrade
This is a very common error that often occurs during apt install or apt upgrade. Its core meaning is: the package was successfully unpacked and installed into the filesystem, but its post-installation script failed to execute.
Example Error Message:dpkg: error processing package some-package (--configure): installed some-package package post-installation script subprocess returned error exit status 1
Solutions:
Force reconfiguration (most common):
This error means the package is in an "installed but not configured" state. First, try to make dpkg re-run the configuration scripts for all unconfigured packages.
sudo dpkg --configure -a
In many cases, this will solve the problem directly.
Force fix-broken install (-f install):
If reconfiguration is unsuccessful, try apt's fix command. It will check for dependency issues and attempt to download and install any missing packages.