歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux Yum 命令使用舉例

Linux Yum 命令使用舉例

日期:2017/2/28 16:07:45   编辑:Linux教程

縱觀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
...

Copyright © Linux教程網 All Rights Reserved