Yum (Linux)

Click here to load reader

  • date post

    15-Jul-2015
  • Category

    Education

  • view

    174
  • download

    1

Embed Size (px)

Transcript of Yum (Linux)

yum

yumInstalling and Removing Packages Using yumA software package, or simply package, is the collection of scripts, programs, files, and directories required to install and run an application, utility, server, or system software.

A package also includes a list of other packages the package depends on (dependencies). Using software packages makes it easier to install, update, and uninstall software.

A package contains either executable files or source code files. Executable files are precompiled for a specific processor architecture and operating system, whereas source files need to be compiled but will run on a wide range of machines and operating systems.A PMS, or package management system, is a set of utilities that allow you to install, upgrade, remove, and search software packages easily and in a consistent manner. It is based on a local database that holds information about each installed package, including its dependencies and version information.

PackageKit (www.packagekit.org) is a front end for several PMSs, providing a uniform interface. Fedora, Kubuntu, and SUSE use PackageKit. The gnome-packagekit package holds graphical tools designed for the GNOME desktop; each of these tools is named gpk*.

/etc/yum.repos.dThe following example calls yum to install the tcsh shell, which is part of the tcsh package. After yum determines what it needs to do, it asks for confirmation. Reply y if you want to continue or n to quit.

# yum install tcshLoaded plugins: langpacks, presto, refresh-packagekitSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package tcsh.i686 0:6.17-15.fc15 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Installing:tcsh i686 6.17-15.fc15 updates-testing 403 kTransaction Summary================================================================================Install 1 Package(s)Total download size: 403 kInstalled size: 1.1 MIs this ok [y/N]: yDownloading Packages:Setting up and reading Presto delta metadataProcessing delta metadataPackage(s) data still to download: 403 ktcsh-6.17-15.fc15.i686.rpm | 403 kB 00:01Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : tcsh-6.17-15.fc15.i686 1/1Installed:tcsh.i686 0:6.17-15.fc15Complete!Automatically Installs dependenciesThe next command installs the ypbind (NIS) package. Because this package dependson other packages that are not installed (rpcbind and yp-tools), yum lists the packageunder Installing for dependencies and installs them automatically. The yum utilityasks for confirmation before installing the packages.# yum install ypbindLoaded plugins: langpacks, presto, refresh-packagekitSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package ypbind.i686 3:1.32-5.fc15 will be installed--> Processing Dependency: yp-tools for package: 3:ypbind-1.32-5.fc15.i686--> Processing Dependency: rpcbind for package: 3:ypbind-1.32-5.fc15.i686--> Running transaction check---> Package rpcbind.i686 0:0.2.0-10.fc15 will be installed---> Package yp-tools.i686 0:2.12-4.fc15 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Installing:ypbind i686 3:1.32-5.fc15 fedora 55 kInstalling for dependencies:rpcbind i686 0.2.0-10.fc15 fedora 47 kyp-tools i686 2.12-4.fc15 fedora 69 kTransaction Summary================================================================================Install 3 Package(s)Total download size: 171 kInstalled size: 345 kIs this ok [y/N]: yyum remove You can also use yum to remove packages, using a similar syntax. The followingexample removes the tcsh package:# yum remove tcshLoaded plugins: langpacks, presto, refresh-packagekitSetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package tcsh.i686 0:6.17-15.fc15 will be erased--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Removing:tcsh i686 6.17-15.fc15 @updates-testing 1.1 MTransaction Summary================================================================================Remove 1 Package(s)Installed size: 1.1 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionErasing : tcsh-6.17-15.fc15.i686 1/1Removed:tcsh.i686 0:6.17-15.fc15Complete!AutomaticallyremovesdependenciesWhen yum removes a package, it also removes packages that are dependent on thepackage it is removing. The following example removes ypbind and its dependency,yp-tools. It does not remove rpcbind because another installed package mightdepend on rpcbind.# yum remove ypbindLoaded plugins: langpacks, presto, refresh-packagekitSetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package ypbind.i686 3:1.32-5.fc15 will be erased--> Processing Dependency: ypbind for package: yp-tools-2.12-4.fc15.i686--> Running transaction check---> Package yp-tools.i686 0:2.12-4.fc15 will be erased--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Removing:ypbind i686 3:1.32-5.fc15 @fedora 91 kRemoving for dependencies:yp-tools i686 2.12-4.fc15 @fedora 167 kTransaction Summary================================================================================Remove 2 Package(s)Installed size: 258 kIs this ok [y/N]: yFinding the Package That Holds an Application or File You NeedFinding a package with a name that sounds like...The yum search command (next page) searches package names, descriptions, and summaries.The yum list command (next page) searches package names only.

