1. 程式人生 > >第五週 rpm與yum命令的常見選項

第五週 rpm與yum命令的常見選項

1、簡述rpm與yum命令的常見選項,並舉例

rpm 

  -i 安裝

  -U 更新

  -e 刪除

   -q 查詢

   -F更新    

-v顯示詳情

-h顯示進度條

[[email protected] ~]# rpm -qa|grep java
java-1.7.0-openjdk-headless-1.7.0.181-2.6.14.8.el7_5.x86_64
javapackages-tools-3.4.1-11.el7.noarch


java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
tzdata-java-2018e-3.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
java-1.7.0-openjdk-1.7.0.181-2.6.14.8.el7_5.x86_64

 

[[email protected] ~]# rpm -ivh rabbitmq-server-3.2.3-1.noarch.rpm 


warning: rabbitmq-server-3.2.3-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 056e8e56: NOKEY
Preparing...                          ################################# [100%]
        package rabbitmq-server-3.2.3-1.noarch is already installed

 

[[email protected] ~]# rpm -Uvh rabbitmq-server-3.7.7-1.el7.noarch.rpm
warning: rabbitmq-server-3.7.7-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
error: Failed dependencies:
        erlang >= 19.3 is needed by rabbitmq-server-3.7.7-1.el7.noarch

rpm -e --test --nodeps java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64

 

[[email protected] ~]# rpm -ql java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
/usr/lib/jvm-exports/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
/usr/lib/jvm-exports/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jaas-1.8.0.171.jar

 

[[email protected] ~]# rpm -qc java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/logging.properties
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/security/blacklisted.certs
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/security/java.policy
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/security/java.security

 

rpm -q --changelog java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64

[[email protected] ~]# rpm -qi java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
Name        : java-1.8.0-openjdk-headless
Epoch       : 1
Version     : 1.8.0.171
Release     : 8.b10.el7_5
Architecture: x86_64
Install Date: Sun 01 Jul 2018 06:58:20 PM CST
Group       : Development/Languages
Size        : 108454287
License     : ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib
Signature   : RSA/SHA256, Tue 22 May 2018 10:19:39 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM  : java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.src.rpm
Build Date  : Tue 22 May 2018 10:19:52 AM CST
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://openjdk.java.net/
Summary     : OpenJDK Runtime Environment
Description :
The OpenJDK runtime environment without audio and video support.

 

[[email protected] ~]# rpm -q --scripts java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
pretrans scriptlet (using <lua>):
-- see https://bugzilla.redhat.com/show_bug.cgi?id=1038092 for whole issue
-- see https://bugzilla.redhat.com/show_bug.cgi?id=1290388 for pretrans over pre
-- if copy-jdk-configs is in transaction, it installs in pretrans to temp
-- if copy_jdk_configs is in temp, then it means that copy-jdk-configs is in tranasction  and so is
-- preferred over one in %{_libexecdir}. If it is not in transaction, then depends 
-- whether copy-jdk-configs is installed or not. If so, then configs are copied
-- (copy_jdk_configs from %{_libexecdir} used) or not copied at all
local posix = require "posix"
local debug = false

SOURCE1 = "/var/lib/rpm-state//copy_jdk_configs.lua"
SOURCE2 = "/usr/libexec/copy_jdk_configs.lua"
 

[[email protected] ~]# rpm -q --provides rabbitmq-server-3.2.3-1.noarch
config(rabbitmq-server) = 3.2.3-1
rabbitmq-server = 3.2.3-1

rpm -Uvh --oldpackage rabbitmq-server-3.2.3-1.noarch.rpm

[[email protected] ~]# rpm -qf /var/log/rabbitmq
rabbitmq-server-3.2.3-1.noarch

  yum命令:

 *       install package1 [package2] [...]
        * update [package1] [package2] [...]
        * update-to [package1] [package2] [...]
        * update-minimal [package1] [package2] [...]
        * check-update
        * upgrade [package1] [package2] [...]
        * upgrade-to [package1] [package2] [...]
        * distribution-synchronization [package1] [package2] [...]
        * remove | erase package1 [package2] [...]
        * autoremove [package1] [...]
        * list [...]
        * info [...]
        * provides | whatprovides feature1 [feature2] [...]
        * clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
        * makecache [fast]
        * groups [...]
        * search string1 [string2] [...]
        * shell [filename]
        * resolvedep dep1 [dep2] [...]
           (maintained for legacy reasons only - use repoquery or yum provides)
        * localinstall rpmfile1 [rpmfile2] [...]

   (maintained for legacy reasons only - use install)
        * localupdate rpmfile1 [rpmfile2] [...]
           (maintained for legacy reasons only - use update)
        * reinstall package1 [package2] [...]
        * downgrade package1 [package2] [...]
        * deplist package1 [package2] [...]
        * repolist [all|enabled|disabled]
        * repoinfo [all|enabled|disabled]
        * repository-packages <enabled-repoid>  <install|remove|remove-or-reinstall|remove-or-distribution-
       synchronization> [package2] [...]
        * version [ all | installed | available | group-* | nogroups* | grouplist | groupinfo ]
              *      history      [info|list|packages-list|packages-info|summary|addon-info|redo|undo|roll‐
       back|new|sync|stats]
        * load-transaction [txfile]

 

[[email protected] ~]# yum install java
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
epel                                                                                              12616/12616
Package 1:java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64 already installed and latest version
Nothing to do

[[email protected] ~]# yum remove java
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.181-2.6.14.8.el7_5 will be erased
--> Processing Dependency: java >= 1.5 for package: jline-1.0-8.el7.noarch
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el7_5 will be erased
--> Processing Dependency: java-1.8.0-openjdk for package: icedtea-web-1.7.1-1.el7.x86_64
--> Running transaction check
---> Package icedtea-web.x86_64 0:1.7.1-1.el7 will be erased
---> Package jline.noarch 0:1.0-8.el7 will be erased
--> Processing Dependency: jline for package: rhino-1.7R5-1.el7.noarch
--> Running transaction check
---> Package rhino.noarch 0:1.7R5-1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                      Arch             Version                               Repository          Size
==============================================================================================================
Removing:
 java-1.7.0-openjdk           x86_64           1:1.7.0.181-2.6.14.8.el7_5            @updates           554 k
 java-1.8.0-openjdk           x86_64           1:1.8.0.171-8.b10.el7_5               @updates           501 k
Removing for dependencies:
 icedtea-web                  x86_64           1.7.1-1.el7                           @base              2.3 M
 jline                        noarch           1.0-8.el7                             @base               72 k
 rhino                        noarch           1.7R5-1.el7                           @base              1.1 M

Transaction Summary
==============================================================================================================
Remove  2 Packages (+3 Dependent packages)

Installed size: 4.5 M
Is this ok [y/N]: n

 

[[email protected] ~]# yum list|grep xz-java.noarch
xz-java.noarch                            1.3-3.el7                    base  

 

yum check-update

 

[[email protected] ~]# yum update xfsdump.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package xfsdump.x86_64 0:3.1.4-1.el7 will be updated
---> Package xfsdump.x86_64 0:3.1.7-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                  Arch                    Version                         Repository             Size
==============================================================================================================
Updating:
 xfsdump                  x86_64                  3.1.7-1.el7                     base                  308 k

Transaction Summary
==============================================================================================================
Upgrade  1 Package

Total download size: 308 k
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2018-07-22.15-15.PRO7RH.yumtx

 

[[email protected] ~]# yum upgrade xfsdump.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package xfsdump.x86_64 0:3.1.4-1.el7 will be updated
---> Package xfsdump.x86_64 0:3.1.7-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                  Arch                    Version                         Repository             Size
==============================================================================================================
Updating:
 xfsdump                  x86_64                  3.1.7-1.el7                     base                  308 k

