Для начала /etc/apt/sources.list должен быть такого вида:
deb http://mirror.yandex.ru/debian/ stretch main contrib non-free deb-src http://mirror.yandex.ru/debian/ stretch main contrib non-free
deb http://security.debian.org/debian-security stretch/updates main contrib non-free deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free
# stretch-updates, previously known as 'volatile' deb http://mirror.yandex.ru/debian/ stretch-updates main contrib non-free deb-src http://mirror.yandex.ru/debian/ stretch-updates main contrib non-free
-------------------------------------------------------------------------------------- Cоответственно stretch заменить на тот дистрибутив который стоит jessie wheezy и тд
Далее выполняем последовательно команды: apt-get update apt-get install aptitude aptitude clean aptitude update aptitude safe-upgrade