I've been upgrading Ubuntu installations quite a few times recently, and thought it makes sense to post a really short how-to if you ever want to upgrade your Ubuntu distro from the command line.
Use apt-get to upgrade Ubuntu
The procedure for upgrading one Ubuntu release to another one is pretty straightforward. There are some rules though:
- Never attempt to skip a release or two when upgrading
- Never do a few Ubuntu release upgrades in a row without reboots in between
- Always backup the files you change
- Always have an install CD for your current Ubuntu release around
Upgrading Ubuntu: step by step procedure
There are a few steps involved in every Ubuntu upgrade:
1. Confirm your existing Ubuntu release
/etc/lsb-release file will help you determine the current Ubuntu release you have. In my example, that's what it was:
ubuntu# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=8.04 DISTRIB_CODENAME=hardy DISTRIB_DESCRIPTION="Ubuntu 8.04.1"
2. Change the /etc/apt/sources.list file
This is the file which holds a list of all the repositories to be used by apt-get command (and the rest of the apt commands) to manage packages on your Ubuntu system. It usually looks like this (note how I use grep to ignore the comment lines in the file thus only showing the content that's of interest to us):
ubuntu# cat /etc/apt/sources.list | grep -v ^# deb http://ie.archive.ubuntu.com/ubuntu/ hardy main restricted deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy main restricted deb http://ie.archive.ubuntu.com/ubuntu/ hardy-updates main restricted deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy-updates main restricted deb http://ie.archive.ubuntu.com/ubuntu/ hardy universe deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy universe deb http://ie.archive.ubuntu.com/ubuntu/ hardy-updates universe deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy-updates universe deb http://ie.archive.ubuntu.com/ubuntu/ hardy multiverse deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy multiverse deb http://ie.archive.ubuntu.com/ubuntu/ hardy-updates multiverse deb-src http://ie.archive.ubuntu.com/ubuntu/ hardy-updates multiverse ...
Each line contains a URL of a certain repository and then the Ubuntu release codename and a type of the repository. Without going into details today, I'll just concentrate on the release codename: "hardy" in this example.
What these commands do is confirm that for any updates apt-get should be consulting the specified repositories. In order to upgrade your distribution, we need to change the Ubuntu release codename to the one of the next release – for Intrepid Ibex (Ubuntu 8.10) it's "intrepid".
First, make a copy of the existing /etc/apt/sources.list, and then use sed to generate a new file with hardy replaced by intrepid:
ubuntu# cp /etc /apt/apt/sources.list /etc/apt/sources.list.hardy ubuntu# cat /etc/apt/sources.list.hardy | grep -v ^# ubuntu# cat /etc/apt/sources.list.hardy | sed s/hardy/intrepid/g > /etc/apt/sources.list
3. Use apt-get update command to update the packages list
Now that we have specified the Intrepid Ibex release codename in /etc/apt/sources.list, it's time to make apt-get recognize this by contacting all the repositories mentioned in the file and downloading lists of new packages available from all of them. apt-get maintains a list of available packages in its own database, and that's how yout get it to refresh:
ubuntu# apt-get update 0% [Working] Get:1 http://security.ubuntu.com intrepid-security Release.gpg [189B] Ign http://security.ubuntu.com intrepid-security/main Translation-en_IE Ign http://security.ubuntu.com intrepid-security/restricted Translation-en_IE Get:2 http://ie.archive.ubuntu.com intrepid Release.gpg [189B] ...
It's going to be quite a long list of newly downloaded lists from all the repositories.
4. Use apt-get dist-upgrade to upgrade your Ubuntu release
We're now ready to upgrade your Ubuntu, it will take just one more command and a few hundred megabytes of a download. Once you see this output, simply answer "y" to the question and leave your Ubuntu alone for about an hour to complete the downloads and update all the packages:
ubuntu# apt-get updatedist-upgrade Reading package lists... 0% Reading package lists... 100% Reading package lists... Done Building dependency tree... 0% Building dependency tree... 0% Building dependency tree... 50% Building dependency tree... 50% Building dependency tree Reading state information... 0% Reading state information... 10% Reading state information... Done Calculating upgrade... Done The following packages will be REMOVED: console-tools gimp-gnomevfs gimp-python gtk2-engines-ubuntulooks gtkhtml3.14 libchromexvmc1 libchromexvmcpro1 libffi4 libgail-common libgail18 libgmime-2.0-2 libgnomekbd2 libgnomekbdui2 libperl5.8 myspell-en-us xserver-xorg-video-cyrix xserver-xorg-video-imstt xserver-xorg-video-newport xserver-xorg-video-psb xserver-xorg-video-via The following NEW packages will be installed: bluetooth bluez compiz-wrapper cpp-4.3 cups cups-bsd cups-client cups-common cups-driver-gutenprint firefox-3.0-branding gcc-4.3 gcc-4.3-base gdm-guest-session gstreamer0.10-schroedinger guile-1.8-libs gvfs-bin hunspell-en-us kbd landscape-common libapparmor-perl libapparmor1 libasound2-plugins libavahi-gobject0 libbabl-0.0-0 libbind9-40 libbluetooth3 libcamel1.2-14 libcanberra-gnome libcanberra-gtk0 libcanberra0 libcap2 libcryptui0 libcups2 libdb4.7 libdjvulibre21 libdns43 libebackend1.2-0 libedataserver1.2-11 libelf1 libept0 libffi5 libgdiplus libgegl-0.0-0 libgif4 libglitz-glx1 libglitz1 libgmime-2.0-2a libgmp3c2 libgnome-desktop-2-7 libgnome-keyring1.0-cil libgnomekbd3 libgnomekbdui3 libgnutls26 libgp11-0 libgpm2 libgtkglext1 libgtkhtml-editor-common libgtkhtml-editor0 libgucharmap7 libhunspell-1.2-0 libhyphen0 libijs-0.35 libilmbase6 libisc44 libisccc40 libisccfg40 libltdl7 liblwres40 libmldbm-perl libmpfr1ldbl libmtp8 libntfs-3g28 libopenal1 libopenexr6 libpam-ck-connector libpangomm-1.4-1 libparted1.8-9 libpci3 libpciaccess0 libpcsclite1 libperl5.10 libpoppler-glib3 libpoppler3 libschroedinger-1.0-0 libsilc-1.1-2 libsmbios2 libspectre1 libspeexdsp1 libtalloc1 libtotem-plparser12 libts-0.0-0 libuuid-perl libv4l-0 libwbclient0 libxapian15 libxcb-render-util0 libxcb-render0 linux-firmware linux-headers-2.6.27-9 linux-headers-2.6.27-9-generic linux-image-2.6.27-9-generic linux-restricted-modules-2.6.27-9-generic myspell-en-au openoffice.org-math openssl-blacklist python-cupshelpers python-pexpect python-pkg-resources python-pycurl python-rdflib python-smartpm python-twisted-bin python-twisted-core python-twisted-web python-usb python-xkit python-zopeinterface syslinux sysvinit-utils ubuntu-system-service update-motd usb-creator xinput xserver-common xserver-xorg-video-mach64 xserver-xorg-video-r128 xserver-xorg-video-radeon The following packages have been kept back: ubuntu-desktop The following packages will be upgraded: acl acpi acpi-support acpid adduser alacarte alsa-base alsa-utils anacron apmd app-install-data app-install-data-commercial apparmor apparmor-utils apport apport-gtk apt apt-utils aptitude apturl aspell at at-spi avahi-autoipd avahi-daemon base-files base-passwd bash bash-completion belocs-locales-bin bind9-host binutils binutils-static bluez-cups bluez-gnome bluez-utils bogofilter bogofilter-bdb bogofilter-common brasero brltty brltty-x11 bsdutils bug-buddy busybox-initramfs bzip2 ca-certificates capplets-data cdparanoia cdrdao cli-common command-not-found command-not-found-data compiz compiz-core compiz-fusion-plugins-extra compiz-fusion-plugins-main compiz-gnome compiz-plugins compizconfig-backend-gconf console-setup console-terminus consolekit contact-lookup-applet coreutils cpio cpp cpp-4.2 cron cups-pdf cupsddk cupsddk-drivers cupsys cupsys-bsd cupsys-client cupsys-common cupsys-driver-gutenprint dash dbus dbus-x11 debconf debconf-i18n debianutils defoma deskbar-applet desktop-file-utils dhcp3-client dhcp3-common dictionaries-common dnsutils doc-base dosfstools dpkg dvd+rw-tools e2fslibs e2fsprogs eject ekiga eog esound-common espeak espeak-data ethtool evince evolution evolution-common evolution-data-server evolution-data-server-common evolution-exchange evolution-plugins evolution-webcal example-content f-spot fast-user-switch-applet fdutils file file-roller findutils finger firefox firefox-3.0 firefox-3.0-gnome-support firefox-gnome-support fontconfig fontconfig-config foo2zjs foomatic-db foomatic-db-engine foomatic-db-hpijs foomatic-filters fortune-mod fortunes-min freeglut3 friendly-recovery ftp fuse-utils gcalctool gcc gcc-4.2 gcc-4.2-base gconf-editor gconf2 gconf2-common gdb gdebi gdebi-core gdm gedit gedit-common genisoimage gettext-base ghostscript ghostscript-x gimp gimp-data gimp-help-common gimp-help-en gnome-about gnome-accessibility-themes gnome-app-install gnome-applets gnome-applets-data gnome-cards-data gnome-control-center gnome-desktop-data gnome-doc-utils gnome-games gnome-games-data gnome-icon-theme gnome-keyring gnome-mag gnome-media gnome-media-common gnome-menus gnome-mount gnome-netstatus-applet gnome-nettool gnome-orca gnome-panel gnome-panel-data gnome-pilot gnome-pilot-conduits gnome-power-manager gnome-screensaver gnome-session gnome-settings-daemon gnome-spell gnome-system-monitor gnome-system-tools gnome-terminal gnome-terminal-data gnome-themes gnome-user-guide gnome-utils gnome-volume-manager gnupg gpgv grep groff-base grub gsfonts gstreamer0.10-alsa gstreamer0.10-gnomevfs gstreamer0.10-plugins-base gstreamer0.10-plugins-base-apps gstreamer0.10-plugins-good gstreamer0.10-pulseaudio gstreamer0.10-tools gstreamer0.10-x gtk2-engines gtk2-engines-murrine gtk2-engines-pixbuf gucharmap guile-1.6-libs gvfs gvfs-backends gvfs-fuse gzip hal hal-cups-utils hal-info hdparm hostname hotkey-setup hpijs hplip hplip-data human-icon-theme human-theme ifupdown initramfs-tools initscripts iproute iptables iso-codes jockey-common jockey-gtk klibc-utils klogd landscape-client language-pack-en language-pack-en-base language-pack-gnome-en language-pack-gnome-en-base language-selector language-selector-common language-support-en language-support-translations-en language-support-writing-en laptop-detect laptop-mode-tools launchpad-integration lftp libaa1 libacl1 libalut0 libao2 libapm1 libarchive1 libart-2.0-2 libart2.0-cil libasound2 libaspell15 libatk1.0-0 libatm1 libatspi1.0-0 libattr1 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-compat-libdnssd1 libavahi-core5 libavahi-glib1 libavahi-ui0 libbeagle1 libblkid1 libbonobo2-0 libbonobo2-common libbonoboui2-0 libbonoboui2-common libbrlapi0.5 libbz2-1.0 libc6 libc6-i686 libcaca0 libcairo-perl libcairo2 libcairomm-1.0-1 libcdio-cdda0 libcdio-paranoia0 libcdio7 libcdparanoia0 libck-connector0 libcomerr2 libcompizconfig0 libconsole libcroco3 libcucul0 libcupsimage2 libcupsys2 libcurl3 libcurl3-gnutls libcwidget3 libdaemon0 libdatrie0 libdb4.6 libdbus-1-3 libdbus-glib-1-2 libdecoration0 libdeskbar-tracker libdevmapper1.02.1 libdirectfb-1.0-0 libdmx1 libdrm2 libdv4 libebook1.2-9 libecal1.2-7 libedata-book1.2-2 libedata-cal1.2-6 libedataserverui1.2-8 libedit2 libeel2-2 libeel2-data libegroupwise1.2-13 libelfg0 libenchant1c2a libesd-alsa0 libespeak1 libexchange-storage1.2-3 libexempi3 libexif12 libexpat1 libflac8 libfontconfig1 libfontenc1 libfreetype6 libfs6 libfuse2 libgadu3 libgail-gnome-module libgcc1 libgconf2-4 libgconf2.0-cil libgcrypt11 libgd2-noxpm libgdata-google1.2-1 libgdata1.2-1 libggz2 libggzcore9 libggzmod4 libgimp2.0 libgksu2-0 libgl1-mesa-dri libgl1-mesa-glx libglade2-0 libglade2.0-cil libglib-perl libglib2.0-0 libglib2.0-cil libglibmm-2.4-1c2a libglu1-mesa libgmime2.2-cil libgnome-keyring0 libgnome-mag2 libgnome-media0 libgnome-menu2 libgnome-pilot2 libgnome-speech7 libgnome-vfs2.0-cil libgnome-window-settings1 libgnome2-0 libgnome2-canvas-perl libgnome2-common libgnome2-perl libgnome2-vfs-perl libgnome2.0-cil libgnomecanvas2-0 libgnomecanvas2-common libgnomecups1.0-1 libgnomekbd-common libgnomeprint2.2-0 libgnomeprint2.2-data libgnomeprintui2.2-0 libgnomeprintui2.2-common libgnomeui-0 libgnomeui-common libgnomevfs2-0 libgnomevfs2-bin libgnomevfs2-common libgnomevfs2-extra libgomp1 libgpgme11 libgphoto2-2 libgphoto2-port0 libgpod-common libgpod3 libgraphviz4 libgs8 libgsf-1-114 libgsf-1-common libgsl0ldbl libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 libgtk-vnc-1.0-0 libgtk2-perl libgtk2.0-0 libgtk2.0-bin libgtk2.0-cil libgtk2.0-common libgtkhtml2-0 libgtkhtml3.14-19 libgtkhtml3.16-cil libgtkmm-2.4-1c2a libgtksourceview2.0-0 libgtksourceview2.0-common libgtkspell0 libgtop2-7 libgtop2-common libguile-ltdl-1 libgutenprint2 libgvfscommon0 libgweather-common libgweather1 libhal-storage1 libhal1 libhesiod0 libhtml-parser-perl libhtml-tagset-perl libicu38 libidn11 libieee1284-3 libjasper1 libkeyutils1 libklibc libkpathsea4 libkrb53 liblaunchpad-integration1 liblcms1 libldap-2.4-2 liblircclient0 liblocale-gettext-perl liblpint-bonobo0 liblzo2-2 libmagic1 libmagick10 libmetacity0 libmono-addins-gui0.2-cil libmono-addins0.2-cil libmono-cairo1.0-cil libmono-cairo2.0-cil libmono-corlib1.0-cil libmono-corlib2.0-cil libmono-data-tds1.0-cil libmono-data-tds2.0-cil libmono-security1.0-cil libmono-security2.0-cil libmono-sharpzip0.84-cil libmono-sharpzip2.84-cil libmono-sqlite2.0-cil libmono-system-data1.0-cil libmono-system-data2.0-cil libmono-system-web1.0-cil libmono-system-web2.0-cil libmono-system1.0-cil libmono-system2.0-cil libmono0 libmono1.0-cil libmono2.0-cil libmusicbrainz4c2a libnautilus-burn4 libnautilus-extension1 libneon27 libnet-dbus-perl libnewt0.52 libnl1 libnm-glib0 libnm-util0 libnspr4-0d libnss3-1d libogg0 liboil0.3 liboobs-1-4 libopal-2.2 libopenobex1 liborbit2 libotr2 libpam-gnome-keyring libpam-modules libpam-runtime libpam0g libpanel-applet2-0 libpango1.0-0 libpango1.0-common libpaper-utils libpaper1 libpcap0.8 libpcre3 libpisock9 libpisync1 libpixman-1-0 libpng12-0 libpolkit-dbus2 libpolkit-gnome0 libpolkit-grant2 libpolkit2 libpopt0 libpt-1.10.10 libpt-1.10.10-plugins-alsa libpt-1.10.10-plugins-v4l libpt-1.10.10-plugins-v4l2 libpth20 libpulse-browse0 libpulse0 libpulsecore5 libpurple0 libqthreads-12 librarian0 libraw1394-8 librecode0 librpc-xml-perl librsvg2-2 librsvg2-common libsamplerate0 libsane libsasl2-2 libsasl2-modules libscim8c2a libscrollkeeper0 libsdl1.2debian libsdl1.2debian-alsa libselinux1 libsensors3 libsepol1 libsgutils1 libshout3 libsigc++-2.0-0c2a libslang2 libslp1 libsm6 libsmbclient libsnmp-base libsnmp15 libsoup2.4-1 libspeex1 libsqlite3-0 libss2 libssl0.9.8 libstdc++6 libtag1c2a libtasn1-3 libterm-readkey-perl libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtheora0 libtiff4 libtracker-gtk0 libtrackerclient0 libuniconf4.4 libusb-0.1-4 libusplash0 libuuid1 libvisual-0.4-0 libvolume-id0 libvorbis0a libvorbisenc2 libvorbisfile3 libvte-common libvte9 libwavpack1 libwnck-common libwnck22 libwpd8c2a libwpg-0.1-1 libwps-0.1-1 libwrap0 libwvstreams4.4-base libwvstreams4.4-extras libwww-perl libx11-6 libx11-data libx11-xcb1 libx86-1 libxau6 libxaw7 libxcb-xlib0 libxcb1 libxcomposite1 libxdamage1 libxdmcp6 libxevie1 libxext6 libxfont1 libxft2 libxi6 libxinerama1 libxkbfile1 libxklavier12 libxml-parser-perl libxml2 libxml2-utils libxp6 libxrandr2 libxrender1 libxslt1.1 libxss1 libxtrap6 libxv1 libxxf86misc1 libxxf86vm1 libzephyr3 linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-common linux-restricted-modules-generic linux-sound-base locales login logrotate lsb-base lsb-release lshw lsof ltrace lzma make makedev man-db manpages mawk memtest86+ mesa-utils metacity metacity-common mime-support min12xxw mktemp mlocate module-init-tools mono-common mono-gac mono-jit mono-runtime mount mousetweaks mscompress mtr-tiny myspell-en-gb myspell-en-za nano nautilus nautilus-cd-burner nautilus-data nautilus-sendto nautilus-share net-tools netbase netcat netcat-traditional network-manager network-manager-gnome notification-daemon ntfs-3g ntpdate nvidia-kernel-common obex-data-server openoffice.org-base-core openoffice.org-calc openoffice.org-common openoffice.org-core openoffice.org-draw openoffice.org-gnome openoffice.org-gtk openoffice.org-help-en-gb openoffice.org-help-en-us openoffice.org-hyphenation-en-us openoffice.org-impress openoffice.org-l10n-common openoffice.org-l10n-en-gb openoffice.org-l10n-en-za openoffice.org-style-human openoffice.org-thesaurus-en-au openoffice.org-thesaurus-en-us openoffice.org-writer openprinting-ppds openssh-blacklist openssh-client openssh-server openssl parted passwd pciutils perl perl-base perl-modules pidgin pidgin-data pidgin-otr pm-utils pnm2ppa policykit policykit-gnome poppler-utils popularity-contest powermgmt-base powernowd ppp pppconfig pppoeconf procps pulseaudio pulseaudio-esound-compat pulseaudio-module-gconf pulseaudio-module-hal pulseaudio-module-x11 pulseaudio-utils pxljr python python-apport python-apt python-brlapi python-cairo python-central python-cups python-dbus python-gconf python-gdbm python-glade2 python-gmenu python-gnome2 python-gnome2-desktop python-gnomecanvas python-gobject python-gst0.10 python-gtk2 python-gtkhtml2 python-gtksourceview2 python-imaging python-launchpad-bugs python-launchpad-integration python-libxml2 python-minimal python-notify python-numeric python-problem-report python-pyatspi python-pyorbit python-software-properties python-support python-uno python-virtkey python-vte python-xdg python2.5 python2.5-minimal rdesktop readahead rhythmbox rss-glx rsync samba-common scim scim-bridge-agent scim-bridge-client-gtk scim-gtk2-immodule scim-modules-socket screen scrollkeeper seahorse sed shared-mime-info smbclient software-properties-gtk sound-juicer splix sqlite3 ssh-askpass-gnome ssl-cert startup-tasks strace sudo synaptic sysklogd system-config-printer-common system-config-printer-gnome system-services system-tools-backends sysv-rc sysvutils tangerine-icon-theme tar tasksel tasksel-data tcpd tcpdump thunderbird-locale-en-gb time tomboy toshset totem totem-common totem-gstreamer totem-mozilla totem-plugins tracker tracker-search-tool transmission-common transmission-gtk tsclient ttf-arabeyes ttf-arphic-uming ttf-dejavu-core ttf-freefont ttf-indic-fonts-core ttf-kochi-gothic ttf-kochi-mincho ttf-malayalam-fonts ttf-opensymbol ttf-thai-tlwg ttf-unfonts-core tzdata ubufox ubuntu-artwork ubuntu-docs ubuntu-gdm-themes ubuntu-minimal ubuntu-sounds ubuntu-standard ubuntu-wallpapers ucf udev ufw unattended-upgrades unzip update-inetd update-manager update-manager-core update-notifier update-notifier-common upstart upstart-compat-sysv upstart-logd usbutils usplash usplash-theme-ubuntu util-linux util-linux-locales uuid-runtime vbetool vim-common vim-tiny vinagre vino w3m wamerican wbritish wget whiptail whois wodim wpasupplicant wvdial x-ttcidfont-conf x11-apps x11-common x11-utils x11-xkb-utils x11-xserver-utils xauth xbase-clients xdg-user-dirs xdg-user-dirs-gtk xdg-utils xfonts-utils xinit xkb-data xml-core xorg xsane xsane-common xscreensaver-data xscreensaver-gl xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-kbd xserver-xorg-input-mouse xserver-xorg-input-synaptics xserver-xorg-input-vmmouse xserver-xorg-input-wacom xserver-xorg-video-all xserver-xorg-video-amd xserver-xorg-video-apm xserver-xorg-video-ark xserver-xorg-video-ati xserver-xorg-video-chips xserver-xorg-video-cirrus xserver-xorg-video-dummy xserver-xorg-video-fbdev xserver-xorg-video-geode xserver-xorg-video-glint xserver-xorg-video-i128 xserver-xorg-video-i740 xserver-xorg-video-i810 xserver-xorg-video-intel xserver-xorg-video-mga xserver-xorg-video-neomagic xserver-xorg-video-nsc xserver-xorg-video-nv xserver-xorg-video-openchrome xserver-xorg-video-rendition xserver-xorg-video-s3 xserver-xorg-video-s3virge xserver-xorg-video-savage xserver-xorg-video-siliconmotion xserver-xorg-video-sis xserver-xorg-video-sisusb xserver-xorg-video-tdfx xserver-xorg-video-tga xserver-xorg-video-trident xserver-xorg-video-tseng xserver-xorg-video-v4l xserver-xorg-video-vesa xserver-xorg-video-vga xserver-xorg-video-vmware xserver-xorg-video-voodoo xsltproc xterm xulrunner-1.9 xulrunner-1.9-gnome-support xutils xutils-dev yelp zenity zlib1g 939 upgraded, 127 newly installed, 20 to remove and 1 not upgraded. Need to get 582MB of archives. After this operation, 304MB of additional disk space will be used. Do you want to continue [Y/n]? n
5. Reboot and enjoy the upgraded system
Reboot your Ubuntu:
ubuntu# shutdown -i6 -r now
… and once your system is back up, you're ready to verify that it's been successfully upgraded:
ubuntu# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=8.10 DISTRIB_CODENAME=intrepid DISTRIB_DESCRIPTION="Ubuntu 8.10"
That's it, good luck with your Ubuntu upgrade!
Related books
If you want to learn more about Ubuntu, here's a great book: