Linux下的yum命令及yum源設定
yum install softwarename #安裝
yum repolist #列出設定yum源資訊
yum list softwarename #檢視軟體源中是否有此軟體
yum list installed #列出已經安裝的軟體名稱
yum list available #列出可以用yum安裝的軟體
yum search softwareinfo #根據軟體資訊搜尋軟體名字(如,使用search web搜尋web瀏覽器)
yum whatprovides filename #在yum源中查詢包含filename檔案的軟體包
yum history #檢視系統軟體改變歷史
yum reinstall softwarename #重新安裝
yum info softwarename #檢視軟體資訊
yum groups list #檢視軟體組資訊
yum groups install softwarename #安裝元件
yum groups remove softwarename #解除安裝元件
2、本地yum源的自定義安裝
(1)找和系統匹配的映象檔案到系統中
hostnamectl檢視本機系統版本
(2)mkdir /iso #建立目錄
(3)mv /home/kiosk/Desktop/*.iso /iso #將映象放至/iso目錄下,防止誤刪(本步操作不是必須的)
(4)mkdir /rhel7.0 /rhel7.2 #建立掛載裝置
(5)mount /iso/rhel-server-7.0-x86_64-dvd.iso /rhel7.0 #將7.0映象掛在到/rhel7.0目錄
(6)mount /iso/rhel-server-7.2-x86_64-dvd.iso /rhel7.2 #將7.0映象掛在到/rhel7.2目錄
(8)mkdir /repobackup
(9)mv * /repobackup #備份檔案,以便日後使用
(10)vim yum.repo #檔名可以任意,但必須是.repo字尾
(寫入內容:
[rhel7.2] #倉庫名
name=rhel7.2
baseurl=file:///rhel7.2(file:// 訪問本地檔案
gpgcheck=0 #對是否官方授權進行檢測,0表示可以安裝非官方軟體
(11)yum clean all #清理快取
4、共享yum源的安裝
在本地yum源安裝完成後,執行如下操作:
(1)安裝apache
yum install httpd #安裝systemctl start httpd
systemctl enable httpd #開啟服務
systemctl stop firewalld
systemctl disable firewalld #關閉防火牆
systemctl status httpd #檢視服務狀態是否正常
mkdir /var/www/html/rhel7.0
mkdir /var/www/html/rhel7.2 #建立目錄(注意路徑,只有/var/www/html/才能被時別)
mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2 #掛載映象
在瀏覽器中輸入地址
http://172.25.254.68/rhel7.0
http://172.25.254.68/rhel7.2
cd /etc/yum.repos.d
ls
rm -fr *
vim yum.repo
(寫入內容
[rhel7.0]
name=rhel7.0
baseurl=http://172.25.254.68/rhel7.0
gpgcheck=0)
yum clean all
yum install httpd #測試,虛擬機器可以下載軟體
如圖,虛擬機器可以使用yum命令正常下載httpd
注:掛載會在關機後消失,如圖,reboot後掛載消失
(5)為了使其自動掛載,可在掛載後執行作如下操作:
vim /etc/rc.d/rc.local #開機時自動執行的指令碼(寫入:
mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2)
baseurl=file:///var/www/html/rhel7.2
chmod +x /etc/rc.d/rc.local #新增執行許可權
測試如下:
設定完成後,reboot之後檢視,掛載仍然存在