RSS

All you ever wanted to know about apt for Ubuntu/Debian Linux

Thu, Sep 21, 2006

ArsGeek, Linux, Ubuntu

Talk about it in our Forums

apt-get geek

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.

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

11 Comments For This Post

  1. Ben Says:

    sudo apt-cache search neverball

    sudo is not necessary here. Normal users can apt-cache.

  2. arsgeek Says:

    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.

  3. Benj Says:

    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`

  4. Mausen Says:

    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.

  5. arsgeek Says:

    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

  6. Keith Says:

    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.

  7. Null Says:

    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.

  8. towsonu2003 Says:

    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.

  9. iker Says:

    “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?

  10. arsgeek Says:

    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

  11. pay Says:

    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?

11 Trackbacks For This Post

  1. linuxtoy.org Says:

    Apt 使用备忘…

    命令
    作用

    sudo apt-cache search package
    搜索包

    sudo apt-cache show package
    获取包的相关信息,如说明、大小、版本等

    sudo apt-get install package
    安装包

    sudo apt-get install package - - reinstall
    重新安装包

    su…

  2. All you ever wanted to know about apt for Ubuntu/Debian Linux « The Independant Penguin Says:

    [...] Full Story Explore posts in the same categories: GNU/Linux News [...]

  3. warpedvisions.org » Blog Archive » Quick apt guide Says:

    [...] September 23rd, 2006 in Links ArsGeek writes about all you ever wanted to know about apt for Ubuntu/Debian Linux. [...]

  4. its about time» Blog Archive » links for 2006-09-23 Says:

    [...] ArsGeek :: All you ever wanted to know about apt for Ubuntu/Debian Linux (tags: apt bash commandline commands Debian ubuntu tutorial tips tricks sysadmin Linux apt-get desktop documentation guide IT opensource reference shell) [...]

  5. The Inside Of My Head » links for 2006-09-23 Says:

    [...] ArsGeek :: All you ever wanted to know about apt for Ubuntu/Debian Linux 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. (tags: linux ubuntu) [...]

  6. links for 2006-09-29 « Where Is All This Leading To? Says:

    [...] ArsGeek :: All you ever wanted to know about apt for Ubuntu/Debian Linux (tags: ubuntu Linux debian apt-get apt tips tricks commandline bash opensource sysadmin shell) [...]

  7. EveryDigg » Blog Archive » All you ever wanted to know about apt for Ubuntu/Debian Linux Says:

    [...] 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.read more | digg story [...]

  8. apt-get install » links for 2006-09-23 Says:

    [...] ArsGeek :: All you ever wanted to know about apt for Ubuntu/Debian Linux Let’s get some more info, like a description, size, version and a whole bunch more. sudo apt-cache show neverball (tags: ubuntu debian apt tips) [...]

  9. magicpig » Blog Archive » Says:

    [...] All you ever wanted to know about apt for Ubuntu/Debian Linux [...]

  10. Web 2.0 Announcer Says:

    ArsGeek :: All you ever wanted to know about apt for Ubuntu/Debian Linux

    [...][...]

  11. Apt ???? | LinuxDig Says:

    [...] ArsGeek, [...]

Leave a Reply