$ yum whatprovides "*X11/Xlib.h"Loaded plugins: langpacks, presto, refresh-packagekit...libX11-devel-1.4.2-1.fc15.i686 : Development files for libX11Repo : fedoraMatched from:Filename : /usr/include/X11/Xlib.hThe most likely candidate is the entry shown in the preceding example, which is themost generic. You can install this package using the following command:# yum install libX11-develyum search The yum search command searches for a string in the package description, summary,and name fields. The following example searches for packages that have the stringvim in these fields:$ yum search vimLoaded plugins: langpacks, presto, refresh-packagekitupdates-testing/pkgtags | 44 kB 00:00=============================== N/S Matched: vim ===============================glusterfs-vim.i686 : Vim syntax fileperl-Text-VimColor.noarch : Syntax color text in HTML or XML using Vimuzbl-vim.i686 : Vim highlighting for uzbl's configvim-X11.i686 : The VIM version of the vi editor for the X Window Systemvim-clustershell.noarch : VIM files for ClusterShellvim-common.i686 : The common files needed by any version of the VIM editorThe yum list command searches for a package name field that matches a string.Specify list available without an argument to list all packages that can be installedfrom the yum repositories. The following example searches for packages whosename fields match the string *emacs*:$ yum list '*emacs*'Loaded plugins: langpacks, presto, refresh-packagekitAvailable Packagesclips-emacs.noarch 6.30.0-0.3.20090722svn.fc15 fedoracoq-emacs.i686 8.2pl1-1.fc12 fedoracrm114-emacs.i686 0-2.14.20100106.fc15 fedoracvc3-emacs.noarch 2.2-3.fc15 fedoracvc3-emacs-el.noarch 2.2-3.fc15 fedoracvc3-xemacs.noarch 2.2-3.fc15 fedoracvc3-xemacs-el.noarch 2.2-3.fc15 fedoraemacs.i686 1:23.2-17.fc15 fedorayum: Keeps the System Up-to-DateThis section continues to describe yum. It covers updating installed packages, yumcommands and groups, downloading RPM package files, configuring yum, andadding a repository specification. Refer to yum.baseurl.org for more information.Updating PackagesThe yum update command, without additional parameters, updates all installed packages.

# yum updateLoaded plugins: langpacks, presto, refresh-packagekitSetting up Update ProcessResolving Dependencies--> Running transaction check---> Package gnome-games.i686 1:2.91.93-1.fc15 will be updated---> Package gnome-games.i686 1:2.91.94-0.20110331.1.fc15 will be an update---> Package xorg-x11-server-Xorg.i686 0:1.10.0-3.fc15 will be updated---> Package xorg-x11-server-Xorg.i686 0:1.10.0-7.fc15 will be an update--> Finished Dependency ResolutionDependencies Resolved================================================================================Package Arch Version Repository Size================================================================================Updating:gnome-games i686 1:2.91.94-0.20110331.1.fc15 updates-testing 2.4 Mxorg-x11-server-Xorg i686 1.10.0-7.fc15 updates-testing 1.4 MTransaction Summary================================================================================Upgrade 2 Package(s)Total download size: 3.8 MIs this ok [y/N]: yDownloading Packages:Setting up and reading Presto delta metadataProcessing delta metadataDownload delta size: 1.2 M(1/2): gnome-games-2.91.93-1.fc15_2.91.94-0.20110331.1.f | 341 kB 00:02(2/2): xorg-x11-server-Xorg-1.10.0-3.fc15_1.10.0-7.fc15. | 870 kB 00:06Finishing rebuild of rpms, from deltarpms | 3.8 MB 00:02Presto reduced the update size by 69% (from 3.8 M to 1.2 M).Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionUpdating : 1:gnome-games-2.91.94-0.20110331.1.fc15.i686 1/4Updating : xorg-x11-server-Xorg-1.10.0-7.fc15.i686 2/4Cleanup : 1:gnome-games-2.91.93-1.fc15.i686 3/4Cleanup : xorg-x11-server-Xorg-1.10.0-3.fc15.i686 4/4Updated:gnome-games.i686 1:2.91.94-0.20110331.1.fc15xorg-x11-server-Xorg.i686 0:1.10.0-7.fc15Complete!yum CommandsThis section describes a few commonly used yum commands. The yum man page contains a complete list.check Reports on problems in the local RPM database.check-update Lists packages that are installed on the local system and have updates available in the yum repositories.clean all Removes header files that yum uses for resolving dependencies. Also removes cached packages. However, because yum removes packages after they have been installed, typically no cached packages existclean metadata Removes the files yum uses to determine remote package availability. Using this command forces yum to download all metadata the next time you run it.grouplist Lists yum groups (next).groupinfo group Lists information about the yum group named group (next).groupinstall group Installs the packages in the yum group named group (next).info word Displays information about packages in the yum repositories named word. Specifyword as "*word*" to search for word anywhere in the package name.list word Lists packages in the yum repositories whose name is word. Specify word as"*word*" to search for word anywhere in the package name. See page 538 for anexample.list available Lists all packages that can be installed from the yum repositories. Use a pipe andgrep to search for packages (e.g., yum list available | grep samba).provides Same as whatprovides.search word Lists packages in the yum repositories that have word in their descriptions, summaries,or names. See page 538 for an example.whatprovides wordSearches repositories and displays a list of packages that provides a feature or filethat matches word. Specify word as "*word*"yum GroupsIn addition to working with single packages, yum can work with groups of packages.The next example shows how to display a list of installed and available groups:$ yum grouplistLoaded plugins: langpacks, presto, refresh-packagekitSetting up Group ProcessInstalled Groups:Administration ToolsDial-up Networking Support FontsGNOME Desktop Environment...Window ManagersX Window SystemInstalled Language Groups:Arabic Support [ar]Armenian Support [hy]Available Groups:...MySQL Database...DoneThe command yum groupinfo followed by the name of a group displays informationabout the group, including a description of the group and a list of mandatory,default, and optional packages. The next example displays informationabout the MySQL Database group of packages. You must quote group namesthat include SPACEs.# yum groupinfo "MySQL Database"Loaded plugins: langpacks, presto, refresh-packagekitSetting up Group ProcessGroup: MySQL DatabaseDescription: This package group contains packages useful for use with MySQL.Mandatory Packages:mysqlDefault Packages:MySQL-pythonlibdbi-dbd-mysqlmysql-connector-odbcmysql-serverperl-DBD-MySQLunixODBCOptional Packages:mod_auth_mysqlmysql-benchmysql-develmysqlreportmysqltunerphp-mysqlqt-mysqlqt3-MySQL

