Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Debian stable disribution installed on my computer. Once I installed some packages from testing but now it causes some troubles so I would like to downgrade them. I've tried next commands:

apt-get --reinstall install  `apt-show-versions | grep newer | cut -d ' ' -f 1 | tr '\n' ' '`

this doesn't work because apt tries to retrieve the same versions of packages and complains that it can't download them because I now have no sources for testing packages in sources.list

apt-get -t squeeze  install  `apt-show-versions | grep newer | cut -d ' ' -f 1 | tr '\n' ' '`

doesn't work either. Writes that the newest versions of packages have already installed. I thought -t sqeeze forces apt to install packages from stable.

Anyway how can I solve this task?

share|improve this question
wouldn't it work if you add the testing sources to sources.list again, purge the testing applications, remove the sources and install again? – wullxz Aug 9 '12 at 11:13

I use this:

for p in $(apt-show-versions|grep "newer than version in archive"|cut -d\  -f1); do apt-get install $p=$(apt-cache show $p|grep ^Version|tail -1|cut -d\  -f2); done

(There is a double space after both -d\.)

share|improve this answer

As @wullxz said. You can do that by purging the new packages, removing or commenting out the unstable repo from the sources list, installing the old packages then, uncomment or add the unstable repo again to sources.list if you want to use some other packages from it.

  • Purge new package:

sudo apt-get purge my-package

  • Edit sources.list and comment out the testing repo:

sudo nano /etc/apt/sources.list

  • Install old stable package again:

sudo apt-get update

sudo apt-get install my-package

  • (Optional) Use the testing repo again (as aforementioned) if u need to and, lock the version for that particular package temporarily:

# uncomment the testing repo from sources.list

sudo nano /etc/apt/sources.list

# Lock the current version of the package.

echo "my-package hold" | dpkg --set-selections

  • If you would like to remove the lock and install the testing package again:

echo "my-package install" | dpkg --set-selections

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .