
If you’re like me, which is a debian/ubuntu user who likes to instal 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.
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.
geek out.















September 21st, 2006 at 10:11 pm
sudo apt-cache search neverball
sudo is not necessary here. Normal users can apt-cache.
September 22nd, 2006 at 7:55 am
Hi Ben,
That’s true, but I like the sense of power I get when I sudo things. It’s like my linux box is a tiny little universe, and I, SUDO USER COMMAND AND CONTROL ALL FUNCTI… er. Yeah. You can do that as a normal user.
geek out.
September 22nd, 2006 at 1:17 pm
You might also be interested in deborphan:
Package: deborphan
Description: Find orphaned libraries
deborphan finds “orphaned” packages on your system.
It determines which packages have no other packages
depending on their installation, and shows you a list of
these packages. It is most useful when finding libraries,
but it can be used on packages in all sections.
Its output is simple so that you can do this:
$ sudo apt-get remove –purge `deborphan`
September 22nd, 2006 at 1:23 pm
So if you apt-get remove package, does that remove all of the packages installed as dependencies that aren’t being used by any other explicitly installed packages?
This has been bugging me for a while now, and nothing that I’ve seen so far seems to adequately answer it.
September 22nd, 2006 at 1:26 pm
Hey Mausen,
It does. Sometimes. Sometimes if dependancies aren’t removed, you can use Benj’s suggestion of deborphan to get rid of them.
geek out
September 22nd, 2006 at 2:53 pm
I have been using apt-get for a long time. Practically, I run apt-get update and apt-get dist-upgrade almost everyday. My system is a development version of Ubuntu Edgy Eft, thus there is always something new everyday.
September 22nd, 2006 at 5:42 pm
aptitude is preferred to apt-get as it handles dependencies and orphaned packages much better.
Furthermore, aptitude has both a CLI that resembles apt-get and
a curses interface.
September 22nd, 2006 at 9:15 pm
aptitude seems to be better than apt-get. imagine you installed ubuntu-desktop: a metapackage that install more than a gigabyte of data. what if you wanna switch to xubuntu-desktop? (un)install ubuntu-desktop with apt-get and you will have all that hard disk space still occupied. but if you installed the package with aptitude and now uninstall it with aptitude, than you will get rid of all the packages it installed as well…
2 disadvantages of aptitude:
* apt-get is much better (longer) tested
* synaptic works with apt-get, not aptitude.
September 23rd, 2006 at 9:55 am
“First, let’s see if there really is a program out there called Neverball.
sudo apt-cache search neverball
We can see that yes…”
Ok, what if it doesn’t?
September 23rd, 2006 at 12:00 pm
Hey Iker,
It probably means you don’t have the correct repositories set up. See:
http://www.arsgeek.com/?p=502
and
http://www.arsgeek.com/?p=515
geek out
September 25th, 2006 at 6:34 am
You can also download development packages for compilling a program with sudo apt-get build-dep neverball and you can compile with with sudo apt-get –build source neverball. Usefull if you find a package that doesn’t match your distro or architecture. Also does anyone know if there is a command that allows you to download the .deb package to your home folder without installing it so you can install it later?