未加星标

25 Useful yum Command Examples For Package Management In Linux

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Yellowdog Updater Modifier (yum) is an RPM based package manager which is used to install and update packages in various linux distributions including CentOS, RHEL and Fedora.

Yum is quite powerful as it’s capable of automatically resolving dependency issues, and is similar to other package managers such as ‘apt-get’ in Debian based distributions.

These examples should serve as a useful introduction, guide or cheat sheet style resource for how to use the yum command in Linux.

How To Use yum Command Examples 1. Install New Package From Repository

The yum command can be used to install packages from a repository with the ‘install’ argument, followed by the package name. In the example below, we are installing Apache, which is provided in the ‘httpd’ package.

[[email protected] ~]# yum install httpd Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================== Package Arch Version Repository Size ======================================================================== Installing: httpd x86_64 2.4.6-40.el7.centos.4 updates 2.7 M Transaction Summary ======================================================================== Install 1 Package Total download size: 2.7 M Installed size: 9.4 M Is this ok [y/d/N]: y

Downloading packages: httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : httpd-2.4.6-40.el7.centos.4.x86_64 1/1 Verifying : httpd-2.4.6-40.el7.centos.4.x86_64 1/1 Installed: httpd.x86_64 0:2.4.6-40.el7.centos.4 Complete!

Note that after confirming the packages that will be installed, you will be asked to provide input. In this case we entered ‘y’ for yes to proceed with the installation, which then completed successfully.

2. Assume Yes

In the first example we were prompted to press the ‘y’ key in order to proceed with the installation. Rather than being prompted each time for user input, we can simply specify the ‘-y’ option in our command for assume yes. This way we will not be prompted for any input and yum will assume that everything will be answered with yes.

[[email protected] ~]# yum install httpd-manual -y

Resolving Dependencies --> Running transaction check ---> Package httpd-manual.noarch 0:2.4.6-40.el7.centos.4 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================== Package Arch Version Repository Size ========================================================================== Installing: httpd-manual noarch 2.4.6-40.el7.centos.4 updates 1.3 M Transaction Summary ========================================================================== Install 1 Package Total download size: 1.3 M Installed size: 5.5 M Downloading packages: httpd-manual-2.4.6-40.el7.centos.4.noarch.rpm | 1.3 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : httpd-manual-2.4.6-40.el7.centos.4.noarch 1/1 Verifying : httpd-manual-2.4.6-40.el7.centos.4.noarch 1/1 Installed: httpd-manual.noarch 0:2.4.6-40.el7.centos.4 Complete!

Note that in this example we were not prompted for input, as assume yes has been provided, so the package was installed fully without any further user interaction.

3. Check For Available Updates

We can run yum with the ‘check-update’ argument which will check in with our enabled repositories for any updates that may be available for packages that we have installed. This does not actually perform any updates, it simply gives us a list of packages that have updates available for installation.

[[email protected] ~]# yum check-update

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile bash.x86_64 4.2.46-20.el7_2 updates dbus.x86_64 1:1.6.12-14.el7_2 updates dbus-libs.x86_64 1:1.6.12-14.el7_2 updates device-mapper-persistent-data.x86_64 0.6.2-1.el7_2 updates glibc.x86_64 2.17-106.el7_2.8 updates glibc-common.x86_64 2.17-106.el7_2.8 updates initscripts.x86_64 9.49.30-1.el7_2.3 updates kernel.x86_64 3.10.0-327.28.3.el7 updates kernel-tools.x86_64 3.10.0-327.28.3.el7 updates kernel-tools-libs.x86_64 3.10.0-327.28.3.el7 updates ...

4. Update New Package From Repository

In the previous example we have been provided with a list of packages that currently have package updates available. We can perform an update to a specific package by specifying it after the ‘update’ argument, as shown below.

[[email protected] ~]# yum update bash -y

Resolving Dependencies --> Running transaction check ---> Package bash.x86_64 0:4.2.46-19.el7 will be updated ---> Package bash.x86_64 0:4.2.46-20.el7_2 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================= Package Arch Version Repository Size ================================================================= Updating: bash x86_64 4.2.46-20.el7_2 updates 1.0 M Transaction Summary ================================================================= Upgrade 1 Package Total download size: 1.0 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. bash-4.2.46-20.el7_2.x86_64.rpm | 1.0 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : bash-4.2.46-20.el7_2.x86_64 1/2 Cleanup : bash-4.2.46-19.el7.x86_64 2/2 Verifying : bash-4.2.46-20.el7_2.x86_64 1/2 Verifying : bash-4.2.46-19.el7.x86_64 2/2 Updated: bash.x86_64 0:4.2.46-20.el7_2 Complete!

Note that we do not have to run check-update prior to this.

While we can update specified packages in this manner, it is often easier to simply apply all available updates for all packages on the system with ‘yum update’.

5. Download Package RPM File

Rather than installing a package from the repository as demonstrated previously, we can optionally download the .rpm file from the repository with the ‘yumdownloader’ command.

The ‘yumdownloader’ command comes from the ‘yum-utils’ package, so we install this first.

[[email protected] ~]# yum install yum-utils -y

Now we can download the RPM file to the local system.

[[email protected] ~]# yumdownloader unbound Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.ventraip.net.au * extras: mirror.optus.net * updates: mirror.optus.net unbound-1.4.20-26.el7.x86_64.rpm [[emailprotected] ~]# ls -la unbound-1.4.20-26.el7.x86_64.rpm

-rw-r--r--. 1 root root 483136 Nov 26 2015 unbound-1.4.20-26.el7.x86_64.rpm

6. Perform Local Install Of RPM File I

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LinuxDebian
分页:12
转载请注明
本文标题:25 Useful yum Command Examples For Package Management In Linux
本站链接:http://www.codesec.net/view/481426.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(38)