If you’re like me, which is a debian/ubuntu user who likes to install new and use(ful)(less) software all the time, then apt will be an important part of your life. It’s time too look into a powerful program used in the Debian world. Apt covered by ArsGeek.
Let’s open up a command line and start looking at what apt can do. We’re going to use one the most addictive and soul-sucking computer games ever invented. Neverball.
First, let’s see if there really is a program out there called Neverball.
sudo apt-cache search neverball
We can see that yes, there is a program out there called neverball, and it also has a file called neverdata associated with it.
Let’s get some more info, like a description, size, version and a whole bunch more.
sudo apt-cache show neverball
Sound interesting? Great! Let’s install it.
sudo apt-get install neverball
Type ‘Y’ or hit enter to continue. Notice that you don’t have to tell apt to get neverdata as well? Apt will take care of pesky things like dependancies for you. It will also tell you if there are any recommended programs. In this case, there won’t be.
If you’ve already got the program on your system, but want to reinstall it for some reason (perhaps you hacked it a bit and really broke things *blush*) then use the – -reinstall switch. NOTE: that’s two dashes, no space. You’ll have to correct this if you cut and paste into a CLI from this site.
sudo apt-get install neverball - - reinstall
Now after a few months when you unglue your face from your screen and you’ve completed all 60 or so neverball levels, you decide to remove it from your system. This has nothing to do with your wife demanding that you do so, or your children asking you “who are you again?” and is done completely of your own free will.
sudo apt-get remove neverball
And if you REALLY want to get rid of something (including any config files and in this case completed levels) then try
sudo apt-get remove neverball - - purge
So now you know how to install and remove programs. Let’s look at what to do now to keep your system up to date using apt.
First, you’ll want to let your computer know exactly what’s out there. You have a file in /etc/apt/ called sources.list. This is a list of all of the places your computer will go to look for stuff to install. The software packages are constantly changing, with new ones being added and old ones being updated. So let’s tell your computer to check with these repositories and find out what’s going on.
sudo apt-get update
Now that your computer knows what’s new, let’s have it update the software on your machine. There are two was to do this, the simple upgrade way, and the complete (read: smart) upgrade way. Here’s what I’d recommend doing:
sudo apt-get dist-upgrade
That’s the smart way. dist-upgrade handles changing dependancies (say neverball gets a new release with a new library) while doing apt-get upgrade will not handle this.
Even with the best intentions, things sometimes break. Many times broken dependancies can be fixed by issuing this command:
sudo apt-get -f install
So we’ve got programs installed, we know how to get rid of them and we know how to upgrade them. Let’s find out what we need to run them. Apt is pretty good at handling this for you but I’m a curious guy so I like to know things. Do you know what dependancies neverball has?
sudo apt-cache depends neverball
Now we see what you need to have in your install to get neverball to run. You can also do the reverse as well. Let’s take libc6, one of neverball’s dependancies. What else depends on this?
sudo apt-cache rdepends libc6
Lots of stuff! That’s probably why it wasn’t installed when we installed neverball. It was already on your system.
You can also do most, if not all of this through synaptic but it’s always good to know your CLI stuff, especially if you *ahem* completely destroy your GUI ability and need to restore it.