428 lines
13 KiB
HTML
428 lines
13 KiB
HTML
<!--startcut ==============================================-->
|
|
<!-- *** BEGIN HTML header *** -->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML><HEAD>
|
|
<title>Debian APT Part 1: Basic Commands LG #84</title>
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
|
|
ALINK="#FF0000">
|
|
<!-- *** END HTML header *** -->
|
|
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="qubism.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue84/tougher.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../lg_faq.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="vinayak.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
|
|
<!--endcut ============================================================-->
|
|
|
|
<TABLE BORDER><TR><TD WIDTH="200">
|
|
<A HREF="http://www.linuxgazette.com/">
|
|
<IMG ALT="LINUX GAZETTE" SRC="../gx/2002/lglogo_200x41.png"
|
|
WIDTH="200" HEIGHT="41" border="0"></A>
|
|
<BR CLEAR="all">
|
|
<SMALL>...<I>making Linux just a little more fun!</I></SMALL>
|
|
</TD><TD WIDTH="380">
|
|
|
|
|
|
<CENTER>
|
|
<BIG><BIG><STRONG><FONT COLOR="maroon">Debian APT Part 1: Basic Commands</FONT></STRONG></BIG></BIG>
|
|
<BR>
|
|
<STRONG>By <A HREF="../authors/tougher.html">Rob Tougher</A></STRONG>
|
|
</CENTER>
|
|
|
|
</TD></TR>
|
|
</TABLE>
|
|
<P>
|
|
|
|
<!-- END header -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<html>
|
|
<head>
|
|
<title>Debian APT Part 1 - Basic Commands</title>
|
|
</head>
|
|
<body>
|
|
|
|
|
|
<h3>Contents</h3>
|
|
|
|
|
|
<dl>
|
|
<dt><a href=#1>Introduction</a>
|
|
<dt><a href=#2>Overview</a>
|
|
<dt><a href=#3>Using APT</a>
|
|
<dd><a href=#3.1>Initial Setup</a>
|
|
<dd><a href=#3.2>Updating your local package cache</a>
|
|
<dd><a href=#3.3>Viewing the available packages</a>
|
|
<dd><a href=#3.4>Viewing the information for a single package</a>
|
|
<dd><a href=#3.5>Installing a package</a>
|
|
<dd><a href=#3.6>Removing a package</a>
|
|
<dd><a href=#3.7>Keeping your system updated</a>
|
|
<dt><a href=#4>Conclusion</a>
|
|
<dt><a href=#5>References</a>
|
|
</dl>
|
|
|
|
|
|
<a name=1 />
|
|
<h3>Introduction</h3>
|
|
|
|
<p>
|
|
I use the <a href="http://www.debian.org">Debian GNU/Linux</a>
|
|
operating system. I use Debian for the following reasons:
|
|
</p>
|
|
|
|
<ul>
|
|
<li>It comes with a lot of
|
|
<a href="http://packages.debian.org/stable/">great software</a>
|
|
<li>The software is simple to install
|
|
</ul>
|
|
|
|
|
|
<p>
|
|
I install Debian software using APT, the Advanced Packaging Tool. With APT
|
|
I can install Debian software from either a CD-ROM, an FTP server, an HTTP server,
|
|
or my local filesystem. What's even better is that Debian provides their
|
|
software archives on <a href="http://www.debian.org/mirror/list">
|
|
freely-accessible FTP and HTTP servers</a>. Installation is as simple as pointing
|
|
APT at one of these servers and telling it to run.
|
|
</p>
|
|
|
|
<p>
|
|
The purpose of this article is to give you an overview of APT and
|
|
describe the basic commands for using it. My hope is that this article
|
|
will show you how easy software installation can be using APT.
|
|
</p>
|
|
|
|
|
|
<a name=2 />
|
|
<h3>Overview</h3>
|
|
|
|
|
|
<p>
|
|
The main concept in APT is the <i>package</i>. Every software application that
|
|
Debian provides has a corresponding package. A package is a file
|
|
with a <code>*.deb</code> extension and includes these items:
|
|
</p>
|
|
|
|
<ul>
|
|
<li>a software application
|
|
<li>a description of the application
|
|
<li>a list of dependencies for the application
|
|
<li>the installation scripts for the application
|
|
<li>the application's user documentation
|
|
</ul>
|
|
|
|
<p>
|
|
All operations in APT deal with packages. When you want to
|
|
install a software application, you tell APT to install that
|
|
application's package. When you want to remove a software application,
|
|
you tell APT to remove that application's package. Even if you only
|
|
want information about the software application, you need to
|
|
ask APT for the information using the application's package name.
|
|
</p>
|
|
|
|
<p>
|
|
Another important concept is the <i>package cache</i>.
|
|
The package cache is a complete list of available packages in the
|
|
Debian distribution. The package cache is stored on your local machine, and
|
|
you are responsible for keeping it updated. A later section deals with
|
|
updating your package cache.
|
|
</p>
|
|
|
|
|
|
|
|
<a name=3 />
|
|
<h3>Using APT</h3>
|
|
|
|
|
|
<a name=3.1 />
|
|
<h4>Initial Setup</h4>
|
|
|
|
<p>
|
|
Before you can use APT you have to tell it where to look for package files.
|
|
Each location you specify is called a <i>source</i>. A source can be a CD-ROM, an HTTP server,
|
|
an FTP server, or an archive on your hard drive.
|
|
</p>
|
|
|
|
<p>
|
|
APT looks in <code>/etc/apt/sources.list</code> for your list of sources.
|
|
The following is my <code>sources.list</code> file:
|
|
</p>
|
|
|
|
|
|
<pre>
|
|
deb http://security.debian.org/ stable/updates main
|
|
deb http://http.us.debian.org/debian stable main contrib non-free
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-6 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-7 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-5 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-4 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-3 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-2 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
deb cdrom:[Debian GNU/Linux 3.0 r0 _Woody_ - Official i386 Binary-1 (20020718)]/ unstable contrib main non-US/contrib non-US/main
|
|
</pre>
|
|
|
|
|
|
|
|
<p>
|
|
Adding HTTP, FTP, and local file archives to <code>sources.list</code> is simple -
|
|
you can add the entries into the file using a text editor (Debian keeps a list
|
|
of mirrors on their <a href="http://www.debian.org/mirror/list">web site</a>).
|
|
To add CD-ROMs you have to use the <code>apt-cdrom</code> command:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-cdrom add
|
|
</pre>
|
|
|
|
|
|
|
|
<a name=3.2 />
|
|
<h4>Updating your local package cache</h4>
|
|
|
|
<p>
|
|
You are responsible for keeping your local package cache updated.
|
|
Every time you want to install or upgrade a software application,
|
|
you should update your package cache first. This ensures that
|
|
you have the latest information about the software you
|
|
are installing.
|
|
</p>
|
|
|
|
<p>
|
|
Run this command to update your package cache:
|
|
</p>
|
|
|
|
|
|
<pre>
|
|
prompt$ apt-get update
|
|
</pre>
|
|
|
|
|
|
|
|
<a name=3.3 />
|
|
<h4>Viewing the available packages</h4>
|
|
|
|
|
|
<p>
|
|
The apt-cache utility allows you to search the
|
|
local package cache for packages with certain text in it.
|
|
</p>
|
|
|
|
|
|
<p>
|
|
For example, you might want to install the Apache HTTP server on
|
|
your machine. You could search for the Apache package using the
|
|
following command:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-cache search apache
|
|
</pre>
|
|
|
|
|
|
<p>
|
|
This command returns 119 packages on my machine. Instead of reading
|
|
through all of the entries, you could filter the output using
|
|
<code>grep</code>:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-cache search apache | grep "^apache"
|
|
</pre>
|
|
|
|
<p>
|
|
This command generates the following:
|
|
</p>
|
|
|
|
|
|
<pre>
|
|
apache-doc - Apache web server docs
|
|
apache-dev - Apache web server development kit
|
|
apache-ssl - Versatile, high-performance HTTP server with SSL support
|
|
apache-common - Support files for all Apache web servers
|
|
<b>apache - Versatile, high-performance HTTP server</b>
|
|
apache-perl - Versatile, high-performance HTTP server with added Perl support
|
|
</pre>
|
|
|
|
|
|
<a name=3.4 />
|
|
<h4>Viewing the information for a single package</h4>
|
|
|
|
<p>
|
|
After having searched for a package, you might want to view the
|
|
information for that package. The <code>apt-cache</code> utility takes
|
|
a <code>show</code> command, like the following:
|
|
</p>
|
|
|
|
|
|
<pre>
|
|
prompt$ apt-cache show packagename
|
|
</pre>
|
|
|
|
<p>
|
|
For example, If you wanted to view the information for the <code>apache</code>
|
|
package, you would type the following at a command prompt:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-cache show apache
|
|
</pre>
|
|
|
|
<p>
|
|
This returns the following:
|
|
</p>
|
|
|
|
<pre>
|
|
Package: apache
|
|
Priority: optional
|
|
Section: web
|
|
Installed-Size: 748
|
|
Maintainer: Matthew Wilcox <willy@debian.org>
|
|
Architecture: i386
|
|
Version: 1.3.26-0woody1
|
|
Replaces: apache-modules
|
|
Provides: httpd
|
|
Depends: libc6 (>= 2.2.4-4), libdb2 (>= 2:2.7.7.0-7), libexpat1 (>= 1.95.2-6), mime-support, apache-common (>= 1.3.26-0), apache-common (<< 1.3.27-0), perl5 | perl, logrotate (>= 3.5.4-1), dpkg (>> 1.9.0)
|
|
Suggests: apache-doc
|
|
Conflicts: apache-modules, libapache-mod-perl (<= 1.17-1), jserv (<= 1.1-3)
|
|
Filename: pool/main/a/apache/apache_1.3.26-0woody1_i386.deb
|
|
Size: 352814
|
|
MD5Sum: 728257f5de8d71e0d00701bdca9d452d
|
|
Description: Versatile, high-performance HTTP server
|
|
The most popular server in the world, Apache features a modular
|
|
design and supports dynamic selection of extension modules at runtime.
|
|
Some of its strong points are its range of possible customization,
|
|
dynamic adjustment of the number of server processes, and a whole
|
|
range of available modules including many authentication mechanisms,
|
|
server-parsed HTML, server-side includes, access control, CERN httpd
|
|
metafiles emulation, proxy caching, etc. Apache also supports multiple
|
|
virtual homing.
|
|
.
|
|
Separate Debian packages are available for PHP3, mod_perl, Java
|
|
Servlet support, Apache-SSL, and other common extensions. More
|
|
information is available at http://www.apache.org/.
|
|
Task: web-server
|
|
</pre>
|
|
|
|
|
|
|
|
<a name=3.5 />
|
|
<h4>Installing a package</h4>
|
|
|
|
<p>
|
|
Installing a package is achieved using the <code>apt-get</code> utility.
|
|
The following will install a package:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-get install packagename
|
|
</pre>
|
|
|
|
<p>
|
|
Typing the following at a command prompt would install the Apache HTTP
|
|
Server on your machine:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-get install apache
|
|
</pre>
|
|
|
|
|
|
|
|
<a name=3.6 />
|
|
<h4>Removing a package</h4>
|
|
|
|
<p>
|
|
You can remove packages from your machine with the following command:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-get remove packagename
|
|
</pre>
|
|
|
|
<p>
|
|
For example, if you wanted to remove the Apache HTTP Server from your
|
|
machine, you would use the following:
|
|
</p>
|
|
|
|
<pre>
|
|
prompt$ apt-get remove apache
|
|
</pre>
|
|
|
|
|
|
|
|
<a name=3.7 />
|
|
<h4>Keeping your system updated</h4>
|
|
|
|
<p>
|
|
It's good to keep your system updated with the
|
|
latest (stable) versions of software. Doing this
|
|
using APT is a simple two-step operation. You have
|
|
to do only the following:
|
|
</p>
|
|
|
|
|
|
<pre>
|
|
prompt$ apt-get update
|
|
prompt$ apt-get upgrade
|
|
</pre>
|
|
|
|
<p>
|
|
The first command updates your local package cache (we saw this in a previous
|
|
section). The second command upgrades any packages installed on your machine that
|
|
have newer versions available.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<a name=4 />
|
|
<h3>Conclusion</h3>
|
|
|
|
<p>
|
|
In this article I described the basic usage of APT. You should now be able to
|
|
use APT to install Debian software on your machine.
|
|
</p>
|
|
|
|
|
|
<a name=5 />
|
|
<h3>References</h3>
|
|
|
|
<ul>
|
|
<li><a href="http://www.debian.org/doc/">Debian documentation</a>
|
|
<li>man pages for apt-get, apt-cache, and sources.list
|
|
</ul>
|
|
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- *** BEGIN copyright *** -->
|
|
<hr>
|
|
<CENTER><SMALL><STRONG>
|
|
Copyright © 2002, Rob Tougher.
|
|
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
|
|
Published in Issue 84 of <i>Linux Gazette</i>, November 2002
|
|
</STRONG></SMALL></CENTER>
|
|
<!-- *** END copyright *** -->
|
|
<HR>
|
|
|
|
<!--startcut ==========================================================-->
|
|
<CENTER>
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="qubism.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue84/tougher.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../lg_faq.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="vinayak.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
</CENTER>
|
|
</BODY></HTML>
|
|
<!--endcut ============================================================-->
|