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
-this command replaces "aptitude dist-upgrade" - it will present solutions to conflicts, and ask confirmation before downloading
It can be 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)

You could 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 - note that some packages are obsoleted and replaced with one of different name).

I upgraded just now 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 change sources to testing again, update lists and do a dist-upgrade. 
The plain "upgrade" command will not add any new packages or remove unneeded ones -which is necessary when upgrading to another release.

Upgrading to Jessie without installing systemd

su to root then make this apt conf file with
echo -e 'Package: systemd\nPin: origin ""\nPin-Priority: -100' > /etc/apt/preferences.d/systemd

You may also need to deny "upstart" (ubuntu's startup daemon) from installing as well
echo -e '\nPackage: upstart\nPin: origin ""\nPin-Priority: -100' >> /etc/apt/preferences.d/systemd

then run a dist upgrade with the simulate option to check what will install - and aptitude should be used

note that policykit-1 will not install because it depends on libpam-systemd!  This means there may be some errors on startup, hotplugging media will not work (mounting) and there will be no shutdown/reboot option on the logout menu!  (this is so with LXDE, as the update removes lxsession, lxpolkit)

To get around these problems, I use a power-off script with a yad dialogue, udevil disk management (see my plain OB page), and to prevent the dbus error messages on media insert, turn off the auto-mounting in pcmanfm preferences.

But we might not have the pleasure of choosing sysvinit over systemd for much longer, with Debian, who knows?  If we can't carry on without switching to systemd, then our other choices are... Devuan, or Slackware, which continues to be systemd-free (that's not a package name!) 

See my Devuan page!

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>

Upgrading the kernel

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

Install the pae kernel for newer computers
  • search for available kernels with apt-cache search linux-image 
  • install the pae kernel
  • reboot and select the new kernel if necessary
  • if it runs well and fixes hardware issues such as video or networking, you can remove the non-pae kernel with apt-get
  • find its package name with dpkg --list | grep linux 

Install from stable backports
  • add the backports to sources with the line deb http://ftp.debian.org/debian/ wheezy-backports main non-free contrib
  • update APT and search for available kernels with apt-cache search linux-image 
  • install the kernel desired kernel

Install from Testing on Stable - note that this method may install quite a lot of packages from testing and you could end up with a mixed distro Debian.
  • 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


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/...