1、简述rpm与yum命令的常见选项,并举例
rpm
-i 安装
-U 更新
-e 删除
-q 查询
-F更新
-v显示详情
-h显示进度条
[root@node1 ~]# 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
[root@node1 ~]# 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
[root@node1 ~]# 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.noarchrpm -e --test --nodeps java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64
[root@node1 ~]# 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
[root@node1 ~]# 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
[root@node1 ~]# 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 :
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://>
Vendor : CentOS
URL : http:///
Summary : OpenJDK Runtime Environment
Description :
The OpenJDK runtime environment without audio and video support.
[root@node1 ~]# 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:///show_bug.cgi?id=1038092 for whole issue
-- see https:///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 = falseSOURCE1 = "/var/lib/rpm-state//copy_jdk_configs.lua"
SOURCE2 = "/usr/libexec/copy_jdk_configs.lua"
[root@node1 ~]# rpm -q --provides rabbitmq-server-3.2.3-1.noarch
config(rabbitmq-server) = 3.2.3-1
rabbitmq-server = 3.2.3-1rpm -Uvh --oldpackage rabbitmq-server-3.2.3-1.noarch.rpm
[root@node1 ~]# 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]
[root@node1 ~]# yum install java
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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[root@node1 ~]# 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 ResolutionDependencies 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 MTransaction Summary
==============================================================================================================
Remove 2 Packages (+3 Dependent packages)Installed size: 4.5 M
Is this ok [y/N]: n
[root@node1 ~]# yum list|grep xz-java.noarch
xz-java.noarch 1.3-3.el7 base
yum check-update
[root@node1 ~]# yum update xfsdump.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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 ResolutionDependencies Resolved
==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Updating:
xfsdump x86_64 3.1.7-1.el7 base 308 kTransaction Summary
==============================================================================================================
Upgrade 1 PackageTotal 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
[root@node1 ~]# yum upgrade xfsdump.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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 ResolutionDependencies Resolved
==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Updating:
xfsdump x86_64 3.1.7-1.el7 base 308 kTransaction Summary
==============================================================================================================
Upgrade 1 PackageTotal 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
[root@node1 ~]# 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 ResolutionDependencies 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 MTransaction 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
[root@node1 ~]# 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:
* epel: mirror.premi.st
* extras:
* updates:
epel 12616/12616
epel 12616/12616
Metadata Cache Created
yum list|grep java
[root@node1 ~]# yum info xz-java-javadoc.noarch
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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:///xz/java.html
License : Public Domain
Description : This package contains the API documentation for xz-java.
[root@node1 ~]# yum grouplist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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
[root@node1 ~]# yum groupinfo "TurboGears application framework"
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates: Group: TurboGears application framework
Group-Id: turbogears
Description: TurboGears web application framework.
Optional Packages:
TurboGears
python-cherrypy
[root@node1 ~]# yum whatprovides ls
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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/lscoreutils-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
[root@node1 ~]# yum provides ls
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel: mirror.premi.st
* extras:
* updates:
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/lscoreutils-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
[root@node1 ~]# 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
[root@node1 ~]# yum groups
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel:
* extras:
* updates:
Installed Environment Groups: 1
Available Environment Groups: 11
Available Groups: 20
Done
yum search java
[root@node1 ~]# 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
[root@node1 ~]# 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
[root@node1 ~]# yum reinstall java
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel:
* extras:
* updates:
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 ResolutionDependencies 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 kTransaction Summary
==============================================================================================================
Reinstall 2 PackagesTotal 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
[root@node1 ~]# 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:
* epel:
* extras:
* updates:
Nothing to do
[root@node1 ~]# 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:
* epel:
* extras:
* updates:
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
[root@node1 ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel:
* extras:
* updates:
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
[root@node1 ~]# yum repoinfo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base:
* epel:
* extras:
* updates:
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:///?release=7&arch=x86_64&repo=os&infra=stock
Repo-baseurl : http:///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.repoRepo-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:///metalink?repo=epel-7&arch=x86_64
Updated : Sun Jul 22 08:07:48 2018
Repo-baseurl : https:///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.repoRepo-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:///?release=7&arch=x86_64&repo=extras&infra=stock
Repo-baseurl : http:///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.repoRepo-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:///?release=7&arch=x86_64&repo=updates&infra=stock
Repo-baseurl : http:///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.reporepolist: 23,860
[root@node1 ~]# yum groupremove "GNOME Desktop"
2、自建yum仓库,分别为网络源和本地源
[root@node1 yum.repos.d]# cat epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http:///pub/epel/7/$basearch
metalink=https:///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常用命令有
[root@node1 yum.repos.d]# atq
3 Sun Jul 22 16:04:00 2018 a root[root@node1 yum.repos.d]# atrm 3
[root@node1 yum.repos.d]# atqcrontab -e
10 3,5 * * 3 root date "+%Y-%m-%d %H:%M:%S"
[root@node1 yum.repos.d]# crontab -l
10 3,5 * * 3 root date "+%Y-%m-%d %H:%M:%S"[root@node1 yum.repos.d]# crontab -r
[root@node1 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)
删除某行
[root@localhost ruby] # sed '1d' ab #删除第一行
[root@localhost ruby] # sed '$d' ab #删除最后一行
[root@localhost ruby] # sed '1,2d' ab #删除第一行到第二行
[root@localhost ruby] # sed '2,$d' ab #删除第二行到最后一行 显示某行
. [root@localhost ruby] # sed -n '1p' ab #显示第一行
[root@localhost ruby] # sed -n '$p' ab #显示最后一行
[root@localhost ruby] # sed -n '1,2p' ab #显示第一行到第二行
[root@localhost ruby] # sed -n '2,$p' ab #显示第二行到最后一行 使用模式进行查询
[root@localhost ruby] # sed -n '/ruby/p' ab #查询包括关键字ruby所在所有行
[root@localhost ruby] # sed -n '/\$/p' ab #查询包括关键字$所在所有行,使用反斜线\屏蔽特殊含义 增加一行或多行字符串
[root@localhost ruby]# cat ab
Hello!
ruby is me,welcome to my blog.
end
[root@localhost ruby] # sed '1a drink tea' ab #第一行后增加字符串"drink tea"
Hello!
drink tea
ruby is me,welcome to my blog.
end
[root@localhost ruby] # sed '1,3a drink tea' ab #第一行到第三行后增加字符串"drink tea"
Hello!
drink tea
ruby is me,welcome to my blog.
drink tea
end
drink tea
[root@localhost ruby] # sed '1a drink tea\nor coffee' ab #第一行后增加多行,使用换行符\n
Hello!
drink tea
or coffee
ruby is me,welcome to my blog.
end 代替一行或多行
[root@localhost ruby] # sed '1c Hi' ab #第一行代替为Hi
Hi
ruby is me,welcome to my blog.
end
[root@localhost ruby] # sed '1,2c Hi' ab #第一行到第二行代替为Hi
Hi
end 替换一行中的某部分
格式:sed 's/要替换的字符串/新的字符串/g' (要替换的字符串可以用正则表达式)
[root@localhost ruby] # sed -n '/ruby/p' ab | sed 's/ruby/bird/g' #替换ruby为bird
[root@localhost ruby] # sed -n '/ruby/p' ab | sed 's/ruby//g' #删除ruby 插入
[root@localhost ruby] # sed -i '$a bye' ab #在文件ab中最后一行直接输入"bye"
[root@localhost ruby]# cat ab
Hello!
ruby is me,welcome to my blog.
end
bye 删除匹配行
sed -i '/匹配字符串/d' filename (注:若匹配字符串是变量,则需要“”,而不是‘’。记得好像是)
替换匹配行中的某个字符串
sed -i '/匹配字符串/s/替换源字符串/替换目标字符串/g' filename