20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management
来源:互联网 发布:手机家长控制软件 编辑:程序博客网 时间:2024/05/22 09:39
In this article, we will learn how to install, update, remove, find packages, manage packages and repositories on Linux systems using YUM (Yellowdog Updater Modified) tool developed by RedHat. The example commands shown in this article are practically tested on our CentOS 6.3 server, you can use these material for study purpose, certifications or just to explore ways to install new packages and keep your system up-to-date. The basic requirement of this article is, you must have a basic understanding of commands and a working Linux operating system, where you can explore and practice all the commands listed below.
What is YUM?
YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool forRPM (RedHat Package Manager) based Linux systems. It allows users and system administrator to easily install, update, remove or search software packages on a systems. It was developed and released bySeth Vidal under GPL (General Public License) as an open source, means anyone can allowed to download and access the code to fix bugs and develop customized packages.YUM uses numerous third party repositories to install packages automatically by resolving their dependencies issues.
1. Install a Package with YUM
To install a package called Firefox 14, just run the below command it will automatically find and install all required dependencies for Firefox.
# yum install firefoxLoaded plugins: fastestmirrorDependencies Resolved================================================================================================ Package Arch Version Repository Size ================================================================================================Updating:firefox i686 10.0.6-1.el6.centos updates 20 MUpdating for dependencies: xulrunner i686 10.0.6-1.el6.centos updates 12 MTransaction Summary================================================================================================Install 0 Package(s)Upgrade 2 Package(s)Total download size: 32 MIs this ok [y/N]: yDownloading Packages:(1/2): firefox-10.0.6-1.el6.centos.i686.rpm | 20 MB 01:10(2/2): xulrunner-10.0.6-1.el6.centos.i686.rpm | 12 MB 00:52------------------------------------------------------------------------------------------------Total 63 kB/s | 32 MB 02:04Updated: firefox.i686 0:10.0.6-1.el6.centosDependency Updated: xulrunner.i686 0:10.0.6-1.el6.centosComplete!
The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option-y as shown in below example.
# yum -y install firefox
2. Removing a Package with YUM
To remove a package completely with their all dependencies, just run the following command as shown below.
# yum remove firefoxLoaded plugins: fastestmirrorSetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package firefox.i686 0:10.0.6-1.el6.centos set to be erased--> Finished Dependency ResolutionDependencies Resolved==================================================================================================== Package Arch Version Repository Size ====================================================================================================Removing: firefox i686 10.0.6-1.el6.centos @updates 23 MTransaction Summary====================================================================================================Remove 1 Package(s)Reinstall 0 Package(s)Downgrade 0 Package(s)Is this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Erasing : firefox-10.0.6-1.el6.centos.i686 1/1Removed: firefox.i686 0:10.0.6-1.el6.centosComplete!
Same way the above command will ask confirmation before removing a package. To disable confirmation prompt just add option -y as shown in below.
# yum -y remove firefox
3. Updating a Package using YUM
Let’s say you have outdated version of MySQL package and you want to update it to the latest stable version. Just run the following command it will automatically resolves all dependencies issues and install them.
# yum update mysqlLoaded plugins: fastestmirrorDependencies Resolved============================================================================================================ Package Arch Version Repository Size============================================================================================================Updating: vsftpd i386 2.0.5-24.el5_8.1 updates 144 kTransaction Summary============================================================================================================Install 0 Package(s)Upgrade 1 Package(s)Total size: 144 kIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Updating : vsftpd 1/2 Cleanup : vsftpd 2/2Updated: vsftpd.i386 0:2.0.5-24.el5_8.1Complete!
4. List a Package using YUM
Use the list function to search for the specific package with name. For example to search for a package calledopenssh, use the command.
# yum list opensshLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: mirror.nus.edu.sgInstalled Packagesopenssh.i386 4.3p2-72.el5_6.3 installedAvailable Packages 4.3p2-82.el5 base
To make your search more accurate, define package name with their version, in case you know. For example to search for a specific versionopenssh-4.3p2 of the package, use the command.
# yum list openssh-4.3p2
5. Search for a Package using YUM
If you don’t remember the exact name of the package, then use search function to search all the available packages to match the name of the package you specified. For example, to search all the packages that matches the word.
# yum search vsftpdLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in============================== Matched: vsftpd ========================ccze.i386 : A robust log colorizerpure-ftpd-selinux.i386 : SELinux support for Pure-FTPDvsftpd.i386 : vsftpd - Very Secure Ftp Daemon
6. Get Information of a Package using YUM
Say you would like to know information of a package before installing it. To get information of a package just issue the below command.
# yum info firefoxLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.inAvailable PackagesName : firefoxArch : i386Version : 10.0.6Release : 1.el5.centosSize : 20 MRepo : updatesSummary : Mozilla Firefox Web browserURL : http://www.mozilla.org/projects/firefox/License : MPLv1.1 or GPLv2+ or LGPLv2+Description: Mozilla Firefox is an open-source web browser, designed for standards : compliance, performance and portability.
7. List all Available Packages using YUM
To list all the available packages in the Yum database, use the below command.
# yum list | less
8. List all Installed Packages using YUM
To list all the installed packages on a system, just issue below command, it will display all the installed packages.
# yum list installed | less
9. Yum Provides Function
Yum provides function is used to find which package a specific file belongs to. For example, if you would like to know the name of the package that has the/etc/httpd/conf/httpd.conf.
# yum provides /etc/httpd/conf/httpd.confLoaded plugins: fastestmirrorhttpd-2.2.3-63.el5.centos.i386 : Apache HTTP ServerRepo : baseMatched from:Filename : /etc/httpd/conf/httpd.confhttpd-2.2.3-63.el5.centos.1.i386 : Apache HTTP ServerRepo : updatesMatched from:Filename : /etc/httpd/conf/httpd.confhttpd-2.2.3-65.el5.centos.i386 : Apache HTTP ServerRepo : updatesMatched from:Filename : /etc/httpd/conf/httpd.confhttpd-2.2.3-53.el5.centos.1.i386 : Apache HTTP ServerRepo : installedMatched from:Other : Provides-match: /etc/httpd/conf/httpd.conf
10. Check for Available Updates using Yum
To find how many of installed packages on your system have updates available, to check use the following command.
# yum check-update
11. Update System using Yum
To keep your system up-to-date with all security and binary package updates, run the following command. It will install all latest patches and security updates to your system.
# yum update
12. List all available Group Packages
In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.
# yum grouplistInstalled Groups: Administration Tools DNS Name Server Dialup Networking Support Editors Engineering and Scientific FTP Server Graphics Java Development Legacy Network ServerAvailable Groups: Authoring and Publishing Base Beagle Cluster Storage Clustering Development Libraries Development Tools Eclipse Educational Software KDE (K Desktop Environment) KDE Software Development
13. Install a Group Packages
To install a particular package group, we use option as groupinstall. Fore example, to install “MySQL Database“, just execute the below command.
# yum groupinstall 'MySQL Database'Dependencies Resolved=================================================================================================PackageArch Version Repository Size=================================================================================================Updating: unixODBC i386 2.2.11-10.el5 base 290 kInstalling for dependencies: unixODBC-libs i386 2.2.11-10.el5 base 551 kTransaction Summary=================================================================================================Install 1 Package(s)Upgrade 1 Package(s)Total size: 841 kIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Installing : unixODBC-libs1/3 Updating : unixODBC 2/3 Cleanup : unixODBC 3/3Dependency Installed: unixODBC-libs.i386 0:2.2.11-10.el5Updated: unixODBC.i386 0:2.2.11-10.el5Complete!
14. Update a Group Packages
To update any existing installed group packages, just run the following command as shown below.
# yum groupupdate 'DNS Name Server'Dependencies Resolved================================================================================================================ PackageArch VersionRepository Size================================================================================================================Updating: bind i386 30:9.3.6-20.P1.el5_8.2 updates 981 k bind-chroot i386 30:9.3.6-20.P1.el5_8.2 updates 47 kUpdating for dependencies: bind-libs i386 30:9.3.6-20.P1.el5_8.2 updates 864 k bind-utils i386 30:9.3.6-20.P1.el5_8.2 updates 174 kTransaction Summary================================================================================================================Install 0 Package(s)Upgrade 4 Package(s)Total size: 2.0 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Updating : bind-libs 1/8 Updating : bind 2/8 Updating : bind-chroot 3/8 Updating : bind-utils 4/8 Cleanup : bind 5/8 Cleanup : bind-chroot 6/8 Cleanup : bind-utils 7/8 Cleanup : bind-libs 8/8Updated: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2Dependency Updated: bind-libs.i386 30:9.3.6-20.P1.el5_8.2 bind-utils.i386 30:9.3.6-20.P1.el5_8.2Complete!
15. Remove a Group Packages
To delete or remove any existing installed group from the system, just use below command.
# yum groupremove 'DNS Name Server'Dependencies Resolved=========================================================================================================== Package Arch Version Repository Size===========================================================================================================Removing: bind i386 30:9.3.6-20.P1.el5_8.2 installed 2.1 M bind-chroot i386 30:9.3.6-20.P1.el5_8.2 installed 0.0Transaction Summary===========================================================================================================Remove 2 Package(s)Reinstall 0 Package(s)Downgrade 0 Package(s)Is this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Erasing : bind 1/2warning: /etc/sysconfig/named saved as /etc/sysconfig/named.rpmsave Erasing : bind-chroot 2/2Removed: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2Complete!
16. List Enabled Yum Repositories
To list all enabled Yum repositories in your system, use following option.
# yum repolistrepo id repo name statusbase CentOS-5 - Base enabled: 2,725epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783extras CentOS-5 - Extras enabled: 282mod-pagespeed mod-pagespeed enabled: 1rpmforge RHEL 5 - RPMforge.net - dag enabled: 11,290updates CentOS-5 - Updates enabled: 743repolist: 20,824
16. List all Enabled and Disabled Yum Repositories
The following command will display all enabled and disabled yum repositories on the system.
# yum repolist allrepo id repo name statusC5.0-base CentOS-5.0 - Base disabledC5.0-centosplus CentOS-5.0 - Plus disabledC5.0-extras CentOS-5.0 - Extras disabledbase CentOS-5 - Base enabled: 2,725epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783extras CentOS-5 - Extras enabled: 282repolist: 20,824
17. Install a Package from Specific Repository
To install a particular package from a specific enabled or disabled repository, you must use–enablerepo option in your yum command. For example to Install PhpMyAdmin 3.5.2 package, just execute the command.
# yum --enablerepo=epel install phpmyadminDependencies Resolved============================================================================================= Package Arch Version Repository Size=============================================================================================Installing: phpMyAdmin noarch 3.5.1-1.el6 epel 4.2 MTransaction Summary=============================================================================================Install 1 Package(s)Total download size: 4.2 MInstalled size: 17 MIs this ok [y/N]: yDownloading Packages:phpMyAdmin-3.5.1-1.el6.noarch.rpm | 4.2 MB 00:25Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : phpMyAdmin-3.5.1-1.el6.noarch 1/1 Verifying : phpMyAdmin-3.5.1-1.el6.noarch 1/1Installed: phpMyAdmin.noarch 0:3.5.1-1.el6Complete!
18. Interactive Yum Shell
Yum utility provides a custom shell where you can execute multiple commands.
# yum shellLoaded plugins: fastestmirrorSetting up Yum Shell> update httpdLoading mirror speeds from cached hostfile * base: mirrors.sin3.sg.voxel.net * epel: ftp.riken.jp * extras: mirrors.sin3.sg.voxel.net * updates: mirrors.sin3.sg.voxel.netSetting up Update Process>
19. Clean Yum Cache
By default yum keeps all the repository enabled package data in /var/cache/yum/ with each sub-directory, to clean all cached files from enabled repository, you need to run the following command regularly to clean up all the cache and make sure that there is nothing unnecessary space is using. We don’t want to give the output of the below command, because we like to keep cached data as it is.
# yum clean all
20. View History of Yum
To view all the past transactions of yum command, just use the following command.
# yum historyLoaded plugins: fastestmirrorID | Login user | Date and time | Action(s) | Altered------------------------------------------------------------------------------- 10 | root | 2012-08-11 15:19 | Install | 3 9 | root | 2012-08-11 15:11 | Install | 1 8 | root | 2012-08-11 15:10 | Erase | 1 EE 7 | root | 2012-08-10 17:44 | Install | 1 6 | root | 2012-08-10 12:19 | Install | 2 5 | root | 2012-08-10 12:14 | Install | 3 4 | root | 2012-08-10 12:12 | I, U | 13 E< 3 | root | 2012-08-09 13:01 | Install | 1 > 2 | root | 2012-08-08 20:13 | I, U | 292 EE 1 | System | 2012-08-08 17:15 | Install | 560history list
We have tried to cover all the basic to advance yum commands with their examples. If anything related to yum commands may have missed out. Please update us through our comment box. So, we keep updating the same based on feedback’s received.
原文地址:http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/
- 20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management
- 20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management
- yum ---Yellowdog Updater Modified and yumex
- 20 Netstat Commands for Linux Network Management
- linux_20 Netstat Commands for Linux Network Management
- YUM(Yellow dog Updater, Modified)使用详解
- createrepo createrepo是linux下的创建仓库的软件包。create是创建的意思,repo是repository的缩写,是仓库的意思。 yum(Yellowdog Updater,
- Linux Commands For Shared Library Management & Debugging Problem & strace
- 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- linux_ 25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management
- some commands for disk management
- Suse linux hardware management commands
- List of Solaris commands for process management
- 20 Advanced Commands for Linux Experts
- 20 Useful Commands for Linux Newbies
- 20 Advanced Commands for Linux Experts
- 20 Useful Commands for Linux Newbies
- WSO2-Stratos2.0的架构
- javaWeb解决中文乱码问题
- ToAscii将虚拟键码转化为相应的字符或字符串
- Spring使用JdbcTemplate插入和修改数据的三种方法
- baby one more time
- 20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management
- onInterceptTouchEvent和onTouchEvent调用关系详解
- Hello, world!
- 6410之UART使用中断方式
- git新手入门参考文章
- note : A-Protect Study note
- java--加强之 jdk1.5简单新特性,枚举,注解
- GetKeyboardState
- 把VIM打造成一个真正的IDE