AptGetHowto

Differences between revisions 17 and 18
Revision 17 as of 2005-12-13 20:58:50
Size: 6978
Editor: c-24-2-76-178
Comment:
Revision 18 as of 2005-12-23 09:42:23
Size: 6998
Editor: S0106000d88b9f3db
Comment: minor editing
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
* Package management via apt-get runs hand-in-hand with the sources.list file. For information on editing or updating that files entries, see ["SourcesList"] Package management via apt-get runs hand-in-hand with the sources.list file. For information on editing or updating that files entries, see ["SourcesList"]
Line 8: Line 8:
''In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.'' ''"In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.''
Line 10: Line 10:
''A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions.'' ''A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions."''
Line 12: Line 12:
  From Debian APT HOWTO  -- From Debian APT HOWTO
Line 16: Line 16:
All these commands require sudo! Replace "packagename" or "string" with the program you're installing or searching for. All these commands require [:RootSudo:sudo]! Replace "packagename" or "string" with the program you're installing or searching for.
Line 34: Line 34:
* {{{apt-get autoclean}}} - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, apt-get clean is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes. * {{{apt-get autoclean}}} - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, {{{apt-get clean}}} is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes.

Package management with apt

attachment:IconsPage/IconApt.png Package management via apt-get runs hand-in-hand with the sources.list file. For information on editing or updating that files entries, see ["SourcesList"]

Intro

"In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.

A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions."

  • -- From Debian APT HOWTO

Commands

All these commands require [:RootSudo:sudo]! Replace "packagename" or "string" with the program you're installing or searching for.

  • apt-get update - Run this after changing /etc/apt/sources.list or /etc/apt/preferences. You also must run it periodically to make sure your source list is up-to-date.

  • apt-get install packagename - installs a new package (but see aptitude, below)

  • apt-get remove packagename - removes a installed package (configfiles remain)

  • apt-get --purge remove packagename - removes a installed package (configfiles will also be removed)

  • apt-get upgrade - upgrades all installed packages

  • apt-get dist-upgrade - upgrades the entire system to a newer release

  • apt-cache search string - Searches for string in the list of known packages

  • dpkg -l package-name-pattern - List installed packages matching pattern. Practically speaking you have to use '*package-name-pattern*' unless you know the fully exact name of the package.

  • aptitude - Curses viewer of packages installed or available. Aptitude can be used from the command-line in a similar way to apt-get, but only for some commands - install and remove being the most common. However, because aptitude keeps track of more information than apt-get does, it can be considered better at install and remove operations.

  • apt-cache showpkg pkgs - Show information about packages.

  • apt-cache dumpavail - Prints out an available list.

  • apt-cache show pkgs - Displays package records, similar to dpkg --print-avail.

  • apt-cache pkgnames - Fast listing of every package in the system.

  • dpkg -S file - Which installed package owns the file?

  • dpkg -L package - List files in the package.

  • apt-file search filename - Search for a package (need not be installed) containing files including the string. apt-file is a package of its own, which you may have to apt-get install first, then run apt-file update. If apt-file search filename shows you too much, try apt-file search filename | grep -w filename (which shows you only the files that contain filename as a whole word) or variants like apt-file search filename | grep /bin/ only files located in directories like /bin or /usr/bin, useful if you're looking for a particular executable).

* apt-get autoclean - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, apt-get clean is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes.

Typical use case

I want to feel the wind in my hair, I want the adrenaline of speed. So lets install a racing game. But what racing games are available?

apt-cache search racing game

It gives me a lot of answers. I see a game named "torcs". Lets get some more information on this game.

apt-cache show torcs

Hmmm... it seems intersting. But is this game not already installed on my computer? And what is the available version? Is it from Universe or main?

apt-cache policy torcs

Ok, so now, let's install it!

apt-get install torcs

What is the command I must type in the console to launch this game? In this example, it's straightforward ("torcs"), but that's not always the case. One way of finding the name of the binary is to look at what files the package has installed in "/usr/bin". For games, the binary will be in "/usr/games". For administrative programs, it's in "/usr/sbin".

dpkg -L torcs|grep /usr/games/

The first part of the command display all files installed by the package "torcs" (try it). With the second part, we ask to only display lines containing "/usr/games/".

Hmmm, that game is cool. Maybe there are some extra tracks?

apt-cache search torcs

But I'm running out of space. I will delete the apt cache!

apt-get clean

Oh no, my mother asked me to remove all games from this computer. But I want to keep the configuration files so I can simply re-install it later.

apt-get remove torcs

If I want to also remove config files :

apt-get remove --purge torcs

Additional packages

deborphan and debfoster are great for finding orphaned and unneeded packages which can be removed.

Speeding up your work at the command line

You can create aliases to make typing these commands faster. For example, you might put this in your *~/.bashrc*

    alias acs='apt-cache search'
    alias agu='sudo apt-get update'
    alias agg='sudo apt-get upgrade'
    alias agd='sudo apt-get dist-upgrade'
    alias agi='sudo apt-get install'
    alias agr='sudo apt-get remove'

But see aptitude, above, for a reason to use "alias agi='sudo aptitude install'"

Setting up apt-get to use a http-proxy

gedit ~/.bashrc

add these lines to the bottom of your .bashrc file

http_proxy=http://yourproxyaddress:proxyport
export http_proxy

Save the file. Close your terminal window and then open another terminal window

Test proxy with sudo apt-get update and whatever networking tool you desire. I use firestarter to see active connections.

If you make a mistake and go back to edit the file again, remember to close the terminal and reopen it. It will not function with the new settings until you do.


CategoryDocumentation

AptGetHowto (last edited 2008-08-06 16:39:37 by localhost)