– General Linux 2 – Use Red Hat Package Management [5] (Linux Professional Institute Certification) a .˜. /V\ // \\ @._.@ by: Andrew Eager geoffrey robertson geoffrey@zip.com.au $Id: gl1.102.6.slides.tex,v 1.4 2003/05/30 05:09:04 waratah Exp $ c 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version. a Copyright 1 List of Slides 2 (2.2) 102 Installation & Package Mgt. [24] 2.102.1 Design hard disk layout [2] 2.102.2 Install a boot manager [3] 2.102.3 Make and install programs from source [5] 2.102.4 Manage shared libraries [3] 2.102.5 Use Debian package management [5] 2.102.6 Use Red Hat Package Manager (RPM) [6] 3 Use Red Hat Package Management Objective Candidates should be able to perform package management under Linux distributions that use RPMs for package distribution. This objective includes being able to install, re-install, upgrade, and remove packages, as well as obtain status and version information on packages. This objective also includes obtaining package information such as version, status, dependencies, integrity, and signatures. Candidates should be able to determine what files a package provides, as well as find which package a specific file comes from. 4 Use Red Hat Package Management Key files, terms, and utilities /etc/rpmrc /usr/lib/rpm/* 5 Use Red Hat Package Management Resources of interest : 6 RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: 7 RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package 7-a RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package – Install an RPM package 7-b RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package – Install an RPM package – Update an already installed RPM package 7-c RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package – Install an RPM package – Update an already installed RPM package – Query an RPM package 7-d RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package – Install an RPM package – Update an already installed RPM package – Query an RPM package – Erase an RPM package 7-e RPM - RedHat Package Manager • RPM works with RedHat, SuSE & Mandrake (among others) and can do the following: – Build an RPM package – Install an RPM package – Update an already installed RPM package – Query an RPM package – Erase an RPM package – Verify an RPM package. 7-f RPM Packages • RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from: – Local media (hard disk, cdrom etc) – An ftp site – An http site 8 RPM Packages • RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from: – Local media (hard disk, cdrom etc) – An ftp site – An http site • Packages sourced from local media are specified using just their filename. For example: – acroread-4.05-1.i686.rpm 8-a RPM Packages • RPM package files consist of a single compressed file much like a tarball. Package files can be sourced from: – Local media (hard disk, cdrom etc) – An ftp site – An http site • Packages sourced from local media are specified using just their filename. For example: – acroread-4.05-1.i686.rpm • Packages sourced from ftp or http sites are specified using the following syntax: – ftp://USER:PASSWORD@HOST:PORT/path/to/package.rpm 8-b RPM Filenames RPM Filenames use a standard naming scheme: package -version-patch.arch.rpm package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example: kernel -2.4.9-21.i686.rpm 9 RPM Filenames RPM Filenames use a standard naming scheme: package- version -patch.arch.rpm package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example: kernel- 2.4.9 -21.i686.rpm 10 RPM Filenames RPM Filenames use a standard naming scheme: package-version- patch .arch.rpm package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example: kernel-2.4.9- 21 .i686.rpm 11 RPM Filenames RPM Filenames use a standard naming scheme: package-version-patch. arch .rpm package - The name of the package version - The version number patch - patch number of this package arch - The architecture this package is for (i386, i586, i686, alpha, sparc) Example: kernel-2.4.9-21. i686 .rpm 12 RPM Operating Modes RPM operations are split up into 4 major modes: 13 RPM Operating Modes RPM operations are split up into 4 major modes: • Querying & Verifying 13-a RPM Operating Modes RPM operations are split up into 4 major modes: • Querying & Verifying • Installing, Upgrading or Removing 13-b RPM Operating Modes RPM operations are split up into 4 major modes: • Querying & Verifying • Installing, Upgrading or Removing • Building Packages 13-c RPM Operating Modes RPM operations are split up into 4 major modes: • Querying & Verifying • Installing, Upgrading or Removing • Building Packages • RPM database administration functions 13-d Verifying package Integrity Having downloaded an rpm from the Internet, the very first thing you want to do is verify its integrity. You do this with the -K or --checksig option to rpm: # rpm -K kernel-2.4.9-31.i586.rpm kernel-2.4.9-31.i586.rpm: md5 gpg OK NOTE: Some packages use PGP to check integrity while others use GnuPG. 14 Installing, Upgrading & Removing Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential: 15 Installing, Upgrading & Removing Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential: • Install - Install a package. Good for Kernels 15-a Installing, Upgrading & Removing Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential: • Install - Install a package. Good for Kernels • Upgrade - Upgrade a package if it’s installed, otherwise install the package 15-b Installing, Upgrading & Removing Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential: • Install - Install a package. Good for Kernels • Upgrade - Upgrade a package if it’s installed, otherwise install the package • Freshen - Upgrade a package only if it’s already installed. 15-c Installing, Upgrading & Removing Understanding the RPM terminology in relation to Installing, upgrading & removing rpm packages is essential: • Install - Install a package. Good for Kernels • Upgrade - Upgrade a package if it’s installed, otherwise install the package • Freshen - Upgrade a package only if it’s already installed. • Erase - Remove a package. 15-d Installing, Upgrading & Removing - Options The table below summarises the various options used for package installation, freshening and removal. Mode Install Upgrade Freshen Erase Short option -i -U -F -e Long option --install --upgrade --freshen --erase 16 Using RPM on the command line Generally you use rpm in one of the following modes: 17 Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... 17-a Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... 17-b Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... 17-c Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... 17-d Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... Commonly used options are: -v Verbose 17-e Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... Commonly used options are: -v Verbose -h print progress hash marks 17-f Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... Commonly used options are: -v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files 17-g Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... Commonly used options are: -v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking 17-h Using RPM on the command line Generally you use rpm in one of the following modes: • rpm -i [install options] package file ... • rpm -U [install-options] package file ... • rpm -F [install-options] package file ... • rpm -e [erase-options] package name ... Commonly used options are: -v Verbose -h print progress hash marks --force Force RPM to overwrite existing packages or files --nodeps Bypass dependency checking --replacefiles Overwrite files owned by other packages 17-i Example - install option Install kernel-2.4.18-4 without removing the existing kernel: # rpm -q kernel kernel-2.4.9-21 # rpm -ivh kernel-2.4.18-4*.rpm Preparing... #################### [100%] 1:kernel-2.4.18-4 #################### [100%] # rpm -q kernel kernel-2.4.18-4 kernel-2.4.9-21 # 18 Example - Freshen option Upgrade the existing kernel to kernel-2.4.18-4. # rpm -q kernel kernel-2.4.9-21 # rpm -Uvh kernel-2.4.18-4*.rpm Preparing... #################### [100%] 1:kernel-2.4.18-4 #################### [100%] # rpm -q kernel kernel-2.4.18-4 # 19 Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: 20 Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: # rpm -q gocr package gocr is not installed 20-a Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: # rpm -q gocr package gocr is not installed # rpm -Uvh gocr-0.3.4-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.4-1.rpm ###################### [100%] 20-b Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: # rpm -q gocr package gocr is not installed # rpm -Uvh gocr-0.3.4-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.4-1.rpm ###################### [100%] # rpm -q gocr gocr-0.3.4-1 20-c Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: # rpm -q gocr package gocr is not installed # rpm -Uvh gocr-0.3.4-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.4-1.rpm ###################### [100%] # rpm -q gocr gocr-0.3.4-1 # rpm -Uvh gocr-0.3.6-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.6-1.rpm ###################### [100%] 20-d Example - Upgrade option: What the upgrade option does will depend on whether or not the package is currently installed. If installed, it will perform a freshen, otherwise it will perform an install: # rpm -q gocr package gocr is not installed # rpm -Uvh gocr-0.3.4-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.4-1.rpm ###################### [100%] # rpm -q gocr gocr-0.3.4-1 # rpm -Uvh gocr-0.3.6-1.i386.rpm Preparing... ###################### [100%] 1:gocr-0.3.6-1.rpm ###################### [100%] # rpm -q gocr gocr-0.3.6-1 20-e Example - Erase option Remove the package gocr from the system # rpm -q gocr gocr-0.3.6-1 # rpm -e gocr # rpm -q gocr # 21 Querying Packages RPM can be used to query a package (either installed or not). rpm -q|--query [select-options] [query-options] 22 Querying Packages RPM can be used to query a package (either installed or not). rpm -q|--query [select-options] [query-options] Select options : Choose what it is you want to query -a Query all installed packages. -f Query package owning FILE. -p Query an (uninstalled) package file 22-a Querying Packages RPM can be used to query a package (either installed or not). rpm -q|--query [select-options] [query-options] Select options : Choose what it is you want to query -a Query all installed packages. -f Query package owning FILE. -p Query an (uninstalled) package file Query options : Choose what it is you want to see from the query: -i Show all information about the package -l Show what files are contained in the package -R List packages on which this package depends 22-b Query - Example Give a list of all packages with kern in their name: $ rpm -qa | grep kern ← kernelcfg-0.5-5 glibc-kernheaders-2.4-7.14 kernel-2.4.9-21 kernel-source-2.4.18-4 23 Query - Example Show a list of all files in kernel-2.4.9-21 $ rpm -ql kernel-2.4.9-21 ← /boot/System.map-2.4.9-21 /boot/module-info-2.4.9-21 /boot/vmlinuz-2.4.9-21 .... 24 Query - Example Show package which owns /bin/ls: $ rpm -qf /bin/ls ← $ fileutils-4.1-10 ← 25 Show complete information about the fileutils package: $ rpm -qi fileutils ← Name : fileutils Relocations: (not relocateable) Version : 4.1 Vendor: Red Hat, Inc. Release : 10 Build Date: Mon 25 Mar 2002 12:23:22 PM E Install date: Fri 24 May 2002 02:18:08 PM EST Build Host: daffy.perf.redhat.com Group : Applications/File Source RPM: fileutils-4.1-10.src.rpm Size : 1679468 License: GPL Packager : Red Hat, Inc. Summary : The GNU versions of common file management utilities. Description : The fileutils package includes a number of GNU versions of common and popular file management utilities. Fileutils includes the following tools: chgrp (changes a file’s group ownership), chown (changes a file’s ownership), chmod (changes a file’s permissions), cp (copies files), dd (copies and converts files), df (shows a filesystem’s disk usage), dir (gives a brief directory listing), dircolors (the setup program for the color version of the ls command), du (shows disk usage), install (copies files and sets permissions), ln (creates file links), ls (lists directory contents), mkdir (creates directories), mkfifo (creates FIFOs or named pipes), mknod (creates special files), mv (renames files), rm (removes/deletes files), rmdir (removes empty 26 Verifying package files This option to rpm is used to verify the files installed on the system with those from the rpm package file. This is not to be confused with the integrity of the package file. The following table lists the characteristics verified: 5 - The MD5 checksum S - The file size L - Symbolic link T - Modification time D - Device major & minor number U - User owner G - Group owner M - Permission and/or file type 27 Example - Verify package Verify the setup package against the originally installed version. $ rpm -V S.5....T S.5....T S.5....T S.5....T S.5....T S.5....T ..?..... .M...... setup ← c /etc/bashrc c /etc/csh.cshrc c /etc/csh.login c /etc/host.conf c /etc/printcap c /etc/profile c /etc/securetty c /etc/shadow 28 The End 29