Sie sind auf Seite 1von 13

36 29 Like Like

Home
Free eBook
Contact
About
Start Here
15 Linux Yum Command Examples Install,
Uninstall, Update Packages
by Balakrishnan Mariyappan on August 31, 2011
Tweet 32
Installing, removing, and updating packages is a typical activity on
Linux. Most of the Linux distributions provides some kind of package manager utility. For example, apt-get,
dpkg, rpm, yum, etc.
On some Linux distributions, yum is the default package manager.
Yum stands for Yellowdog Updater Modified.
This article explains 15 most frequently used yum commands with examples.
1. Install a package using yum install
To install a package, do yum install packagename. This will also identify the dependencies automatically and
install them.
The following example installs postgresql package.
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
1 of 13 29/05/2014 1:07 PM
# yum install postgresql.x86_64
Resolving Dependencies
Install 2 Package(s)
Is this ok [y/N]: y
Package(s) data still to download: 3.0 M
(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm | 2.8 MB 00:11
(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00
------------------------------------------------------------------
Total 241 kB/s | 3.0 MB 00:12
Running Transaction
Installing : postgresql-libs-9.0.4-5.fc15.x86_64 1/2
Installing : postgresql-9.0.4-5.fc15.x86_64 2/2
Complete!
By default yum install, will prompt you to accept or decline before installing the packages. If you want yum to
install automatically without prompting, use -y option as shown below.
# yum -y install postgresql.x86_64
2. Uninstall a package using yum remove
To remove a package (along with all its dependencies), use yum remove package as shown below.
# yum remove postgresql.x86_64
Resolving Dependencies
---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erased
Is this ok [y/N]: y
Running Transaction
Erasing : postgresql-9.0.4-5.fc15.x86_64 1/1
Removed:
postgresql.x86_64 0:9.0.4-5.fc15
Complete!
3. Upgrade an existing package using yum update
If you have a older version of a package, use yum update package to upgrade it to the latest current version.
This will also identify and install all required dependencies.
# yum update postgresql.x86_64
4. Search for a package to be installed using yum search
If you dont know the exact package name to be installed, use yum search keyword, which will search all the
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
2 of 13 29/05/2014 1:07 PM
packages that matches the keyword and display it.
The following examples searches the yum repository for all the packages that matches the keyword firefox and
lists the available packages.
# yum search firefox
Loaded plugins: langpacks, presto, refresh-packagekit
============== N/S Matched: firefox ======================
firefox.x86_64 : Mozilla Firefox Web browser
gnome-do-plugins-firefox.x86_64 : gnome-do-plugins for firefox
mozilla-firetray-firefox.x86_64 : System tray extension for firefox
mozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefox
mozilla-noscript.noarch : JavaScript white list extension for Mozilla Firefox
Name and summary matches only, use "search all" for everything.
5. Display additional information about a package using yum info
Once you search for a package using yum search, you can use yum info package to view additional information
about the package.
The following examples displays additional information about the samba-common package.
# yum info samba-common.i686
Loaded plugins: langpacks, presto, refresh-packagekit
Available Packages
Name : samba-common
Arch : i686
Epoch : 1
Version : 3.5.11
Release : 71.fc15.1
Size : 9.9 M
Repo : updates
Summary : Files used by both Samba servers and clients
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description : Samba-common provides files necessary for both the server and client
: packages of Samba.
6. View all available packages using yum list
The following command will list all the packages available in the yum database.
# yum list | less
7. List only the installed packages using yum list installed
To view all the packages that are installed on your system, execute the following yum command.
# yum list installed | less
8. Which package does a file belong to? Use yum provides
Use yum provides if you like to know which package a particular file belongs to. For example, if you like to
know the name of the package that has the /etc/sysconfig/nfs file, do the following.
# yum provides /etc/sysconfig/nfs
Loaded plugins: langpacks, presto, refresh-packagekit
1:nfs-utils-1.2.3-10.fc15.x86_64 : NFS utilities and supporting clients and
: daemons for the kernel NFS server
Repo : fedora
Matched from:
Filename : /etc/sysconfig/nfs
1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
: daemons for the kernel NFS server
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
3 of 13 29/05/2014 1:07 PM
Repo : updates
Matched from:
Filename : /etc/sysconfig/nfs
1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
: daemons for the kernel NFS server
Repo : installed
Matched from:
Other : Provides-match: /etc/sysconfig/nfs
9. List available software groups using yum grouplist
In yum, several related packages are grouped together in a specific group. Instead of searching and installing all
the individual packages that belongs to a specific function, you can simply install the group, which will install all
the packages that belongs to the group.
To view all the available software groups execute yum grouplist as shown below. The output is listed in three
groupsInstalled Groups, Installed Language Groups and Available Groups.
# yum grouplist
Installed Groups:
Administration Tools
Base
Design Suite
....
Installed Language Groups:
Arabic Support [ar]
Armenian Support [hy]
Bengali Support [bn]
....
Available Groups:
Authoring and Publishing
Books and Guides
Clustering
DNS Name Server
Development Libraries
Development Tools
Directory Server
Dogtag Certificate System
...
10. Install a specific software group using yum groupinstall
To install specific software group, use groupinstall option as shown below. In the following example, DNS Name
Server group contains bind and bind-chroot.
# yum groupinstall 'DNS Name Server'
Dependencies Resolved
Install 2 Package(s)
Is this ok [y/N]: y
Package(s) data still to download: 3.6 M
(1/2): bind-9.8.0-9.P4.fc15.x86_64.rpm | 3.6 MB 00:15
(2/2): bind-chroot-9.8.0-9.P4.fc15.x86_64.rpm | 69 kB 00:00
-----------------------------------------------------------------
Total 235 kB/s | 3.6 MB 00:15
Installed:
bind-chroot.x86_64 32:9.8.0-9.P4.fc15
Dependency Installed:
bind.x86_64 32:9.8.0-9.P4.fc15
Complete!
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
4 of 13 29/05/2014 1:07 PM
Note: You can also install MySQL database using yum groupinstall as we discussed earlier.
11. Upgrade an existing software group using groupupdate
If youve already installed a software group using yum groupinstall, and would like to upgrade it to the latest
version, use yum groupupdate as shown below.
# yum groupupdate 'Graphical Internet'
Dependencies Resolved
Upgrade 5 Package(s)
Is this ok [y/N]: y
Running Transaction
Updating : evolution-data-server-3.0.2-1.fc15.x86_64 1/10
Updating : evolution-3.0.2-3.fc15.x86_64 2/10
Updating : evolution-NetworkManager-3.0.2-3.fc15.x86_64 3/10
Updating : evolution-help-3.0.2-3.fc15.noarch 4/10
Updating : empathy-3.0.2-3.fc15.x86_64 5/10
Cleanup : evolution-NetworkManager-3.0.1-1.fc15.x86_64 6/10
Cleanup : evolution-help-3.0.1-1.fc15.noarch 7/10
Cleanup : evolution-3.0.1-1.fc15.x86_64 8/10
Cleanup : empathy-3.0.1-3.fc15.x86_64 9/10
Cleanup : evolution-data-server-3.0.1-1.fc15.x86_64 10/10
Complete!
12. Uninstall a software group using yum groupremove
To delete an existing software group use yum groupremove as shown below.
# yum groupremove 'DNS Name Server'
Dependencies Resolved
Remove 2 Package(s)
Is this ok [y/N]: y
Running Transaction
Erasing : 32:bind-chroot-9.8.0-9.P4.fc15.x86_64 1/2
Erasing : 32:bind-9.8.0-9.P4.fc15.x86_64 2/2
Complete!
13. Display your current yum repositories
All yum commands goes against one or more yum repositories. To view all the yum repositories that are
configured in your system, do yum repolist as shown below.
The following will display only the enabled repositories.
# yum repolist
repo id repo name status
fedora Fedora 15 - x86_64 24,085
updates Fedora 15 - x86_64 - Updates 5,612
To display all the repositories (both enabled and disabled), use yum repolist all.
# yum repolist all
repo id repo name status
fedora Fedora 15 - x86_64 enabled: 24,085
fedora-debuginfo Fedora 15 - x86_64 - Debug disabled
fedora-source Fedora 15 - Source disabled
rawhide-debuginfo Fedora - Rawhide - Debug disabled
rawhide-source Fedora - Rawhide - Source disabled
updates Fedora 15 - x86_64 - Updates enabled: 5,612
updates-debuginfo Fedora 15 - x86_64 - Updates - Debug disabled
updates-source Fedora 15 - Updates Source disabled
updates-testing Fedora 15 - x86_64 - Test Updates disabled
updates-testing-debuginfo Fedora 15 - x86_64 - Test Updates Debug disabled
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
5 of 13 29/05/2014 1:07 PM
updates-testing-source Fedora 15 - Test Updates Source disabled
To view only the disabled repositories, use yum repositories disabled.
14. Install from a disabled repositories using yum enablerepo
By default yum installs only from the enabled repositories. For some reason if you like to install a package from
a disabled repositories, use enablerepo option in the yum install as shown below.
# yum --enablerepo=fedora-source install vim-X11.x86_64
Dependencies Resolved
Install 1 Package(s)
Is this ok [y/N]: y
Running Transaction
Installing : 2:vim-X11-7.3.138-1.fc15.x86_64 1/1
Complete!
15. Execute yum commands interactively using Yum Shell
Yum provides the interactive shell to run multiple commands as shown below.
# yum shell
Setting up Yum Shell
> info samba.x86_64
Available Packages
Name : samba
Arch : x86_64
Epoch : 1
Version : 3.5.11
Release : 71.fc15.1
Size : 4.6 M
Repo : updates
Summary : Server and Client software to interoperate with Windows machines
URL : http://www.samba.org/
License : GPLv3+ and LGPLv3+
Description :
: Samba is the suite of programs by which a lot of PC-related
: machines share files, printers, and other information (such as
: lists of available files and printers). The Windows NT, OS/2, and
: Linux operating systems support this natively, and add-on packages
: can enable the same thing for DOS, Windows, VMS, UNIX of all
: kinds, MVS, and more. This package provides an SMB/CIFS server
: that can be used to provide network services to SMB/CIFS clients.
: Samba uses NetBIOS over TCP/IP (NetBT) protocols and does NOT
: need the NetBEUI (Microsoft Raw NetBIOS frame) protocol.
>
Yum can also read commands from a text file and execute it one by one. This is very helpful when you have
multiple systems. Instead of executing the same command on all the systems, create a text file with those
commands, and use yum shell to execute those commands as shown below.
# cat yum_cmd.txt
repolist
info nfs-utils-lib.x86_64
# yum shell yum_cmd.txt
repo id repo name status
fedora Fedora 15 - x86_64 24,085
updates Fedora 15 - x86_64 - Updates 5,612
Available Packages
Name : nfs-utils-lib
Arch : x86_64
Version : 1.1.5
Release : 5.fc15
Size : 61 k
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
6 of 13 29/05/2014 1:07 PM
36 Tweet 32
29 Like Like
Repo : fedora
Summary : Network File System Support Library
URL : http://www.citi.umich.edu/projects/nfsv4/linux/
License : BSD
Description : Support libraries that are needed by the commands and
: daemons the nfs-utils rpm.
Leaving Shell
> Add your comment
Linux provides several powerful administrative tools and utilities which will help
you to manage your systems effectively. If you dont know what these tools are and how to use them, you could
be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help
you understand system administration tools, which will help you to become an effective Linux system
administrator.
Get the Linux Sysadmin Course Now!
If you enjoyed this article, you might also like..
50 Linux Sysadmin Tutorials 1.
50 Most Frequently Used Linux Commands (With
Examples)
2.
Top 25 Best Linux Performance Monitoring and
Debugging Tools
3.
Mommy, I found it! 15 Practical Linux Find
Command Examples
4.
Linux 101 Hacks 2nd Edition eBook 5.
Awk Introduction 7 Awk Print Examples
Advanced Sed Substitution Examples
8 Essential Vim Editor Navigation
Fundamentals
25 Most Frequently Used Linux IPTables
Rules Examples
Turbocharge PuTTY with 12 Powerful
Add-Ons
{ 18 comments read them below or add one }
1 Gerd August 31, 2011 at 12:30 am
I am missing yum localinstall
2 Gowrishankar Rajaiyan August 31, 2011 at 2:40 am
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
7 of 13 29/05/2014 1:07 PM
yum localinstall package-name.rpm
localinstall Is used to install a set of local rpm files. If required the enabled repositories will be used to
resolve dependencies.
This command is pretty useful if you dont want to download the dependencies manually.
3 TK Nallppan August 31, 2011 at 2:57 am
Very useful.. Thanks for your sharing.
4 kunal Udapi August 31, 2011 at 4:09 am
You are doing really great job, could you please post how to resolve package dependencies.
5 Ashok August 31, 2011 at 5:10 am
Hi Balakrishnan, Thanks for this article. Good Job. I was actually looking for a good article on Yum.
6 Rob Roy August 31, 2011 at 5:44 am
Is there a way to TEST a yum install in advance without actually doing an install? Something similar to the
way youd do so with the rpm test flag?
7 Kundan August 31, 2011 at 6:46 am
Nice article I didnt knew some of them before I like yum over apt-get.
8 shru September 1, 2011 at 9:27 pm
Hi Everybody,
I just started learning unix. I had question gor grep command.
I want to display 3rd Character of all lines from abc file.
9 Pankaj September 1, 2011 at 11:54 pm
good article. few of them is new to me.. thanks..
10 Yogesh September 8, 2011 at 8:01 pm
Missed:
yum reinstall package-name
Quite handy if you deleted a file by mistake
e.g.
rm /etc/init.d/httpd
yum reinstall httpd.i386
11 mike September 19, 2011 at 6:40 pm
to answer rob roys question, yes you can pre-test a yum install.
first, you need the plugin.
yum install yum-downloadonly (on older versions of fedora/rhel)
OR
yum install yum-plugin-downloadonly (on newer versions of fedora/rhel)
that will allow you to add the downloadonly option to yum install, for example:
yum downloadonly install postgresql
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
8 of 13 29/05/2014 1:07 PM
after you answer Yes to download, it will just exit.
===
here are some other yum items:
yum check-update (to see which installed RPMs have updates/patches)
put this line in /etc/yum.conf to have old software repackaged into an RPM to allow for rollbacks:
tsflags=repackage
put this in /etc/yum.conf if you want to keep the RPMs after youve installed them (instead of having them
deleted).
keepcache=1
thanks. -mike
12 Ashok April 27, 2012 at 1:08 am
Awesome examples !!
13 Avinash Jadhav October 22, 2012 at 7:52 am
Very much helpfull
14 Pavan February 22, 2013 at 6:31 am
Hi all,
Please help me in resolving amy doubt.
If any one by mistake deletes YUM from server then the system will not allow me to reinstall using a
DVD, please suggest me with valid options to resolve this.
15 Adam April 9, 2013 at 8:53 am
shouldnt yum repositories disabled be yum repolist disabled ??
16 Frank May 18, 2013 at 3:26 am
Can you give an example of using yum setopt=SETOPTS
What does it do\mean
man yum doesnt say much extra:
setopt=repoid.option=value
Can it allow me download updates for an i386 pc on a x86_64 pc?
17 elle September 21, 2013 at 11:18 am
how to install all the packages of a file by one command
18 shaju October 8, 2013 at 11:52 am
Very good article.
Thanks a lot
Leave a Comment
Name
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
9 of 13 29/05/2014 1:07 PM
E-mail
Website
Notify me of followup comments via e-mail
Previous post: 20 Things to Plan for an IT Disaster Recovery
Next post: Top on Steroids 15 Practical Linux HTOP Examples
RSS | Email | Twitter | Facebook | Google+
Search
COURSE
Linux Sysadmin CentOS 6 Course - Master the Tools, Configure it Right, and be Lazy
EBOOKS
Linux 101 Hacks 2nd Edition eBook - Practical Examples to Build a Strong Foundation in
Linux
Bash 101 Hacks eBook - Take Control of Your Bash Command Line and Shell Scripting
Sed and Awk 101 Hacks eBook - Enhance Your UNIX / Linux Life with Sed and Awk
Vim 101 Hacks eBook - Practical Examples for Becoming Fast and Productive in Vim Editor
Nagios Core 3 eBook - Monitor Everything, Be Proactive, and Sleep Well
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
10 of 13 29/05/2014 1:07 PM
The Geek Stuff
6,066 people like The Geek Stuff.
Facebook social plugin
Like Like
POPULAR POSTS
12 Amazing and Essential Linux Books To Enrich Your Brain and Library
50 UNIX / Linux Sysadmin Tutorials
50 Most Frequently Used UNIX / Linux Commands (With Examples)
How To Be Productive and Get Things Done Using GTD
30 Things To Do When you are Bored and have a Computer
Linux Directory Structure (File System Structure) Explained with Examples
Linux Crontab: 15 Awesome Cron Job Examples
Get a Grip on the Grep! 15 Practical Grep Command Examples
Unix LS Command: 15 Practical Examples
15 Examples To Master Linux Command Line History
Top 10 Open Source Bug Tracking System
Vi and Vim Macro Tutorial: How To Record and Play
Mommy, I found it! -- 15 Practical Linux Find Command Examples
15 Awesome Gmail Tips and Tricks
15 Awesome Google Search Tips and Tricks
RAID 0, RAID 1, RAID 5, RAID 10 Explained with Diagrams
Can You Top This? 15 Practical Linux Top Command Examples
Top 5 Best System Monitoring Tools
Top 5 Best Linux OS Distributions
How To Monitor Remote Linux Host using Nagios 3.0
Awk Introduction Tutorial 7 Awk Print Examples
How to Backup Linux? 15 rsync Command Examples
The Ultimate Wget Download Guide With 15 Awesome Examples
Top 5 Best Linux Text Editors
Packet Analyzer: 15 TCPDUMP Command Examples
The Ultimate Bash Array Tutorial with 15 Examples
3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
Unix Sed Tutorial: Advanced Sed Substitution Examples
UNIX / Linux: 10 Netstat Command Examples
The Ultimate Guide for Creating Strong Passwords
6 Steps to Secure Your Home Wireless Network
Turbocharge PuTTY with 12 Powerful Add-Ons
CATEGORIES
Linux Tutorials
Vim Editor
Sed Scripting
Awk Scripting
Bash Shell Scripting
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
11 of 13 29/05/2014 1:07 PM
Nagios Monitoring
OpenSSH
IPTables Firewall
Apache Web Server
MySQL Database
Perl Programming
Google Tutorials
Ubuntu Tutorials
PostgreSQL DB
Hello World Examples
C Programming
C++ Programming
DELL Server Tutorials
Oracle Database
VMware Tutorials
About The Geek Stuff
My name is Ramesh Natarajan. I will be posting instruction guides, how-to,
troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to write
articles that will either teach you or help you resolve a problem. Read more about Ramesh Natarajan and
the blog.
Support Us
Support this blog by purchasing one of my ebooks.
Bash 101 Hacks eBook
Sed and Awk 101 Hacks eBook
Vim 101 Hacks eBook
Nagios Core 3 eBook
Contact Us
Email Me : Use this Contact Form to get in touch me with your comments, questions or suggestions about
this site. You can also simply drop me a line to say hello!.
Follow us on Google+
Follow us on Twitter
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
12 of 13 29/05/2014 1:07 PM
Become a fan on Facebook
Copyright 20082014 Ramesh Natarajan. All rights reserved | Terms of Service
15 Linux Yum Command Examples Install, Uninstall, Update Packages http://www.thegeekstuff.com/2011/08/yum-command-examples/
13 of 13 29/05/2014 1:07 PM

Das könnte Ihnen auch gefallen