Downloading RPM Package Files with yumdownloaderThe yumdownloader utility (yum-utils package) locates and downloadsbut doesnot installRPM files. Because it does not install software, you do not need towork with root privileges to run it; you need only permission to write to theworking directory

The following example downloads the samba RPM file to the working directory:$ yumdownloader sambaLoaded plugins: langpacks, presto, refresh-packagekitsamba-3.6.0-64pre1.fc15.1.i686.rpm | 4.5 MB 00:04Downloadingsource filesYou can use yumdownloader with the source option to download RPM sourcepackage files. The yumdownloader utility automatically enables the necessary sourcerepositories. See page 586 for an example that downloads in the working directorythe RPM file for the latest version of the kernel source code for the release installedon the local system. Without the source option, yumdownloader would havedownloaded an executable RPM file. See page 551 for information on installing thistype of file.yum.conf: Configures yum

You do not need to configure yum: As installed, it is ready to use. This sectiondescribes the yum configuration files for users who want to modify them. The primaryconfiguration file, /etc/yum.conf, holds global settings. As distributed withFedora/RHEL, files in the /etc/yum.repos.d directory define repositories. Followingis the default yum.conf file:

$ cat /etc/yum.conf[main]cachedir=/var/cache/yum/$basearch/$releaseverkeepcache=0debuglevel=2logfile=/var/log/yum.logexactarch=1obsoletes=1gpgcheck=1plugins=1installonly_limit=3color=never...# PUT YOUR REPOS HERE OR IN separate files named file.repo# in /etc/yum.repos.dThe section labeled [main] defines global configuration options. The cachedir specifiesthe directory where yum stores downloaded packages, although with keepcacheset to 0, yum does not store these packages after installing them. The amount ofinformation logged is specified by debuglevel, with a value of 10 producing themost information. The logfile specifies where yum keeps its log.Setting exactarch to 1 causes yum to update packages only with packages of thesame architecture, thereby preventing an i686 package from replacing an i386package, for example. You can use retries to specify the number of times yum willtry to retrieve a file before returning an error (the default is 6). Set this parameter to0 to cause yum to continue trying forever.yum RepositoriesAs noted in /etc/yum.conf, Fedora/RHEL stores information about each repositoryin a separate file in the /etc/yum.repos.d directory:$ ls /etc/yum.repos.dfedora.repo fedora-updates.repo fedora-updates-testing.repoThe next example shows part of the fedora.repo file that specifies the parametersfor the fedora repository:$ cat /etc/yum.repos.d/fedora.repo[fedora]name=Fedora $releasever - $basearchfailovermethod=priority#baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearchenabled=1#metadata_expire=7dgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch