Continuing from here

First page here

7.  Updating your system

We’ve just got a spot of housekeeping to do before installing some stuff to turn your pi into something useful.  We are going to do a system update to make sure we are running the latest version of everything.  And I mean everything.  The update will not only update the operating system, but all your installed software.  All your Pi’s software comes from a “repository” on the internet of pre-compiled software packages, created by the people who made the Raspbian distribution – over 35,000 packages in total, covering pretty much anything you might want your Pi to do: web server, media server, media streamer, torrent client, DNS, web browser (yes, a text only web browser) and so on.  Each package contains software, configuration files, manual pages, and scripts needed to set the software up after install.  You can install packages from outside the repository or compile your own software, but that is a bit more advanced and everything we need is included in the Raspbian repository.

Software is maintained on a your Pi’s Debian-based Linux system, Raspbian, with a set of utilities called Apt, which is short for “Advanced Package Tool”.  It keeps a track of all the installed software packages, what version they are, if they need updating, and other packages required by each package.  That last one is important.  Most packages will rely on other packages being installed on your Pi in order to work.  From a programmer’s point of view, there is no point in re-inventing the wheel if you want a feature in your program (let’s call your program “Program A”) that has already been created by someone else in Program B.  The programmer can tell program A to call up Program B when this feature is needed.  Then, when the repository maintainer creates Program A’s package for the Raspbian repository, the maintainer adds a specification to the package that tells Apt to check that the package containing Program B is already installed on the Pi.  If it is then that’s fine and dandy, but if it’s not, Apt will nip off and download Program B’s package too.  Of course, it then has to check if the Program B’s package needs any other packages to be installed on the Pi, download them if they aren’t installed, check those ones…, and so on until all the packages are happy.  Keeping track of all these interlinking packages, each depending on the other (package B is called a “dependency” of package A), would be a nightmare to do yourself, so thank goodness for Apt, which does it all for you.

You might think that it sounds a bit complicated, but it’s not.  You will soon see how easy it all is to use.  Then you might start feeling sorry for Windows users and the pain they have to go through – finding the software, downloading it (Windows downloads are usually bigger as they don’t have Linux’s dependency system), going through the install procedure and then finding that the installer just splatted a load of crapware all over their PC.  Do not pity them though.  They have chosen their path.  It’s quite similar (and predates by many years) the “App” system used by Apple, Android etc., except it is far more flexible and doesn’t restrict you to one source of packages.

But back to the updating… Let’s start off by getting a list of software that needs updating.  Type sudo apt-get update and you should see something like this:

naich@raspberrypi ~ $ sudo apt-get update 
Get:1 http://mirrordirector.raspbian.org wheezy InRelease [12.5 kB] 
Get:2 http://archive.raspberrypi.org wheezy InRelease [7,698 B] 
Get:3 http://mirrordirector.raspbian.org wheezy/main armhf Packages [7,296 kB] 
... and so on for a bit... 
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en 
Fetched 7,388 kB in 48s (151 kB/s) 
Reading package lists... Done 
naich@raspberrypi ~ $

Lovely jubbly.  It’s got a list of all the latest packages.  Let’s process all the packages that need upgrading to a later version.  Type sudo apt-get upgrade:

naich@raspberrypi ~ $ sudo apt-get upgrade 
Reading package lists... Done 
Building dependency tree Reading state information... Done 

The following packages will be upgraded: 
bash dictionaries-common file idle3 krb5-locales libgssapi-krb5-2 
libk5crypto3 libkrb5-3 libkrb5support0 liblapack3 liblapack3gf 
libmagic1 libpulse0 libsystemd-login0 libtiff4 libxapian-dev libxapian22 
libxml2 libxml2-dev libxslt1-dev libxslt1.1 nfs-common omxplayer 
python3 python3-minimal tasksel tasksel-data udisks vim-common vim-tiny 
xserver-common xserver-xorg-core 

32 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 
Need to get 23.0 MB of archives. 
After this operation, 1,183 kB of additional disk space will be used. 
Do you want to continue [Y/n]?

Do you want to continue?  You do.  And away it goes, upgrading it’s little silicon heart out.  Very rarely, you might see something like this:

Configuration file `/etc/skel/.bashrc'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
 What would you like to do about it ? Your options are:
 Y or I : install the package maintainer's version
 N or O : keep your currently-installed version
 D : show the differences between the versions
 Z : start a shell to examine the situation
 The default action is to keep your current version.
*** .bashrc (Y/I/N/O/D/Z) [default=N] ?

This means that Apt has found a configuration file that been changed since the package was installed.  Unless you have made the change yourself, it’s safest to choose “Y” to install the new version which will be compatible with the updated software. A backup of the old config file will be saved in case the new one doesn’t work so you can examine them later to see the differences and fix them if necessary.

Warnings can generally be ignored.  Things like this probably don’t mean much to you:

insserv: warning: current start runlevel(s) (empty) of script `nfs-common' overwrites defaults (2 3 4 5 S).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6 S) of script `nfs-common' overwrites defaults (0 1 6).

And to be honest it doesn’t mean that much to me either.  It looks like it’s saying that the nfs server isn’t automatically started on runlevels 2-5 any more.  Possibly.  We aren’t using nfs so we don’t care; we’ll cross that bridge if we come to it.  My Pi seemed to work OK after those warnings, so I didn’t worry about them.  Make a note of warnings, just in case you need to find a problem later, but don’t worry about them unduly.  “warning: ” means something unexpected has happened but Apt can keep going.  Errors, however, can’t be ignored.  “error: ” means something so bad has happened that Apt can’t continue.  If you ever see an error, the best thing to do is to copy and paste it into Google to find someone else who has had the same problem and has hopefully fixed it.

You want to go through this procedure (“apt-get update” followed by “apt-get upgrade”) every now and again to make sure your system is up to date.  Most updates are due to bugs regarding security and are closing avenues of attack for hackers, so you want to install them.  I do it about once a week.

There is also another type of upgrade – apt-get dist-upgrade. This upgrades your system to the latest stable release.  This means that it won’t just upgrade your packages for bug fixes and security patches, it will upgrade all your software to the version included in the current stable release of your distribution, as if you downloaded and installed it from scratch.  This is a more serious upgrade and should only be undertaken if you’ve got a bit of spare time to fix anything that might get broken.  You are likely to see those messages about the configuration files and might have to edit upgraded ones to get things working again.  If you start seeing messages during your “apt-get upgrade” that packages have been “held back”, it means that you should probably start thinking about doing a “dist-upgrade”.

Continued here…