Junior Level Linux Certification
Exam Objectives
Key Knowledge Areas
Install, re-install, upgrade and remove packages using RPM and YUM.
Obtain information...
RPM and YUM package management
Red Hat introduced RPM in 1995.
RPM is the package management system used for packaging in ...
RPM and YUM package management
Validating package integrity - rpm -K package_file.rpm or rpm --checksig
RPM includes funct...
RPM and YUM package management
Installing packages - rpm -i package_file.rpm or rpm --install package_file.rpm
1.Many opti...
RPM and YUM package management
Upgrading packages - rpm -U package_file.rpm or Rpm --upgrade package_file.rpm
1.Recommende...
RPM and YUM package management
Removing packages - rpm -e package_name or rpm --uninstall package_name
1.When removing a p...
RPM and YUM package management
Query RPM db: Listing install packages - rpm -q package_name or rpm --query package_name
RP...
RPM and YUM package management
Query RPM db: Checking package that installed a file - Add Option –f to –q rpm -qf filename...
RPM and YUM package management
Query RPM db: list files that will install with package use -Add Option –i to –q rpm -qi pa...
RPM and YUM package management
Verifying package files change - rpm -V package_name
Verify a package using package filenam...
RPM and YUM package management
Creating binary packages from source RPM packages - rpm -i command.
places files into /usr/...
RPM and YUM package management
RPM use
13
The spec file has 8 sections:
spec File Section Description
1.Header General inf...
RPM and YUM package management
YUM use
14
Yellowdog Updater Modified (YUM)
Originally developed to manage Red Hat Linux sy...
RPM and YUM package management
YUM use
15
# rpm -i gcl-2.6.8-0.6.20090701cvs.fc12.x86_64.rpm
error: Failed dependencies:
g...
RPM and YUM package management
YUM use
16
# yum install gcl
Loaded plugins: presto, refresh-packagekit
Setting up Install ...
RPM and YUM package management
YUM use
17
How does yum know where to download packages from?
YUM and RPM use a local datab...
RPM and YUM package management
YUM use
18
$ cat /etc/yum.repos.d/fedora-updates.repo
[updates]
name=Fedora $releasever - $...
RPM and YUM package management
YUM use
19
Removing a dependent package with yum
# yum remove gcl-selinux
Loaded plugins: p...
RPM and YUM package management
YUM use
20
Updating using yum update
# yum update 'gr*'
Loaded plugins: presto, refresh-pac...
RPM and YUM package management
YUM use
21
Displaying information
$ yum list gcl
Loaded plugins: presto, refresh-packagekit...
RPM and YUM package management
YUM use
22
Displaying information
$ yum info gcl
Loaded plugins: presto, refresh-packagekit...
Fim de sessão
23
Upcoming SlideShare
Loading in …5
×

101 2.5 use rpm and yum package management

1,718 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,718
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
55
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

101 2.5 use rpm and yum package management

  1. 1. Junior Level Linux Certification
  2. 2. Exam Objectives Key Knowledge Areas Install, re-install, upgrade and remove packages using RPM and YUM. Obtain information on RPM packages such as version, status, dependencies, integrity and signatures. Determine what files a package provides, as well as find which package a specific file comes from. Objective 2: Linux Installation and Package Management Use RPM and YUM package management Weight: 3 Terms and Utilities rpm rpm2cpio /etc/yum.conf /etc/yum.repos.d/ yum yumdownloader 2
  3. 3. RPM and YUM package management Red Hat introduced RPM in 1995. RPM is the package management system used for packaging in the Linux Standard Base (LSB). RPM (Red Hat Package Manager), is made up of several parts: Package files (*.rpm); RPM database; rpm tool RPM Overview 3 rpm tool: [Querying, verifying] [Installing, upgrading, removing] [miscellaneous functions] RPM packages naming scheme: package-version-patch.architecture.rpm (Ex: ethereal-0.8.9-1.i386.rpm) RPM database: Info about every package installed. Kept in /var/lib/rpm directory. every time that rpm cmd is used the database is consulted (On error or inconsistencies run: rpm –rebuilddb)
  4. 4. RPM and YUM package management Validating package integrity - rpm -K package_file.rpm or rpm --checksig RPM includes functions to check integrity of a package, using the MD5 algorithm and the GnuPG tool. RPM use 4 Red Hat’s public key package maintainer is available on its FTP site and is named RPM-GPG-KEY [root@redhat /root]# gpg --import RPM-GPG-KEY gpg: key DB42A60E: public key imported gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: Total number processed: 1 gpg: imported: 1 Ex: If the package validates correctly: [root@redhat /root]# rpm -K wget-1.5.3-6.src.rpm wget-1.5.3-6.src.rpm: md5 gpg OK If the package isn’t valid: [root@redhat /root]# rpm -K wget-1.5.3-10.i386.rpm wget-1.5.3-10.i386.rpm: rpmReadSignature failed GnuPG tool: Public key encryption package to check authenticity source of a file or doc and to encrypt communications. www.gnupg.org PGP tool: Some packages use PGP to check integrity while others use GnuPG. www.pgpi.com
  5. 5. RPM and YUM package management Installing packages - rpm -i package_file.rpm or rpm --install package_file.rpm 1.Many options contain a long and short version: -i and --install 2.Installs multiple packages: rpm -i first_package_file.rpm second_package_file.rpm or rpm -i *.rpm 3.can use wildcards when installing or upgrading packages, but not when removing packages. 4.can also get packages from Internet: rpm -i ftp://rpmfind.net/linux/redhat/redhat-7.0/i386/en/RedHat/RPMS//libpcap-0.4-29.i386.rpm rpm -i http://rpmfind.net/linux/redhat/redhat-7.0/i386/en/RedHat/RPMS//libpcap-0.4-29.i386.rpm 5.Option -v shows the name of the package installed. Option -h shows hash marks as the package is installed to show status. 6.By default, rpm will not let you overwrite a file from another package. Overwrite options: --force Forces rpm to overwrite existing packages or files. --nodeps Bypasses dependency checking. Useful if you have installed a dependency by other means. --replacefiles Overwrite files owned by other packages. RPM use 5
  6. 6. RPM and YUM package management Upgrading packages - rpm -U package_file.rpm or Rpm --upgrade package_file.rpm 1.Recommended option -v and option -h Like in rpm install 2.Upgrade option first removes old version, it will save any modified config files with the .rpmsave extension. 3.Option -F (or --freshen), upgrades packages only if theres an older version installed. RPM use 6 command attempts to upgrade any installed package with a newer package. [root@redhat]# rpm -Fvh *.rpm Ex:
  7. 7. RPM and YUM package management Removing packages - rpm -e package_name or rpm --uninstall package_name 1.When removing a package, use package name not the filename. 2.Wildcards do not work when removing packages. 3.By default dependency check will not let to remove a package if another depends on it RPM use 7 Option --nodeps can be used to override default dependency check. [root@redhat]# rpm -e libpcap error: removing these packages would break dependencies: libpcap >= 0.4 is needed by ethereal-0.8.9-1 Ex: When a package is removed, rpm saves any configuration files that were changed from the default. (.rpmsave) This way you can reinstall the package later without needing to reconfigure it. [root@redhat]# ls /etc/pine* /etc/pine.conf [root@redhat]# rpm -e pine [root@redhat]# ls /etc/pine* /etc/pine.conf.rpmsave [root@redhat]# Ex:
  8. 8. RPM and YUM package management Query RPM db: Listing install packages - rpm -q package_name or rpm --query package_name RPM database stored in /var/lib/rpm holds information about every package installed on the system. 2.Wildcards do not work when removing packages. 3.By default dependency check will not let to remove a package if another depends on it RPM use 8 Use Option -a To list every package installed on the system. [root@redhat /root]# rpm -q kernel kernel-2.2.14-5.0 Ex: [root@redhat /root]# rpm -qaEx: Combine with grep to see which groups of packages are installed. [root@redhat /root]# rpm -qa | grep kernel kernel-headers-2.2.14-5.0 kernel-2.2.14-5.0 kernel-pcmcia-cs-2.2.14-5.0 kernel-utils-2.2.14-5.0 Ex:
  9. 9. RPM and YUM package management Query RPM db: Checking package that installed a file - Add Option –f to –q rpm -qf filename RPM use 9 bashrc file was installed by package bash-1.14.7-22 [root@redhat /root]# rpm -qf /etc/bashrc bash-1.14.7-22 Ex: Query RPM db: Listing files in a package - Add Option –l to –q rpm -ql filename [root@redhat /root]# rpm -ql openssh-clients /etc/ssh/ssh_config /usr/bin/slogin /usr/bin/ssh /usr/bin/ssh-add /usr/bin/ssh-agent /usr/man/man1/slogin.1.gz /usr/man/man1/ssh-add.1.gz /usr/man/man1/ssh-agent.1.gz /usr/man/man1/ssh.1.gz Ex: list all files in the openssh-clients
  10. 10. RPM and YUM package management Query RPM db: list files that will install with package use -Add Option –i to –q rpm -qi package_name RPM use 10 information about the installed Linux kernel [root@redhat /etc]# rpm -qi kernel Name : kernel Relocations: (not relocateable) Version : 2.2.14 Vendor: Red Hat, Inc. Release : 5.0 Build Date: Tue 07 Mar 2000 09:13:08 PM EST Install date: Wed 01 Nov 2000 06:58:30 PM EST Build Host: porky.devel.redhat.com Group : System Environment/Kernel Source RPM: kernel-2.2.14-5.0.src.rpm Size : 11973135 License: GPL Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Summary : The Linux kernel (the core of the Linux operating system). Description : The kernel package contains the Linux kernel (vmlinuz), the core of your Red Hat Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc. Ex: Query RPM db: Printing package scripts - Add Option –p to –q rpm -qp --scripts package_file.rpm
  11. 11. RPM and YUM package management Verifying package files change - rpm -V package_name Verify a package using package filename - option -p rpm -Vp package_file.rpm Verify every package installed on system - option - a rpm -Va package_file.rpm RPM use 11 Package Verification Characteristics Item Meaning . No change for this characteristic 5 The MD5 checksum has changed S File size has changed L Symbolic link has changed T Modification time has changed D The device major and/or minor number has changed U User owner has changed G group owner has changed M Permission and/or file type has changed [root@redhat /etc]# rpm -V setup S.5....T c /etc/hosts.allow ......G. c /etc/profile S.5....T c /etc/services Ex: the hosts.allow file and services file, the file size, MD5 checksum, and modification time have changed. For the profile file, the group owner has changed, but nothing else.
  12. 12. RPM and YUM package management Creating binary packages from source RPM packages - rpm -i command. places files into /usr/src/redhat RPM use 12 Subdirectories in /usr/src/redhat Directory Purpose /usr/src/redhat/ SOURCES Contains the application source code /usr/src/redhat/ SPECS Contains the RPM spec file /usr/src/redhat/ BUILD Where source code is built /usr/src/redhat/ RPMS Contains the final binary RPM /usr/src/redhat/ SRPMS Contains the source RPM built by the process The spec file for a package controls how the package is compiled and the scripts that run when it is installed or removed. named /usr/src/redhat/SPECS/package_name.spec.
  13. 13. RPM and YUM package management RPM use 13 The spec file has 8 sections: spec File Section Description 1.Header General information such as summary, name, version, and so on 2.Prep Shell scripts that do any work needed before the compile process 3.Build Commands to build the spec file and compile the source code 4.Install Commands needed to install the software on a system 5.Clean Optional cmds to clean up the build environment, in case this package is rebuilt again 6.File List List of files in the package 7.Changelog Log of any changes you make to the package 8.Optional Install Scripts that may be run during install or uninstall of the package and Uninstall Scripts %build #./configure --prefix=/usr --sysconfdir=/etc %configure --sysconfdir=/etc make Ex: sample build section from the spec file for the wget application: changes to the compile process are made here. After all of the appropriate modifications have been made, the binary package needs to be built. (The binary package will be put in the /usr/src/redhat/RPMS directory) This is done with the -ba option for rpm. rpm -ba package.spec
  14. 14. RPM and YUM package management YUM use 14 Yellowdog Updater Modified (YUM) Originally developed to manage Red Hat Linux systems at Duke University's Physics department. $ gcl --help bash: gcl: command not found $ which gcl /usr/bin/which: no gcl in (/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerber os/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/ sbin:/home/user/bin) $ type gcl bash: type: gcl: not found Ex: YUM adds automatic updates, package management, dependency management, to RPM. YUM, like APT, works with repositories - collections of packages, accessible over a network. Ex. YUM vs RPM: <For Missing gcl command>
  15. 15. RPM and YUM package management YUM use 15 # rpm -i gcl-2.6.8-0.6.20090701cvs.fc12.x86_64.rpm error: Failed dependencies: gcl-selinux is needed by gcl-2.6.8-0.6.20090701cvs.fc12.x86_64 Ex: Ex. YUM vs RPM: Installing gcl with rpm rpm knows that package has dependency, but it won't help resolve that dependency. You will need to get the dependencies one by one, or write all the dependencies at once. YUM (Yellowdog Updater Modified) provides a function like apt-get. It would install gcl and the required gcl-selinux prerequisite using yum with install option.
  16. 16. RPM and YUM package management YUM use 16 # yum install gcl Loaded plugins: presto, refresh-packagekit Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package gcl.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be updated --> Processing Dependency: gcl-selinux for package: gcl-2.6.8-0.7.20100201cvs.fc12.x86_64 --> Running transaction check ---> Package gcl-selinux.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be updated --> Finished Dependency Resolution Dependencies Resolved ===================================================================================== Package Arch Version Repository Size ===================================================================================== Installing: gcl x86_64 2.6.8-0.7.20100201cvs.fc12 updates 6.3 M Installing for dependencies: gcl-selinux x86_64 2.6.8-0.7.20100201cvs.fc12 updates 17 k Transaction Summary ===================================================================================== Install 2 Package(s) Upgrade 0 Package(s) Total download size: 6.4 M Installed size: 40 M Is this ok [y/N]: y .. // .. Ex: Ex. YUM vs RPM: Installing gcl with yum
  17. 17. RPM and YUM package management YUM use 17 How does yum know where to download packages from? YUM and RPM use a local database to determine what packages are installed Default location is /etc/yum.repos.d/ directory, usually contains several repo files. There may be other locations in the YUM configuration file - normally /etc/yum.conf. repo file is divided in 3 three sections: 1 for normal packages, 1 for debug packages, 1 for source packages. use command yum clean to clean out various parts of the locally stored info Use yum makecache to create info in local database for the enabled repos.
  18. 18. RPM and YUM package management YUM use 18 $ cat /etc/yum.repos.d/fedora-updates.repo [updates] name=Fedora $releasever - $basearch - Updates failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever /$basearch/ mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$r eleasever&arch=$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch [updates-debuginfo] name=Fedora $releasever - $basearch - Updates - Debug failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever /$basearch/debug/ mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-deb ug-f$releasever&arch=$basearch enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch [updates-source] name=Fedora $releasever - Updates Source failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/updates/$releasever /SRPMS/ mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-sou rce-f$releasever&arch=$basearch enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch Ex:
  19. 19. RPM and YUM package management YUM use 19 Removing a dependent package with yum # yum remove gcl-selinux Loaded plugins: presto, refresh-packagekit Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package gcl-selinux.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be erased Processing Dependency: gcl-selinux for package: gcl-2.6.8-0.7.20100201cvs.fc12.x86_64 --> Running transaction check ---> Package gcl.x86_64 0:2.6.8-0.7.20100201cvs.fc12 set to be erased --> Finished Dependency Resolution Dependencies Resolved ===================================================================================== Package Arch Version Repository Size ===================================================================================== Removing: gcl-selinux x86_64 2.6.8-0.7.20100201cvs.fc12 @updates 90 k Removing for dependencies: gcl x86_64 2.6.8-0.7.20100201cvs.fc12 @updates 40 M Transaction Summary ===================================================================================== Remove 2 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: n Exiting on user Command Complete! Ex:
  20. 20. RPM and YUM package management YUM use 20 Updating using yum update # yum update 'gr*' Loaded plugins: presto, refresh-packagekit Setting up Update Process Resolving Dependencies --> Running transaction check ---> Package grep.x86_64 0:2.6.3-1.fc12 set to be updated ---> Package groff.x86_64 0:1.18.1.4-20.fc12 set to be updated --> Finished Dependency Resolution Dependencies Resolved ===================================================================================== Package Arch Version Repository Size ===================================================================================== Updating: grep x86_64 2.6.3-1.fc12 updates 228 k groff x86_64 1.18.1.4-20.fc12 updates 1.5 M Transaction Summary ===================================================================================== Install 0 Package(s) Upgrade 2 Package(s) Total download size: 1.7 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata .. // .. Ex:
  21. 21. RPM and YUM package management YUM use 21 Displaying information $ yum list gcl Loaded plugins: presto, refresh-packagekit Installed Packages gcl.x86_64 2.6.8-0.7.20100201cvs.fc12 @updates $ rpm -q gcl gcl-2.6.8-0.7.20100201cvs.fc12.x86_64 Ex:
  22. 22. RPM and YUM package management YUM use 22 Displaying information $ yum info gcl Loaded plugins: presto, refresh-packagekit Installed Packages Name : gcl Arch : x86_64 Version : 2.6.8 Release : 0.7.20100201cvs.fc12 Size : 40 M Repo : installed From repo : updates Summary : GNU Common Lisp URL : http://www.gnu.org/software/gcl/ License : GPL+ and LGPLv2+ Description: GCL is a Common Lisp currently compliant with the ANSI standard. : Lisp compilation produces native code through the intermediary of : the system's C compiler, from which GCL derives efficient : performance and facile portability. Currently uses TCL/Tk as GUI. Ex: $ rpm -qi gcl Name : gcl Relocations: (not relocatable) Version : 2.6.8 Vendor: Fedora Project .. // .. GCL is a Common Lisp currently compliant with the ANSI standard. Lisp compilation produces native code through the intermediary of the system's C compiler, from which GCL derives efficient performance and facile portability. Currently uses TCL/Tk as GUI.
  23. 23. Fim de sessão 23

×