相對于rpm
的命令管理,不需要管理依賴性。
使用yum
在線管理,不僅會安裝你要安裝的包,還會安裝相應的依賴包。
yum
在線管理的話,并不是一定要在線,可以做本地yum·
源。
沒有yum包這個說法,yum在線管理的還是RPM
包。
ifconfig
配置的IP地址,是臨時生效的,一旦重啟,會恢復原樣。用這種方式只能配置IP和子網掩碼。如果想要上網還需要網關和DNS。如果在內網訪問,只要IP和子網掩碼就可以了。但是如果想要訪問公網,就需要網關和DNS。使用ifconfig
就做不到這樣的功能。
配置IP有很多種方法,我們可以選擇一個比較簡單的setup
方法。setup
是redhat系列專有的命令,setup
配置IP相對簡單。
按tab鍵可以切換。
網絡yum源:
CentOS-Base.repo
: 網路yum源。
CentOS-Media.repo
: 本地光盤yum源。
CentOS-Base.repo
里面的配置:
1 # CentOS-Base.repo
2 #
3 # The mirror system uses the connecting IP address of the client and the
4 # update status of each mirror to pick mirrors that are updated to and
5 # geographically close to the client. You should use this for CentOS update s
6 # unless you are manually picking other mirrors.
7 #
8 # If the mirrorlist= does not work for you, as a fall back you can try the
9 # remarked out baseurl= line instead.
10 #
11 #
12
13 [base]
14 name=CentOS-$releasever - Base
15 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch& repo=os&infra=$infra
16 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
17 gpgcheck=1
18 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
19
20 #released updates
21 [updates]
22 name=CentOS-$releasever - Updates
23 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch& repo=updates&infra=$infra
24 #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
25 gpgcheck=1
26 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
27
28 #additional packages that may be useful
29 [extras]
30 name=CentOS-$releasever - Extras
31 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch& repo=extras&infra=$infra
32 #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
33 gpgcheck=1
34 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
35
36 #additional packages that extend functionality of existing packages
37 [centosplus]
38 name=CentOS-$releasever - Plus
39 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch& repo=centosplus&infra=$infra
40 #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
41 gpgcheck=1
42 enabled=0
43 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
44
從上面可以看出:
[base]
與[updates]
是一樣的格式,定義的相同的內容。
里面有:[base]
,[updates]
,[extras]
,[centosplus]
這么幾個軟件池,默認是第一個軟件池([base]
)生效。
結合上面的圖片來查看這個配置。
常用的yum命令:
yum list
列出所有可用的軟件包 。
yum列出的包:
分為:包名, 版本, 容器的名稱
yum的庫存:
$ cd /etc/yum.repos.d/
yum search 關鍵字
來搜索服務器上的所有和關鍵字相關的包。
eg:yum -y install gcc
如果:yum -y update
不跟包名,那么就是更新所有軟件包,包括Linux內核都會升級。內核如果升級之后,那么需要在本地做一些配置才能,所以遠程執行了這個命令,那么服務器就不能開機了,謹慎使用。
軟件組管理:
光盤yum源搭建
也就是本地yum源搭建。
對服務器來說考慮的最主要的是穩定和安全,本地yum光盤可能不是最新的,這個無所謂。
做本地Yum源,需要做一定的配置。
讓yum源失效的辦法就是修改掉.repo
的后綴。
改掉名字之后,本地yum源修改配置:
這樣本地yum源就配置好了。
管道符號(
|
)
Linux所提供的管道符“|”將兩個命令隔開,管道符左邊命令的輸出就會作為管道符右邊命令的輸入。
grep "main" test.c
用來搜索test.c
里是否包含字串 main
注意:在baseurl=file:///mnt/cdrom
后面不能加任何空格或者tab,也不能寫注釋這些,嚴格的要求。