Skip to content

Instantly share code, notes, and snippets.

@cpswan
Created December 11, 2014 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpswan/ddc44085fd9a5772d139 to your computer and use it in GitHub Desktop.
Save cpswan/ddc44085fd9a5772d139 to your computer and use it in GitHub Desktop.
Fix apt on Ubuntu 12.04.5 to prevent hash mismatch errors
#!/bin/bash
sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update
sudo dpkg --clear-avail
sudo dpkg --configure -a
sudo apt-get install -f
sudo apt-get update
sudo apt-get dist-upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment