Linux Yum 命令使用举例(很全很实用)


yum命令

yum命令是在Fedora和RedHat以及SUSE中基于rpm的软件包管理器,它可以使系统管理人员交互和自动化地更细与管理RPM软件包,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。

yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。

语法

yum(选项)(参数)

选项

-h:显示帮助信息;
-y:对所有的提问都回答“yes”;
-c:指定配置文件;
-q:安静模式;
-v:详细模式;
-d:设置调试等级(0-10);
-e:设置错误等级(0-10);
-R:设置yum处理一个命令的最大等待时间;
-C:完全从缓存中运行,而不去下载或者更新任何头文件。

参数

install:安装rpm软件包;
update:更新rpm软件包;
check-update:检查是否有可用的更新rpm软件包;
remove:删除指定的rpm软件包;
list:显示软件包的信息;
search:检查软件包的信息;
info:显示指定的rpm软件包的描述信息和概要信息;
clean:清理yum过期的缓存;
shell:进入yum的shell提示符;
resolvedep:显示rpm软件包的依赖关系;
localinstall:安装本地的rpm软件包;
localupdate:显示本地rpm软件包进行更新;
deplist:显示rpm软件包的所有依赖关系。

实例

部分常用的命令包括:

  • 自动搜索最快镜像插件:yum install yum-fastestmirror
  • 安装yum图形窗口插件:yum install yumex
  • 查看可能批量安装的列表:yum grouplist

安装

yum install              #全部安装
yum install package1     #安装指定的安装包package1
yum groupinsall group1   #安装程序组group1

更新和升级

yum update               #全部更新
yum update package1      #更新指定程序包package1
yum check-update         #检查可更新的程序
yum upgrade package1     #升级指定程序包package1
yum groupupdate group1   #升级程序组group1

查找和显示

yum info package1      #显示安装包信息package1
yum list               #显示所有已经安装和可以安装的程序包
yum list package1      #显示指定程序包安装情况package1
yum groupinfo group1   #显示程序组group1信息yum search string 根据关键字string查找安装包

删除程序

yum remove | erase package1   #删除程序包package1
yum groupremove group1             #删除程序组group1
yum deplist package1               #查看程序package1依赖情况

清除缓存

yum clean packages       #清除缓存目录下的软件包
yum clean headers        #清除缓存目录下的 headers
yum clean oldheaders     #清除缓存目录下旧的 headers
http://man.linuxde.net/yum


Linux Yum 命令使用举例(很全很实用)

转载  2016年04月20日 11:30:58
  • 2809

原文地址:http://www.linuxidc.com/Linux/2011-09/42108p2.htm

纵观Linux各发行版使用的软件包管理命令,如apt-get ,dpkg, rpm ,yum,emerge等等。在命令行下,利用这类软件包管理方式来安装、卸载软件,升级软件包都将提高操作效率。Linux 的图形界面,也可以很好的完成相关操作。但是,使用命令行方式,将会得到比图形界面更好地体验。

本文给大家讲解Yum的使用15个范例:

Yum软件包管理方式,在Red Hat,Fedora,CentOS等发行版本上运用广泛。

#1,安装软件
命令格式:
yum install packagename
举例:
# 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!
上述过程中会提示你是否同意安装软件,如果嫌此问麻烦的话,可以使用下面参数-y,直接安装软件:
举例:
# yum -y install postgresql.x86_64

#2,卸载软件
命令格式:
yum remove package举例:
# 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,升级现有软件包
命令格式:
yum update package使用举例:
# yum update postgresql.x86_64

#4,“yum search”搜索已安装软件包
命令格式:
yum search keyword使用举例,搜索软件包firefox:
# 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,使用yum info查看软件包额外信息
命令格式:
yum info 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,“yum list”查看可安装的软件包
下面命令将会列出可安装的软件包:
# yum list | less

#7,“yum list installed”列出已安装软件包
可使用命令“yum list installed” 查看在系统上已安装的软件包:
# yum list installed | less

#8,”yum provides”查看特定文件属于哪个软件包
大家可以使用”yum provides”查看特定文件属于哪个软件包:
举例:
# 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
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,”yum grouplist”列出可获得的软件组
在yum中,几个相关的软件包会被放在一个特定的组内。大家安装某个软件组,这样就会安装该组所有的软件包。
使用举例:
# 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,使用yum groupinstall 安装某个特定软件组:
上个命令是列出软件组,使用“yum groupinstall ”来安装特定的软件组:
使用举例:
# 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!

#11,使用“groupupdate”升级软件组
使用“yum groupinstall”安装软件组后,可用下面命令升级该软件组到最新版本:
# 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,”yum groupremove”卸载软件组
使用举例:
# 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,列出当前yum软件源
使用举例
# yum repolist
repo id     repo name                        status
Fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612
列出所有软件源(“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
updates-testing-source    Fedora 15 - Test Updates Source          disabled
也可以使用命令“yum repositories disabled”查看已损坏的软件源。

#14,使用“yum –enablerepo”从已损坏软件源安装软件
默认情况下,yum安装软件只从当前未被损坏的软件源中安装软件。如果我们想要从已损坏源中安装软件,可以使用命令:
# 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,使用Yum Shell
如下事例:
# 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 shell 运行多个命令:
举例:
# 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
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

https://blog.csdn.net/u012359618/article/details/51199309


原文地址:http://www.linuxidc.com/Linux/2011-09/42108p2.htm

纵观Linux各发行版使用的软件包管理命令,如apt-get ,dpkg, rpm ,yum,emerge等等。在命令行下,利用这类软件包管理方式来安装、卸载软件,升级软件包都将提高操作效率。Linux 的图形界面,也可以很好的完成相关操作。但是,使用命令行方式,将会得到比图形界面更好地体验。

本文给大家讲解Yum的使用15个范例:

Yum软件包管理方式,在Red Hat,Fedora,CentOS等发行版本上运用广泛。

#1,安装软件
命令格式:
yum install packagename
举例:
# 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!
上述过程中会提示你是否同意安装软件,如果嫌此问麻烦的话,可以使用下面参数-y,直接安装软件:
举例:
# yum -y install postgresql.x86_64

#2,卸载软件
命令格式:
yum remove package举例:
# 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,升级现有软件包
命令格式:
yum update package使用举例:
# yum update postgresql.x86_64

#4,“yum search”搜索已安装软件包
命令格式:
yum search keyword使用举例,搜索软件包firefox:
# 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,使用yum info查看软件包额外信息
命令格式:
yum info 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,“yum list”查看可安装的软件包
下面命令将会列出可安装的软件包:
# yum list | less

#7,“yum list installed”列出已安装软件包
可使用命令“yum list installed” 查看在系统上已安装的软件包:
# yum list installed | less

#8,”yum provides”查看特定文件属于哪个软件包
大家可以使用”yum provides”查看特定文件属于哪个软件包:
举例:
# 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
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,”yum grouplist”列出可获得的软件组
在yum中,几个相关的软件包会被放在一个特定的组内。大家安装某个软件组,这样就会安装该组所有的软件包。
使用举例:
# 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,使用yum groupinstall 安装某个特定软件组:
上个命令是列出软件组,使用“yum groupinstall ”来安装特定的软件组:
使用举例:
# 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!

#11,使用“groupupdate”升级软件组
使用“yum groupinstall”安装软件组后,可用下面命令升级该软件组到最新版本:
# 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,”yum groupremove”卸载软件组
使用举例:
# 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,列出当前yum软件源
使用举例
# yum repolist
repo id     repo name                        status
Fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612
列出所有软件源(“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
updates-testing-source    Fedora 15 - Test Updates Source          disabled
也可以使用命令“yum repositories disabled”查看已损坏的软件源。

#14,使用“yum –enablerepo”从已损坏软件源安装软件
默认情况下,yum安装软件只从当前未被损坏的软件源中安装软件。如果我们想要从已损坏源中安装软件,可以使用命令:
# 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,使用Yum Shell
如下事例:
# 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 shell 运行多个命令:
举例:
# 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
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

猜你喜欢

转载自blog.csdn.net/xuheng8600/article/details/80050095