Debian/Ubuntu - How to restore /var/cache/apt structure after deleting it?

Solution 1:

You need two things there:

sudo mkdir -p /var/cache/apt/archives/partial
sudo touch /var/cache/apt/archives/lock
sudo chmod 640 /var/cache/apt/archives/lock

Removing this directory manually is a bad idea generally. To clean archives cleanly, use:

sudo apt-get clean

Solution 2:

For fresh APT versions, full solution looks like:

sudo mkdir -m 0700 /var/cache/apt/archives/partial
sudo chown _apt:root /var/cache/apt/archives/partial