linux的yum命令

linux yum 命令

yum( Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。

基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。

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

yum 语法

yum [options] [command] [package ...]
  • options:可选,选项包括-h(帮助),-y(当安装过程提示选择全部为"yes"),-q(不显示安装的过程)等等。
  • command:要进行的操作。
  • package操作的对象。

yum常用命令

  • 1.列出所有可更新的软件清单命令:yum check-update
  • 2.更新所有软件命令:yum update
  • 3.仅安装指定的软件命令:yum install <package_name>
  • 4.仅更新指定的软件命令:yum update <package_name>
  • 5.列出所有可安裝的软件清单命令:yum list
  • 6.删除软件包命令:yum remove <package_name>
  • 7.查找软件包 命令:yum search <keyword>
  • 8.清除缓存命令:
    • yum clean packages: 清除缓存目录下的软件包
    • yum clean headers: 清除缓存目录下的 headers
    • yum clean oldheaders: 清除缓存目录下旧的 headers
    • yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :清除缓存目录下的软件包及旧的headers

国内 yum 源

网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错。

将yum源设置为163 yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Mar 28  2017 CentOS-Base.repo
-rw-r--r--. 1 root root  647 Mar 28  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  289 Mar 28  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Mar 28  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 Mar 28  2017 CentOS-Vault.repo
[root@localhost yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost yum.repos.d]# ll
total 24
-rw-r--r--. 1 root root 1991 Mar 28  2017 CentOS-Base.repo.backup
-rw-r--r--. 1 root root  647 Mar 28  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  289 Mar 28  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Mar 28  2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 Mar 28  2017 CentOS-Vault.repo
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
--2019-12-04 01:17:41--  http://mirrors.163.com/.help/CentOS6-Base-163.repo
Resolving mirrors.163.com... 59.111.0.251
Connecting to mirrors.163.com|59.111.0.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2006 (2.0K) [application/octet-stream]
Saving to: “CentOS6-Base-163.repo”

100%[=================================================================================================================>] 2,006       --.-K/s   in 0s

2019-12-04 01:17:42 (349 MB/s) - “CentOS6-Base-163.repo” saved [2006/2006]

[root@localhost yum.repos.d]# mv CentOS6-Base-163.repo CentOS-Base.repo
[root@localhost bin]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@localhost bin]# yum makecache
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
base                                                                                                                                | 3.7 kB     00:00
base/group_gz                                                                                                                       | 242 kB     00:00
base/filelists_db                                                                                                                   | 6.4 MB     00:02
base/primary_db                                                                                                                     | 4.7 MB     00:01
base/other_db                                                                                                                       | 2.8 MB     00:00
extras                                                                                                                              | 3.4 kB     00:00
extras/filelists_db                                                                                                                 |  24 kB     00:00
extras/prestodelta                                                                                                                  | 2.2 kB     00:00
extras/primary_db                                                                                                                   |  29 kB     00:00
extras/other_db                                                                                                                     |  14 kB     00:00
updates                                                                                                                             | 3.4 kB     00:00
updates/filelists_db                                                                                                                | 5.2 MB     00:06
updates/prestodelta                                                                                                                 | 258 kB     00:00
updates/primary_db                                                                                                                  | 7.5 MB     00:02
updates/other_db                                                                                                                    | 330 kB     00:00
Metadata Cache Created
[root@localhost bin]#

实例 1

安装 pam-devel

[root@localhost bin]# yum install pam-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pam-devel.x86_64 0:1.1.1-24.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                               Arch                               Version                                   Repository                        Size
===========================================================================================================================================================
Installing:
 pam-devel                             x86_64                             1.1.1-24.el6                              base                             205 k

Transaction Summary
===========================================================================================================================================================
Install       1 Package(s)

Total download size: 205 k
Installed size: 547 k
Is this ok [y/N]: y
Downloading Packages:
pam-devel-1.1.1-24.el6.x86_64.rpm                                                                                                   | 205 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pam-devel-1.1.1-24.el6.x86_64                                                                                                           1/1
  Verifying  : pam-devel-1.1.1-24.el6.x86_64                                                                                                           1/1

Installed:
  pam-devel.x86_64 0:1.1.1-24.el6

Complete!
[root@localhost bin]#

实例 2

移除 pam-devel

[root@localhost bin]# yum remove pam-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package pam-devel.x86_64 0:1.1.1-24.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                               Arch                               Version                                  Repository                         Size
===========================================================================================================================================================
Removing:
 pam-devel                             x86_64                             1.1.1-24.el6                             @base                             547 k

Transaction Summary
===========================================================================================================================================================
Remove        1 Package(s)

Installed size: 547 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : pam-devel-1.1.1-24.el6.x86_64                                                                                                           1/1
  Verifying  : pam-devel-1.1.1-24.el6.x86_64                                                                                                           1/1

Removed:
  pam-devel.x86_64 0:1.1.1-24.el6

Complete!
[root@localhost bin]#

实例 3

利用 yum 的功能,找出以 yum 为开头的软件名称有哪些?

[root@localhost bin]# yum list yum*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Installed Packages
yum.noarch                                        3.2.29-81.el6.centos                                             @anaconda-CentOS-201703281317.x86_64/6.9
Available Packages
yum.noarch                                        3.2.29-81.el6.centos.0.1                                         updates
[root@localhost bin]#

 

上一篇:hdu 5831 Rikka with Parenthesis II 括号匹配+交换


下一篇:linux:vsftpd登录报530 Login incorrect无法登录问题