Also acta

Debian Squeeze with OpenBox

Debian GNU/Linux - Squeeze with OpenBox
If you can walk and chew gum at the same time, you can run GNU/Linux

debian tutorials
debiantutorials.org is built on and runs on Debian.

 

Creative Commons License
Intro to Basic Package Management on your Debian Machine Print E-mail
Written by machiner   
Monday, 10 December 2007 19:00

New users to a Linux distribution typically fall into 2 categories: Those that are put off by the subtle differences they see in how the operating system presents itself, and those that embrace the methodology of how they can now work. Or play. As in life, if we can be OK with subtle differences, we are usually better off. We are at our best when we are constantly evolving.

Using Linux for a short while will no doubt introduce you to new and more efficient ways of doing things. Take, for instance, managing your software. As a new Linux user you might not be at all familiar with actually managing your system's software. In the past you may have searched for and hoped for the best when you downloaded some shareware that claimed to suit your needs. If lucky, you were satisfied with your choice. If you were luckier still, the software that you installed played nice with your system. Many times this is a hit or miss proposition. Not so on your Linux box.

Linux distributions typically come with a package manager. They can be command-line or a more familiar GUI (Graphical User Interface) program. In fact, many people and companies have seen Linux package managers in action and have decided to try Linux based on this one function. It's a terrific reason, no doubt, but it's the same mentality that makes us a sucker for "WOW!". We're all the same -- we see some whiz-bang thing and we gotta have it. Well, hold your horses --.

You can't fault anyone for wanting solid and reliable package management. After all, the Linux distribution that you are using right now was built to work as a desktop operating system. The end package is a terrific draw. It has terrific appeal. You see, Linux is merely a kernel, a "brain", with a few utilities thrown in for good measure. By itself, it doesn't do a lot of us any good. However, when a team, company, or your old Uncle Ed decides to build a Linux distribution based upon a particular kernel, the finished product can be quite spectacular. Well, as far as computers and operating systems go. It doesn't compare to that sunset in Maui.

With a Linux desktop distribution you get the kernel, utilities, and then you get all the software and components necessary to give you a total desktop package. You will find office software, 3d rendering utilities, drivers for your hardware, and any number of obscure and/or cutting-edge software to help you work and play. All tied together and all maintained and updated continually for your pleasure.

As I have written -- it's a big draw. One of the most popular and certainly most important of Linux distributions is Debian GNU/Linux. Its developers created a package manager called Apt some years ago and it is so reliable and simple that many other distributions have decided to employ it as well. The concept is brain-dead simple. House all distribution version related software on central server in "repositories". They are available 24 hours a day and accessible right from your desktop. On you computer's side, you will have a file which contains the addresses of any number of repositories available for your use. On a Debian box you will find that file here: /etc/apt/sources.list When you use your package manager it uses that file to access the server locations contained in it and updates or add/removes software of your choosing against whatever is available on the servers. In the case of Debian that means you have better than 20,000 packages available to you. Ya -- I know. Try to be cool. :)

How you utilize this function depends upon your style of computing. Many of us are at home typing commands into a terminal, or the "command-line". Still, many more of us want to use a GUI front-end. The developers have heard us! Open Synaptic and you are greeted with a well put together GUI program that lets us manage our packages simply. Click a button to update the repository lists -- click another to check for any updates. Click another one still to update everything on your system that needs it in one quick action. Bam!

Within Synaptic you can change or add/remove repositories. This is needed because distributions like Debian have very strict guidelines for what software can be included in its distribution. Debian will not include software that is not "free" within its distribution. This can be problematic when your video card needs a proprietary driver in order to be utilized fully -- like giving you sweet 3d acceleration. Not to worry. Within your Synaptic program you can choose the repositories to use. There are 3 main branches of a Debian repository:

main -- Totally free software; use it, mod it, hawk it thus.
contrib -- Free to use software, but still restricted in some ways
non-free -- Software that is not free. Free to use, but no poking around.

Many desktop users will have all three repositories enabled as some software they need or want is not available in main. When non-free is used extra desktop functionality like Java and nVIDIA is available to you. Adding the non-free or contrib repositories is no cause for concern. Software from these sections will not mess with the stability of your system, however, it's also not supported should something go wrong. Adding proprietary stuff to your distribution is on you. I'm only writing that because we live in a cover-your-butt society. Debian developers have considered your proprietary needs -- your installing of the nVIDIA binary that you downloaded will not wreak havoc on your system.

You can see that with a program like Synaptic it's very simple and even a pleasure to manage the software on your system. However, it's important to be at lease comfortable with the command-line functionality that Synaptic is a pretty front-end to. On Debian, Synaptic will not be installed by default. You must install it yourself, but it's a very simple thing.

As you now know, Synaptic is just a pretty face. The real action is all Apt. It's the real function behind Synaptic. Using apt happens on the command-line and it couldn't be more simple. Merely knowing a few basic commands can keep your system rolling very quickly. Let's explore Apt just a bit, after all, you'll be using it to install Synaptic anyway.

Fire-up your terminal and become root. If you don't know this now, you need to -- a regular user cannot affect a Linux system. All the files located in directories other than /home/user are protected and can only be modified by the root user -- the "administrator" of the machine. This is a good thing. When you become root at the terminal you will see the $ prompt change to a # prompt. You may even see the prompt in a different color. Red, perhaps. You should only ever become root in a terminal and never run a desktop as root. Too much can go wrong.

Now that you're the root user in your terminal you can begin to affect system changes. First thing first -- update apt, run this command:

# apt-get update

You'll see a list of web server addresses go by as apt accesses each one and updates its internal package versions against what is currently available on the repository servers. There may be none. With Debian a release is a release and no software is ever updated except for security changes. This means that you will stay with cool-software-2.1.0-3 until the next release of Debian. This gives you the chance to get proficient and fully utilize the software -- nothing will change as far as you're concerned, but you will all ways have any necessary security updates. You will not have to wait until Tuesday to employ a shaky patch.

After you've updated your repos and your system has the latest information you can run the next command:

# apt-get upgrade

This command will actually do the upgrading. All security updates will be downloaded and utilized and any ancillary packages necessary to allow any security updates will be downloaded and installed. As well, any software that would conflict with the update will be removed from your system. All neat and tidy, all almost effortless. Most important of all - you did this from within your own desktop.

For all of the goodness and simplicity of Apt/Synaptic, there is a better program still for your Debian system. I'll explain the problem first. Dependencies. Dependencies, dependencies, dependencies.....it's the scourge of longtime Linux users and we have all suffered it. To me it's no big deal and I get to see what programs other ones interact with or need in order to function properly. To a Geek-to-the-bone like me, dependencies aren't such a big deal. However, then can make you crazy.

Program A needs programs E, G and Z to function properly. Program Z needs programs L, and F, and program G needs programs B and Q. Oy! If you're downloading a .tar file that you need to compile (we can discuss this later) and the website that you found this must-have software on doesn't tell you all the requirements the software needs to run -- you just might run into a big mess.

This "dependency-hell" isn't so prevalent among the Debian based distros because of how software for a Debian system is offered/maintained (Apt). You mostly see this dependency nightmare among the "rpm" based distros. It's better now with the evolution of package managers like Yum, but in the past it bugged me, too. And it can still bite you.

Apt handles all your dependencies if you install software from the 3 branches of a Debian repository -- main, non-free, contrib. In fact, with all that's available to you there, you may never need to download a thing. However, you may want a newer version of a program -- just because that's how you are. That's cool. You'll have to download and compile it yourself. Dependencies, dependencies, dependencies.

You might be thinking right about now -- Pfft!, I don't deal with this on a Windows system. You'd be incorrect. You absolutely deal with this, but a little differently. First off, the software that you download to install has not been designed to work with your machine as it's built. The software is designed to work on the platform, but not with all of the other software on your system. Because of this, the .exe file that you download is a collection of all the dependencies necessary to install and run that software on your system. Sure, convenient. Simple and trouble-free it is not. Some of the supporting aspects of the shareware you just downloaded might be the same as what's already on your system -- but a different version. Here is where this becomes bad-medicine. The software that you are about to install will actually overwrite the version that your system already has. In fact, the developers for Windows have had to build in protections against this -- which to me is applying a band-aid to a compound-fracture.

On your Linux box, your system files will not be overwritten. Consider this. Programs on your Linux box employ a "config" file. It's a file that contains all the settings and what-not that the software needs to run properly. Everything is a file in Linux and it's terrifically easy to maintain because of this. Should you install a program that is employing a different configuration file than the one currently employed, your system will let you know and ask you how to proceed. You will be allowed to keep your current configuration file, which is the default behavior, replace it with the new one, or even allow no action until further review. That's a feature I want.

Now we can appreciate a little the nature of software. You've no doubt heard many times in your life that nothing exists in a vacuum. True enough, and software is no exception. The nature of software development is to reuse the objects, functions, tools that work. Re-creating the wheel is inefficient. One object might be used in 28 different software titles so that object becomes a dependency. All platforms use this methodology.

Now that we can be comfortable with dependencies I will introduce my favorite package manager. Your Debian system does come with this one installed by default (like Apt, but not Synaptic) and is ready to go as soon as you are. Many people say that only Gurus use Aptitude, but I disagree. It's just as simple as Apt and just as welcoming to new users. To me, though, it's cursed based interface is confusing. People seem to like it, but I can't wrap my brain around it. However, the command-line usage is a "no-brainer", just like with Apt.

Let me explain why I like Aptitude better. Remember dependencies? Many dependencies come in the form of "libraries". Consider the ".dll" file on a Windows system. It's a reusable system file that many programs might use. Libraries are exactly the same. One particular library might need to be installed for a particular class of software to function properly. You can find out what programs need what libraries, but we'll save that until later. Package management has a lot of meat to it and this introductory article should be just that. We will dig deeper later.

With Aptitude managing your system you don't have to worry about stray dependencies being left behind on your system. Unused. We call it "lint". Apt will not remove lint when you remove the package that you installed that needed this dependency (UPDATE: this all changes with the apt version in Lenny). However, Aptitude will. This is a big draw. Most users don't worry about space or efficiency because their hard drives are so vast. However, some of us do -- especially those of us running servers. Nothing remains on a server that isn't being used. Most server admins use Aptitude from the get go. But you don't have to be a "guru".

When you install a program with Aptitude it will note and remember any and all dependencies that were installed with it. When/if you ever remove said program Aptitude will remove the lint along with it. If it sees a library will no longer be necessary, it removes it. That is cool. However, to enjoy this kind of efficiency you must know 2 things:

Aptitude will install "recommends" by default. This makes for more software installed that you might not want. Recommends are extra software and they are not absolutely necessary for the given program to work properly -- however, they are supporting programs that make sure that all of the program's functionality that you want will be available to you. Also, you must have been using Aptitude form the very beginning. For instance, if you have built your system using Apt, then Aptitude will have no record of dependencies, etc. and will not remove lint when you remove software. However, as with anything Linux related -- there is a way. Here's a big tip: You can make Aptitude recognize all previously installed packages and give Aptitude control over all your software and dependencies, but you'll need a while, like maybe an hour, and you'll need a little savvy to know what to keep and what to allow Aptitude to remove.

You can run the following command to give Aptitude control over your system's packages/programs:

# for pkg in $(aptitude search ~i | grep -v "i A" | cut -d " " -f 4); do echo "-- markauto $pkg --"; aptitude markauto $pkg; done

Aptitude will go through all of the software you have installed, learn about it, record dependencies, etc. and offer you a choice of keeping or removing what it considers to be useless software. Listen, though -- you can remove software you like this way and have to reinstall it later. So be careful.

I hope this brief article has introduced you enough to a terrific aspect of Linux and that you will want to learn more. There is much more to learn about package management and some if it will be a godsend for you. As with all new things -- take it slow, consider the pains and penalties of mistakes, and keep that open-minded attitude. There are great rewards.

-- machiner 11 Dec 07, published mar 08

Learn more in the forum thread.

Here's a more recent article about managing Debian software.

Last Updated on Sunday, 28 June 2009 07:12