Debian Upgrade to 9

Debian Distro upgrade. For this example we are upgrading from jessie to stretch
A)
# apt-get update
# apt-get upgrade
# apt-get dist-upgrade

sed -i 's/jessie/stretch/g' /etc/apt/sources.list

B)
# apt-get update
(if you receive a error similar to E: Release file expired. run apt-get -o Acquire::Check-Valid-Until=false update )
# apt-get upgrade
# apt-get dist-upgrade

C)
some housekeeping after the upgrade. The below commands will remove old packages from the system
# Check dpkg -l | awk '/^rc/ { print $2 }'

Process
# apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')
# apt-get autoremove