Transaction Summary
==============================================================================================================
Upgrade  1 Package

Total download size: 308 k
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2018-07-22.15-16.0h9mQr.yumtx

 

[[email protected] ~]# yum erase java
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.181-2.6.14.8.el7_5 will be erased
--> Processing Dependency: java >= 1.5 for package: jline-1.0-8.el7.noarch
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el7_5 will be erased
--> Processing Dependency: java-1.8.0-openjdk for package: icedtea-web-1.7.1-1.el7.x86_64
--> Running transaction check
---> Package icedtea-web.x86_64 0:1.7.1-1.el7 will be erased
---> Package jline.noarch 0:1.0-8.el7 will be erased
--> Processing Dependency: jline for package: rhino-1.7R5-1.el7.noarch
--> Running transaction check
---> Package rhino.noarch 0:1.7R5-1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                      Arch             Version                               Repository          Size
==============================================================================================================
Removing:
 java-1.7.0-openjdk           x86_64           1:1.7.0.181-2.6.14.8.el7_5            @updates           554 k
 java-1.8.0-openjdk           x86_64           1:1.8.0.171-8.b10.el7_5               @updates           501 k
Removing for dependencies:
 icedtea-web                  x86_64           1.7.1-1.el7                           @base              2.3 M
 jline                        noarch           1.0-8.el7                             @base               72 k
 rhino                        noarch           1.7R5-1.el7                           @base              1.1 M

Transaction Summary
==============================================================================================================
Remove  2 Packages (+3 Dependent packages)

Installed size: 4.5 M
Is this ok [y/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2018-07-22.15-17.5YAvP0.yumtx

 

[[email protected] ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
base                                                                                   | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                   | 5.7 kB  00:00:00     
epel                                                                                   | 3.2 kB  00:00:00     
extras                                                                                 | 3.4 kB  00:00:00     
updates                                                                                | 3.4 kB  00:00:00     
(1/10): base/7/x86_64/other_db                                                         | 2.5 MB  00:00:01     
(2/10): epel/x86_64/filelists                                                          |  10 MB  00:00:05     
(3/10): epel/x86_64/prestodelta                                                        | 1.9 kB  00:00:00     
(4/10): epel/x86_64/other                                                              | 2.2 MB  00:00:00     
(5/10): extras/7/x86_64/prestodelta                                                    |  68 kB  00:00:01     
(6/10): updates/7/x86_64/filelists_db                                                  | 2.3 MB  00:00:01     
(7/10): extras/7/x86_64/filelists_db                                                   | 588 kB  00:00:01     
(8/10): updates/7/x86_64/other_db                                                      | 364 kB  00:00:00     
(9/10): updates/7/x86_64/prestodelta                                                   | 383 kB  00:00:09     
(10/10): extras/7/x86_64/other_db                                                      | 110 kB  00:00:15     
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
epel                                                                                              12616/12616
epel                                                                                              12616/12616
Metadata Cache Created

 

yum list|grep java

[[email protected] ~]# yum info xz-java-javadoc.noarch
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Available Packages
Name        : xz-java-javadoc
Arch        : noarch
Version     : 1.3
Release     : 3.el7
Size        : 61 k
Repo        : base/7/x86_64
Summary     : Javadocs for xz-java
URL         : http://tukaani.org/xz/java.html
License     : Public Domain
Description : This package contains the API documentation for xz-java.

 

[[email protected] ~]# yum grouplist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
Installed Environment Groups:
   GNOME Desktop
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Cinnamon Desktop
   MATE Desktop
   Basic Web Server
   Virtualization Host
   Server with GUI
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Cinnamon
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Educational Software
   Electronic Lab
   Fedora Packager
   General Purpose Desktop
   Graphical Administration Tools
   Haskell
   Legacy UNIX Compatibility
   MATE
   Milkymist
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
   TurboGears application framework
   Xfce
Done

 

[[email protected] ~]# yum groupinfo "TurboGears application framework"
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn

Group: TurboGears application framework
 Group-Id: turbogears
 Description: TurboGears web application framework.
 Optional Packages:
   TurboGears
   python-cherrypy

 

[[email protected] ~]# yum whatprovides ls
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
coreutils-8.22-21.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : base
Matched from:
Filename    : /usr/bin/ls

coreutils-8.22-18.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : @anaconda
Matched from:
Filename    : /usr/bin/ls
 

[[email protected] ~]# yum provides ls
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.shu.edu.cn
 * epel: mirror.premi.st
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
coreutils-8.22-21.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : base
Matched from:
Filename    : /usr/bin/ls

coreutils-8.22-18.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo        : @anaconda
Matched from:
Filename    : /usr/bin/ls
 

 

[[email protected] ~]# yum clean all 
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

 

[[email protected] ~]# yum groups
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Installed Environment Groups: 1
Available Environment Groups: 11
Available Groups: 20
Done

 

yum search java

 

[[email protected] ~]# yum localinstall rabbitmq-server-3.2.3-1.noarch.rpm 
Loaded plugins: fastestmirror, langpacks
Examining rabbitmq-server-3.2.3-1.noarch.rpm: rabbitmq-server-3.2.3-1.noarch
rabbitmq-server-3.2.3-1.noarch.rpm: does not update installed package.
Nothing to do

 

[[email protected] ~]# yum localupdate rabbitmq-server-3.2.3-1.noarch.rpm 
Loaded plugins: fastestmirror, langpacks
Examining rabbitmq-server-3.2.3-1.noarch.rpm: rabbitmq-server-3.2.3-1.noarch
rabbitmq-server-3.2.3-1.noarch.rpm: does not update installed package.
Nothing to do

 

[[email protected] ~]# yum  reinstall java
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.181-2.6.14.8.el7_5 will be reinstalled
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el7_5 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                      Arch             Version                                Repository         Size
==============================================================================================================
Reinstalling:
 java-1.7.0-openjdk           x86_64           1:1.7.0.181-2.6.14.8.el7_5             updates           240 k
 java-1.8.0-openjdk           x86_64           1:1.8.0.171-8.b10.el7_5                updates           246 k

Transaction Summary
==============================================================================================================
Reinstall  2 Packages

Total download size: 486 k
Installed size: 1.0 M
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
 yum load-transaction /tmp/yum_save_tx.2018-07-22.15-38.9ax8KD.yumtx

 

[[email protected] ~]# yum downgrade java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Nothing to do

 

[[email protected] ~]# yum deplist java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
package: java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el7_5
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-30.el7
  dependency: fontconfig(x86-64)
   provider: fontconfig.x86_64 2.10.95-11.el7
  dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
  dependency: libX11.so.6()(64bit)
   provider: libX11.x86_64 1.6.5-1.el7
  dependency: libXcomposite.so.1()(64bit)
   provider: libXcomposite.x86_64 0.4.4-4.1.el7
  dependency: libXext.so.6()(64bit)
   provider: libXext.x86_64 1.3.3-3.el7
  dependency: libXi.so.6()(64bit)
   provider: libXi.x86_64 1.7.9-1.el7
  dependency: libXrender.so.1()(64bit)
   provider: libXrender.x86_64 0.9.10-1.el7
  dependency: libXtst.so.6()(64bit)
   provider: libXtst.x86_64 1.2.3-1.el7
  dependency: libasound.so.2()(64bit)
   provider: alsa-lib.x86_64 1.1.4.1-2.el7
  dependency: libasound.so.2(ALSA_0.9)(64bit)
   provider: alsa-lib.x86_64 1.1.4.1-2.el7
  dependency: libasound.so.2(ALSA_0.9.0rc4)(64bit)
   provider: alsa-lib.x86_64 1.1.4.1-2.el7
  dependency: libawt.so()(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libc.so.6(GLIBC_2.14)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libdl.so.2()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libdl.so.2(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libgif.so.4()(64bit)
   provider: giflib.x86_64 4.1.6-9.el7
  dependency: libjava.so()(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libjava.so(SUNWprivate_1.1)(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libjli.so()(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.7.0-openjdk-devel.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libjli.so(SUNWprivate_1.1)(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.7.0-openjdk-devel.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libjpeg.so.62()(64bit)
   provider: libjpeg-turbo.x86_64 1.2.90-5.el7
  dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit)
   provider: libjpeg-turbo.x86_64 1.2.90-5.el7
  dependency: libjvm.so()(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libjvm.so(SUNWprivate_1.1)(64bit)
   provider: java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.8.0-openjdk-headless.x86_64 1:1.8.0.171-8.b10.el7_5
   provider: java-1.7.0-openjdk-headless.x86_64 1:1.7.0.181-2.6.14.8.el7_5
   provider: java-1.6.0-openjdk.x86_64 1:1.6.0.41-1.13.13.1.el7_3
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libm.so.6(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libpng15.so.15()(64bit)
   provider: libpng.x86_64 2:1.5.13-7.el7_2
  dependency: libpng15.so.15(PNG15_0)(64bit)
   provider: libpng.x86_64 2:1.5.13-7.el7_2
  dependency: libpthread.so.0()(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libpthread.so.0(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-222.el7
  dependency: libz.so.1()(64bit)
   provider: zlib.x86_64 1.2.7-17.el7
  dependency: xorg-x11-fonts-Type1
   provider: xorg-x11-fonts-Type1.noarch 7.5-9.el7

 

[[email protected] ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
repo id                              repo name                                                          status
base/7/x86_64                        CentOS-7 - Base                                                     9,911
*epel/x86_64                         Extra Packages for Enterprise Linux 7 - x86_64                     12,616
extras/7/x86_64                      CentOS-7 - Extras                                                     363
updates/7/x86_64                     CentOS-7 - Updates                                                    970
repolist: 23,860

 

[[email protected] ~]# yum repoinfo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Repo-id      : base/7/x86_64
Repo-name    : CentOS-7 - Base
Repo-revision: 1525378614
Repo-updated : Fri May  4 04:17:37 2018
Repo-pkgs    : 9,911
Repo-size    : 8.2 G
Repo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock
Repo-baseurl : http://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/ (9 more)
Repo-expire  : 21,600 second(s) (last: Sun Jul 22 15:31:30 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/CentOS-Base.repo

Repo-id      : epel/x86_64
Repo-name    : Extra Packages for Enterprise Linux 7 - x86_64
Repo-revision: 1532113246
Repo-updated : Sat Jul 21 03:02:11 2018
Repo-pkgs    : 12,616
Repo-size    : 13 G
Repo-metalink: https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=x86_64
  Updated    : Sun Jul 22 08:07:48 2018
Repo-baseurl : https://mirrors.ustc.edu.cn/epel/7/x86_64/ (10 more)
Repo-expire  : 21,600 second(s) (last: Sun Jul 22 15:31:32 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/epel.repo

Repo-id      : extras/7/x86_64
Repo-name    : CentOS-7 - Extras
Repo-revision: 1531861428
Repo-updated : Wed Jul 18 05:06:25 2018
Repo-pkgs    : 363
Repo-size    : 684 M
Repo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock
Repo-baseurl : http://mirrors.163.com/centos/7.5.1804/extras/x86_64/ (9 more)
Repo-expire  : 21,600 second(s) (last: Sun Jul 22 15:31:32 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/CentOS-Base.repo

Repo-id      : updates/7/x86_64
Repo-name    : CentOS-7 - Updates
Repo-revision: 1531842818
Repo-updated : Wed Jul 18 00:08:36 2018
Repo-pkgs    : 970
Repo-size    : 3.2 G
Repo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock
Repo-baseurl : http://mirrors.cn99.com/centos/7.5.1804/updates/x86_64/ (9 more)
Repo-expire  : 21,600 second(s) (last: Sun Jul 22 15:31:33 2018)
  Filter     : read-only:present
Repo-filename: /etc/yum.repos.d/CentOS-Base.repo

repolist: 23,860

 

[[email protected] ~]# yum groupremove "GNOME Desktop"

 

2、自建yum倉庫,分別為網路源和本地源

[[email protected] yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
 


3、簡述at和crontab命令,制定 每週三凌晨三、五點10分執行某個指令碼,輸出當前時間,時間格式為 2017-12-28 10:00:00

at指定某個時間執行某個任務,crontab可以執行週期性任務。

at常用命令有

[[email protected] yum.repos.d]# atq
3       Sun Jul 22 16:04:00 2018 a root

[[email protected] yum.repos.d]# atrm 3
[[email protected] yum.repos.d]# atq

crontab -e

10 3,5 * * 3 root date "+%Y-%m-%d %H:%M:%S"

 

[[email protected] yum.repos.d]# crontab -l
10 3,5 * * 3 root date "+%Y-%m-%d %H:%M:%S"

[[email protected] yum.repos.d]# crontab -r
[[email protected] yum.repos.d]# crontab -l
no crontab for root

 


4、簡述sed常用操作命令,並舉例

 

sed是一個很好的檔案處理工具,本身是一個管道命令,主要是以行為單位進行處理,可以將資料行進行替換、刪除、新增、選取等特定工作,下面先了解一下sed的用法
sed命令列格式為:
         sed [-nefri] ‘command’ 輸入文字        

常用選項:
        -n∶使用安靜(silent)模式。在一般 sed 的用法中,所有來自 STDIN的資料一般都會被列出到螢幕上。但如果加上 -n 引數後,則只有經過sed 特殊處理的那一行(或者動作)才會被列出來。
        -e∶直接在指令列模式上進行 sed 的動作編輯;
        -f∶直接將 sed 的動作寫在一個檔案內, -f filename 則可以執行 filename 內的sed 動作;
        -r∶sed 的動作支援的是延伸型正規表示法的語法。(預設是基礎正規表示法語法)
        -i∶直接修改讀取的檔案內容,而不是由螢幕輸出。       

常用命令:
        a   ∶新增, a 的後面可以接字串,而這些字串會在新的一行出現(目前的下一行)~
        c   ∶取代, c 的後面可以接字串,這些字串可以取代 n1,n2 之間的行!
        d   ∶刪除,因為是刪除啊,所以 d 後面通常不接任何咚咚;
         i   ∶插入, i 的後面可以接字串,而這些字串會在新的一行出現(目前的上一行);
         p  ∶列印,亦即將某個選擇的資料印出。通常 p 會與引數 sed -n 一起運作~
         s  ∶取代,可以直接進行取代的工作哩!通常這個 s 的動作可以搭配正規表示法!例如 1,20s/old/new/g 就是啦!

舉例:(假設我們有一檔名為ab)
     刪除某行
     [[email protected] ] # sed '1d' ab              #刪除第一行 
     [[email protected] ] # sed '$d' ab              #刪除最後一行
     [[email protected] ] # sed '1,2d' ab           #刪除第一行到第二行
     [[email protected] ] # sed '2,$d' ab           #刪除第二行到最後一行

  顯示某行
.    [[email protected] ] # sed -n '1p' ab           #顯示第一行 
     [[email protected] ] # sed -n '$p' ab           #顯示最後一行
     [[email protected] ] # sed -n '1,2p' ab        #顯示第一行到第二行
     [[email protected] ] # sed -n '2,$p' ab        #顯示第二行到最後一行

  使用模式進行查詢
     [[email protected] ] # sed -n '//p' ab    #查詢包括關鍵字所在所有行
     [[email protected] ] # sed -n '/\$/p' ab      &nbs