Software⏱️ 2 min read📅 2026-05-31

How to Fix: dpkg error: "trying to overwrite file, which is also in..."

Try running apt-get -f install with no packages to correct unmet dependencies.

Quick Answer: Run "sudo apt-get -f install" to attempt to resolve the issue.

The "trying to overwrite file, which is also in..." error occurs when an attempt is made to install a package that has already been installed on the system. This can happen due to various reasons such as corrupted package lists or incomplete package removal.

✅ Best Solutions to Fix It

Method 1: Clean and Reinstall

  1. Step 1: Run the command `sudo apt-get autoremove` to remove any unnecessary packages.
  2. Step 2: Run the command `sudo apt-get clean` to clear the package cache.
  3. Step 3: Run the command `sudo apt-get install ` again to reinstall the package.

Method 2: Use `dpkg --purge`

  1. Step 1: Run the command `sudo dpkg --purge ` to remove the package and its dependencies.
  2. Step 2: If there are any remaining files, run the command `sudo rm -rf /var/lib/apt/lists/*` to remove them.

🎯 Final Words

To avoid this error in the future, make sure to regularly clean and update your package lists. Additionally, always verify the package list before installing a new package.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions