22 – Upgrading Software & Other Administrative Tasks

December 5, 2009 – 10:17 pm

Please note… This information no longer exists at the referenced locations.  This is only a copy of what was available in 2003.

Basic Linux Training™

Upgrading Software & Other Administrative Tasks

Henry White

Table of Contents

Upgrading from a Previous Version

After you have Linux up and running, you may want to leave well enough alone – at least, for awhile. But sooner or later you’ll read or hear about some program and decide you want to install it. Or you may want to upgrade a particular software package you already have to take advantage of some new feature or bug fix.

Most of the major distributions update their releases every 3 to 6 months. You probably will not need to upgrade all of your software that often, but it’s entirely up to you. Some people like to use the latest version regardless of how buggy it may be; others put a premium on stability, and only upgrade when it’s necessary to patch a security hole, or a more recent version is generally considered stable enough for production machines. While you’re still learning, going with the known stable versions throughout your system is probably the best choice; you should be concentrating on mastering a somewhat limited number of applications that are not full of bugs and security holes.

Trying to stay on top of everything takes a huge amount of time. While it may be alright for hard-core geeks, and even necessary for programmers and sysadmins, it’s clearly not necessary for the average user. As you’ll learn in another lesson, applications you don’t use and update can be major security holes for the Bad Guys to break in and do all kinds of mischief ;-) And if you dig a little deeper, you’ll see that it’s a relative handful of known problems that keep coming up, time and again.

Any time you make changes to your system, hardware or software, you would be wise to make a backup. Nasty things can and do happen; so be prepared for them – or more precisely, be prepared to recover from them as quickly and as efficiently as possible. (To put it mildly, ‘No backups, no hope, no sympathy.’)

Some people feel it is better to backup everything you want saved and then reinstall from scratch; I subscribe to this. There is really no benefit in backing up the operating system when you have the CDs. What you need to concentrate on are those packages you have updated since the CD, your configuration files with your preferences and customizations, and, of course, your work – which is otherwise irreplaceable. For example, if you routinely backup /etc and /home (read ‘set up a daily cron job, and test it’), you’ll probably be in excellent shape if/when something goes awry. (Note: this will not, however, preserve everything; for example, you could lose everything in your mail queue (/var/spool/mail).)

If you use the package management tools and utilities, all your installed programs can be upgraded using those tools and utilities. If you have added programs outside of the package management tools, they will not be ‘known’ and will have to be upgraded manually or by going through the package management tools.

There are three major packaging formats – .tar.gz which can be used virtually anywhere; .deb which is used only on Debian and Debian-based distributions; and .rpm which, despite being the most commonly used format is NOT necessarily usable from one distribution using that format to another. Your first choice should always be to get new software packages from the FTP site for the distribution you are using or one of its ‘official’ mirror sites. (We’ve talked about this before – not all distributions use the same hierarchy – configuration files, in fact, whole directories might be in a different location.)

Prior to these packaging formats and package managers, everybody used .tar.gz which worked fine then and still does – for the initial installation. It’s when you go to upgrade software, and particularly the whole system, that you would run into major problems. Ultimately, you had the choice between simply wiping the partition and starting fresh, or pulling your hair out for several days – then finally throwing in the towel and wiping the partition for a fresh install ;-) (Well, actually, some people did master the technique, but it was tedious to say the least and anything but bulletproof.)

(Again, reading the documentation first and keeping notes during the procedure is the best policy. If you kept notes during the initial install, as I suggested, you can look them over before you begin upgrading. If you run into a problem, usually a missed dependency or the wrong version of one of the libraries, you’ll have something tangible to fall back on.

  • Backup your current configuration files – some packages will simply overwrite your existing files, and any changes you have made will be lost.
  • Make a list of the packages you plan to remove and replace.

All the package managers have a sophisticated and usually highly efficient option to update individual packages or the whole system. They are all proprietary (with the exception of Debian which is the only non-commercial major distribution) and the installation and setup tools and utilities, along with the default selection of packages and the default configuration, are the things that distinguish one distribution from another. And being proprietary, this is precisely where each distribution spends the bulk of its effort making their uniqueness better and easier to use ;-)

Unlike what you are accustomed to, in Linux you do NOT have to reboot for new packages or changes to the configuration to take effect. The only time you should have to reboot is when you change the kernel or add new hardware, otherwise simply exit and login again. (For example, if you change /etc/profile, you will have to exit the shell for those changes to go into effect.)

Adding packages

If there’s something on the CD-ROM you want to install, log in as ‘root’ and launch the package manager; there is no need to reboot. If it’s something off the Internet or someone burns a CD for you, be careful where the file came from – it may very well be an .rpm that does NOT work on your distribution. The prime source should be the CD, otherwise the FTP site for your distribution (or one of its mirror FTP sites) is the best place to start; there are other sites that carry tons of packages – just make sure you download packages for your distribution.

The key is that you are always logged in as root when you add or remove packages. This is the only way you can be sure all the files and directories will be created and the links made correctly. However, other applications are not intended for the system, and you can install them without root privileges – an example of this is your individual configuration for fetchmail. (Again, read the documentation first!)

Similarly, if you are using one of the package managers, you can still install a regular tarball – the catch is that it will be outside the package management database, so it won’t be automagically upgraded, etc. This *might* be very handy if you prefer one of the older versions of Netscape, for example, and do not want the latest and greatest version to replace it.

There is a separate package called alien which you can use to reproduce one package format into another format. Note, however, that this works, but it is not the same as getting a properly built .rpm or .deb and will not include any additional information that those formats do.

(Unless you are using a fast connection to the Internet, I strongly urge you to save all the packages you download over the Internet after they are installed – particularly the larger one over 150-250 KB. You may need to reinstall later or make a copy for another machine or a friend.)

tar and gzip

Files are almost always compressed to save storage space and transmission time over the Internet. The preferred format uses the GNU utility gzip which has a .gz extension. Unlike pkzip (which you may be familiar with in DOS/Windows), gzip does not compress more than one file; and, unlike with pkzip, by using gzip the original file is automatically deleted – which can give you a rude awakening if you’re not prepared for it. Similarly, the gunzip utility also deletes the original .gz file.

To combine several files, and entire directory, and all subdirectories into one large archive and retain the original directory structure, the tar utility is used. You cannot use absolute pathnames with tar, however, because the leading slash is stripped off to prevent overwriting existing files when a tar file is unarchived.

You can combine these two utilities – first using tar to create an archive of the directory, subdirectories, and hidden files, then using gzip to compress that archive and delete it so that you are left with the original directory files intact and a tarred and gzipped file of it.

The commands would be something like the following.

    tar cvf newarchive.tar .

Note the trailing dot to specify the current directory will be tarred into the file newarchive.tar

    gzip newarchive.tar

Or you could combine these on the same command line using a pipe; or use another feature of the tar utility to gzip on the fly.

    tar czvf newarchive.tar.gz .

You should read the section in your textbook carefully, as well as the man pages, and try using the various combinations on files and directories that can be easy replaced if damaged or lost in these exercises.

Please note that you will tar first, then gzip to create an archive; gzip deletes the original file – in this case, filename.tar. You probably do not want to delete all the individual files in a directory which you will do by running gzip without tarring the files first.

Backups

Now you really have no excuse for not making backups – just set up a cron job to backup your system files (configuration files) and your data files (your work).

There are much more sophisticated and complex backup software available – probably on your CD. You can learn these, or use whichever one you prefer. I like the simplicity of tarballs, plus the fact that you can read them in mc and lynx which decompress them on the fly.

Assignments

Terms and Concepts:

Define and add these to your glossary:

  • ./configure
  • .deb
  • .gz
  • .rpm
  • .tar.gz
  • .tar
  • .tgz
  • .Z
  • .z
  • /etc/ld.so.conf
  • /lib
  • /usr/lib
  • binary distribution
  • dynamically linked
  • ldconfig
  • source distribution
  • statically linked
  • stub
  • symbolic link

Online:

Check you CD-ROM or the LDP site online at
HOWTO Index


Copyright © 1997-2003 Henry White. All Rights Reserved.
Reproduction or redistribution without prior written consent is strictly prohibited. Address comments and inquiries to info@basiclinux.net

Sorry, comments for this entry are closed at this time.