upgrade debian

Update packages to most recent releases 
(if using debian stable there may be only a few new releases and only ones with security patches) 
sudo apt-get update && sudo apt-get upgrade

But safest way to upgrade, that will overcome any dependency problems, would be to use:
sudo aptitude upgrade --full-resolver

if your sources list is correct (on the debian release you are sticking with) you can run this for a real full upgrade (with -s option to simulate if you like)
sudo apt-get dist-upgrade

Debian stable security releases
If you want to keep your debian system up to date with security patches (released as updated packages) make sure you have these lines in your /etc/apt/sources.list
deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free

deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free

and run the first line above to update package lists and upgrade packages

Update to a new debian release
First change your sources list to point to the release you want to upgrade to
sudo nano /etc/apt/sources.list

Check your apt.conf file isn't pointing to your current release, for example it might say
APT::Default-Release "wheezy";
mine doesn't after using netinstall CD.  If it does remove that line or change it.. 
sudo nano /etc/apt/apt.conf

developers recommend 
sudo apt-get update
sudo apt-get dist-upgrade
and that can be simulated first with
sudo apt-get -s dist-upgrade
but it is probably much better to do this booted into recovery mode so that many daemons and drivers are not loaded.
so first you can download the packages needed with
sudo apt-get update && sudo apt-get --download-only dist-upgrade
then boot into recovery mode and run
sudo apt-get dist-upgrade

Aptitude can be used with 
sudo aptitude full-upgrade
and simulated first with
sudo aptitude --simulate full-upgrade
sudo aptitude --simulate full-upgrade > ~/upgrade.txt  (to put the result into a text file in home)

I would try the apt-get dist-upgrade way first, and see if its all plain-sailing or not.... but if APT is asking you to remove like about half of your system, because of breakages, then you had better think wisely.
Next, try the aptitude way, as it will offer perhaps a better solution - removing some but not so many packages, which can be reinstalled later on (if they are needed or exist in the release!).

I upgraded just no and there were quite a few packages to be removed by aptitude dist-upgrade, so I ran through the ones I though were important (many lib's will have different names) at Debian packages, and I only found a few that will need re-installing.

Caution!  If you (by mistake) use the apt-get command "upgrade" after changing your sources file, and actually you are intending to upgrade to another release, apt will not actually upgrade to the new release but will only update your installed packages from the new release -and you will get an irreparable mix of packages from different releases.
For example, if you are stable and you do an upgrade with packages from testing, you will get a mixed install of both stable and testing - and then trying to dist-upgrade, you will have hundreds of packages held back, unable to install because of countless dependency problems.
If you did that, you can revert to stable in sources and do an apt-get update, apt-get upgrade, to revert to stable install, and then do a dist-upgrade. 
The "upgrade" command will not add any new packages or remove unneeded ones -which is necessary when upgrading to another release.

Using backports to update packages
You may want to stay with Wheezy (while Jessie is still in its early testing life) and give backports a go, which is a way of adding updated packages to your stable debian. 

The backports sources list entry looks like 
deb http://ftp.debian.org/debian/ wheezy-backports main

check to see if your packages are available in wheezy-backports by doing a search at packages.debian.org

update apt cache and then install a package from backports with 
sudo apt-get -t wheezy-backports install <package>

Upgrade notes

Wheezy to Jessie

Packages needing re-install after upgrade:
  • with APT... audacious audacious-plugins icedtea-7-plugin lxpanel blueman
  • manual .... googleearth multisystem (ge needs ia32-libs which are obsoleted in Jessie - install a dummy package from /viewtopic.php?f=10&t=111898)
mplayer fails to play files - mplayer error while loading shared libraries: libdvdnavmini.so.4: cannot open shared object file
as root
cd /usr/lib/x86_64-linux-gnu
ln -s libdvdnav.so.4.1.2 libdvdnavmini.so.4

Squeeze to Wheezy
  • on login, the default session shows Xsession, not Xfce 
-in /etc/lightdm/lightdm.conf change user-session=lightdm-xsession to user-session=xfce
  • Broken apt-get after update?
If you choose to keep the original sudoers file, you won't be able to apt-get or aptitude later,
so you need to terminal: su and root p/w
enter visudo
cursor down after the line Defaults  env_reset
highlight this line here and middle mouse button in the terminal to paste it:
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
then CTRL-X, y and Enter
from http://note.harajuku-tech.org/...

Upgrading the kernel

This may be useful (or necessary) when you have hardware that needs latest drivers or to get hot-keys functioning.

Install from Testing on Stable
  • First add Testing to sources (with stable set to default in apt preferences if running a stable Debian install), then apt-get update
  • apt-cache search linux-image to see what kernels are available
  • Install the linux-headers first, e.g. apt-get install linux-headers-3.xx-x
  • reinstall initramfs-tools from testing, apt-get install -t testing initramfs-tools -as without doing this a looping problem is caused with linux-image
  • install corresponding linux-image with aptitude, e.g. aptitude install linux-image-3.xx-x
  • reboot and the new kernel will load automatically

Install newer kernel after upgrade to Jessie
  • apt-cache search linux-image
  • installing linux-headers-3.16-amd64 hit dependency problems, gcc-4.8 needed, but gcc-4.7 installed
  • install in this order: gcc-4.8-base, gcc-4.8
  • apt-get install linux-headers-3.16-amd64 if you need it for compiling the kernel
  • apt-get install linux-image-3.16-amd64