Read LPI Linux Certification in a Nutshell Online
Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger
Tags: #Reference:Computers
apt-get
apt-get [options
] [command
] [package_name
...]
The
apt-get
command is part of the
Advanced Package Tool (APT) management system. It does
not work directly with
.deb
files like
dpkg
, but uses package names instead.
apt-get
maintains a database of package
information that enables the tool to automatically upgrade packages
and their dependencies as new package releases become
available.
Download files, but do not install. This is useful when
you wish to get a large number of package files but delay
their installation to prevent installation errors from
stopping the download process.
Simulate the steps in a package change, but do not
actually change the system.
Automatically respond “yes” to all prompts, instead of
prompting you for a response during package
installation/removal.
Upgrade automatically to new versions of Debian
Linux.
Install or upgrade one or more packages by name.
Remove specified packages.
Fetch a list of currently available packages. This is
typically done before any changes are made to existing
packages.
Upgrade a system’s complete set of packages to current
versions safely. This command is conservative and will not
process upgrades that could cause a conflict or break an
existing configuration; it also will not remove
packages.
Additional commands and options are available. See the
apt-get
manpage for more information.
apt-get
uses
/etc/apt/sources.list
to determine where
packages should be obtained. The file should contain one or more
lines that look something like this:
deb http://http.us.debian.org/debian stable main contrib non-free
Remove the
elvis
package using
apt-get
:
#apt-get remove elvis
Reading Package Lists... Done
Building Dependency Tree... Done
The following packages will be REMOVED:
elvis
0 packages upgraded, 0 newly installed, 1 to remove
and 376 not upgraded.
Need to get 0B of archives. After unpacking 1363kB
will be freed.
Do you want to continue? [Y/n]y
(Reading database ... 54816 files and directories
currently installed.)
Removing elvis ...
(removal continues...)
In this example, the user is required to respond withy
when prompted to continue.
Using the
-y
option to
apt-get
would eliminate this
interaction.
dselect
dselect
dselect
is an interactive,
menu-driven, frontend tool for
dpkg
and is
usually invoked without parameters. The
dselect
command lets you interactively manage packages by selecting them for
installation, removal, configuration, and so forth. Selections are
made from a locally stored list of available packages, which may be
updated while running
dselect
. Package actions
initiated by
dselect
are carried out using
dpkg
.
alien
alien [--to-deb] [--patch=patchfile
] [options
]file
Convert to or install a non-Debian (or “alien”)
package. Supported package types include Red Hat
.rpm
, Stampede
.slp
,
Slackware
.tgz
, and generic
.tar.gz
files.rpm
must also be installed on the system
to convert an RPM package into a
.deb
package.
The
alien
command produces an
output
package
in Debian format by default after
conversion.
Automatically install the output package and remove the
converted package file.
Convert package to RPM format.
Convert package to agzip
archive.
tar
Install a non-Debian package on a Debian system using
alien
with the
-i
option:
#alien -i package.rpm
On the Exam
dselect, apt-get
, and
alien
are important parts of Debian package
management, but detailed knowledge of
dpkg
is
of primary importance for Exam 101.
The Red Hat Package Manager is among the most popular
methods for the distribution of software for Linux and is installed by
default on most distributions. It automatically handles many of the
management details associated with interdependent software running on your
system.
RPM automates the installation and maintenance of software
packages. Built into each package are program files, configuration
files, documentation, and dependencies on other packages. Package files
are manipulated using the
rpm
command, which
maintains a database of all installed packages and their files.
Information from new packages is added to this database, and the
database is consulted on a file-by-file basis for dependencies when
packages are removed, queried, and installed. As with Debian packages,
RPM packages have four common elements:
An RPM package name is short and descriptive. If multiple
words are used, they are separated by hyphens (not underscores, as
you might expect). Typical names include
binutils
,
caching-nameserver
,
cvs
,
gmc
,
kernel-source
, and
telnet
.
Each package has a version. Most package versions are the
same as that of the software they contain. The format of package
versions varies from package to package, but most are numeric
(major.minor.patchlevel
).
The revision tag is simply a release number for the package.
It has no significance except to determine whether one package is
newer than another when the version number does not change.
Packages containing binary (compiled) files are by their
nature specific to a particular type of system. For PCs, the RPM
architecture designation is
i386
, meaning the
Intel 80386 and subsequent line of microprocessors and
compatibles
.
Packages optimized for later x86 CPUs will have an
architecture tag appropriate for the specific CPU the code is
compiled for, such as
i586
for Intel Pentium
(and compatible) processors,
i686
for Intel
Pentium Pro and later processors (Pentium II, Celeron, Pentium
III, and Pentium 4), or
athlon
for AMD
Athlon.
Other possible architecture tags include
alpha,
ia64, ppc
, and
sparc
(for the
Alpha, Itanium, PowerPC, and SPARC architectures, respectively).
Another arch tag,
noarch
, is used to indicate
packages that can install on any architecture.
While the filename of an RPM package is not significant, Red Hat
does have a standard naming scheme for its packages that most of the
other RPM-based distributions also follow. It is constructed by tying
these elements together in one long string.
The
rpm
command provides for the
installation, removal, upgrade, verification, and other management of
RPM packages.
rpm
has a bewildering array of
options, including the traditional single-letter style
(
-i
) and the double-dash full word style
(
--install
)
. In most
cases, both styles exist and are interchangeable.
Although configuring
rpm
may appear to be a
bit daunting, its operation is simplified by being segmented into
modes. rpm
modes are enabled using one (and only
one) of the
mode options
. Within a mode, additional
mode-specific options become
available
to modify the behavior of
rpm
. The major modes ofrpm
and some of the most frequently used
mode-specific options follow. For complete information on how to use and
manage RPM packages, see the
rpm
manpage or the
synopsis offered by
rpm --help
.
YUM (Yellowdog Updater Modified) is a package manager
offering a fast way for installing, updating, and removing packages. The
yum
command has a very simple interface and
functions similar to
rpm,
but
yum
additionally manages all of the dependencies
for you. Yum will detect if dependencies are required for the
installation of an application and, if need be, fetch the required
dependency and install it. Yum has the ability to support multiple
repositories for packages and has a simple
configuration
.
YUM is configured through the
/etc/yum.conf
configuration file. A sample of the configuration file follows.
Repositories may be added and modified through the
/etc/yum.repos.d
directory:
#cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
# This is the default. If you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is especially important, to have correct metadata, for distributions
# like Fedora that don't keep old packages around. If you don't like this
# checking interrupting your command line usage, it's much better to have
# something manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
The most common commands used with
yum
are:
Install a package or packages on your system.
Remove a package or packages from your system.
Update a package or packages on your system.
List a package or group of packages on your
system.
Search package details for the given string.
Check installed packages with
list
:
#yum list
This command will show all of the packages that are currently
installed on your computer. It will also list available packages. In
the following example the partial output is filtered through
|more
to display content one page at a time. Here
you can see that some of the packages are installed (markedinstalled
) and others are available through
update (@update
):
#yum list |more
Loaded plugins: refresh-packagekit
Installed Packages
Canna-libs.i586 3.7p3-27.fc11 installed
ConsoleKit.i586 0.3.0-8.fc11 installed
ConsoleKit-libs.i586 0.3.0-8.fc11 installed
ConsoleKit-x11.i586 0.3.0-8.fc11 installed
DeviceKit.i586 003-1 installed
DeviceKit-disks.i586 004-4.fc11 @updates
DeviceKit-power.i586 009-1.fc11 @updates
GConf2.i586 2.26.2-1.fc11 installed
GConf2-gtk.i586 2.26.2-1.fc11 installed
ImageMagick.i586 6.5.1.2-1.fc11 installed
MAKEDEV.i586 3.24-3 installed
NetworkManager.i586 1:0.7.1-8.git20090708.fc11 @updates
NetworkManager-glib.i586 1:0.7.1-8.git20090708.fc11 @updates
...
You can also check to see if a particular package is installed
or available for install using the
list
command.
The following example checks to see whether Samba is installed. From
the output you see that the
samba
package is not
installed but available for installation through the
repository:
#yum list samba
Loaded plugins: refresh-packagekit
Available Packages
samba.i586 3.3.2-0.33.fc11 fedora
If you need to collect information about a particular package,
use the
info
command. In this situation we
ask for information about the
httpd
service:
#yum info httpd
Loaded plugins: refresh-packagekit
Installed Packages
Name : httpd
Arch : i586
Version : 2.2.11
Release : 8
Size : 2.6 M
Repo : installed
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description: The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
yum
may be used to check for
available updates for packages running on the computer. You can run
the
check-updates
command to perform a
check for any available package or specify a particular package you
want to update. This example checks for any available updates:
#yum check-update
Loaded plugins: refresh-packagekit
gtk2.i586 2.16.5-1.fc11 updates
mysql-libs.i586 5.1.36-1.fc11 updates
selinux-policy.noarch 3.6.12-69.fc11 updates
selinux-policy-targeted.noarch 3.6.12-69.fc11 updates
Installing packages using
yum
is
really quite straightforward. To install a package, you specify its
name with the
install
command and the package
name, along with any dependencies that will be downloaded and
installed. This example installs the
samba
package:
#yum install samba
Loaded plugins: refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba.i586 0:3.3.2-0.33.fc11 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================
Package Arch Version Repository Size
============================================================================
Installing:
samba i586 3.3.2-0.33.fc11 fedora 4.4 M
Transaction Summary
============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 4.4 M
Is this ok [y/N]:
Downloading Packages:
samba-3.3.2-0.33.fc11.i586.rpm | 4.4 MB 00:06
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : samba-3.3.2-0.33.fc11.i586 1/1
Installed:
samba.i586 0:3.3.2-0.33.fc11
Complete!
Removing a package from your system is similar to the
installation process. Two options remove packages:
remove
and
erase
. They perform the same
function, but
remove
should be used with caution
because it also can uninstall dependent
packages
:
#yum remove httpd
Loaded plugins: refresh-packagekit
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i586 0:2.2.11-8 set to be erased
--> Processing Dependency: httpd >= 2.2.0 for package: \
gnome-user-share-2.26.0-2.fc11.i586
--> Running transaction check
---> Package gnome-user-share.i586 0:2.26.0-2.fc11 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================
Package Arch Version Repository Size
=========================================================================
Removing:
httpd i586 2.2.11-8 installed 2.6 M
Removing for dependencies:
gnome-user-share i586 2.26.0-2.fc11 installed 809 k
Transaction Summary
=========================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 2 Package(s)
Is this ok [y/N]: Y