yum使用

第一部分yum基礎
yum 參數:
search (搜索某個軟件名稱或是描述的重要關鍵字)
list(類似于rpm -qa)
info(類似于rpm -qai)
provides(類似于rpm -qf)
eg:搜索磁盤陳列raid相關的軟件有哪些?
[root@centos7 yum]#yum search raid
找出mdadm這個軟件的功能為何?
[root@centos7 yum]#yum info mdadm
列出yum服務器上面提供的所有軟件名稱?
[root@centos7 yum]#yum list
列出目前服務上可供本機進行升級的軟件有哪些?
[root@centos7 yum]#yum list updates
列出提供passwd 這個文件的軟件有哪些?
[root@centos7 yum]#yum provides passwd
列出以pam為開頭的軟件名稱有哪些?
[root@centos7 yum]#yum list pam*
怎樣用yum 刪除軟件pan-devel?
[root@centos7 yum]#yum remove pan-devel
如何使用光盤當作本地yum倉庫:
(1)掛載光盤至某目錄,例如/media/cdrom
#mount -r -t iso*** /dev/cdrom /media/cdrom
(2)創建配置文件
[ base] 代表容器的名字
name=
baseurl= 后 面接的就是容器的實際網址
gpgcheck=1 指定是否需要查閱RPM文件內的數字證書
enabled=1(0為不讓容器啟動)
mirrorlist= 列出這個容器可以使用的鏡像站點
yum的命令行選項:
–nogpgcheck:禁止進行gpg check
-y:自動回答為yes
-q:靜默模式
–disablerepo=reporidglob臨時禁用此處指定的repo
–noplugins禁用所胡插件
yum的repo配置文件可用的變量:
$releasever :當 前os的發行版的主版本號
$arch:平臺
$basearch:基礎平臺
$yum0-$yum9
http://mirrors.magedu.com/centos/$releasever/$basearch/os
列出目前yum server所使用的容器有哪些?
[root@centos7 yum]#yum repolist all
怎樣清除掉本機上面的舊數據?
[root@centos7 yum]#yum clean [packages|headers|all]
表示將已下載的軟件文件,軟件文件頭,所有容器數據都刪除
?
yum 的軟件組功能:
grouplist
groupinfo
groupinstall (可以安整組的軟件)
groupremvove
怎樣全系統自動升級?yum -y update
假設我每天在北京時間凌晨3:00進行自動升級?
[root@centos7 yum]#vim /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .—————- minute (0 – 59)
# | .————- hour (0 – 23)
# | | .———- day of month (1 – 31)
# | | | .——- month (1 – 12) OR jan,feb,mar,apr …
# | | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# * * * * * user-name command to be executed
03 ***root /usr/bin/yum -y update
情境:實際安裝php,php-mysql,httpd-devel?
1.檢查所需要的軟件是否存在,最好直接使用rpm,因為可以直接取得rpm的數據庫內容
[root@centos7 yum]#rpm -q httpd httpd-devel php php-devel php-mysql
package httpd is not installed
package httpd-devel is not installed
package php is not installed
package php-devel is not installed
package php-mysql is not installed
2。確認網絡的可行性
[root@centos7 yum]#ifconfig ens33(看自己的ip是否存在)
[root@centos7 yum]#route -n (看有沒有路由器設置存在)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.20.0.1 0.0.0.0 UG 100 0 0 ens33
172.20.0.0 0.0.0.0 255.255.0.0 U 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0
[root@centos7 yum]#ping -c 2 172.20.0.1看路由器設置是否正確
PING 172.20.0.1 (172.20.0.1) 56(84) bytes of data.
64 bytes from 172.20.0.1: icmp_seq=1 ttl=64 time=0.674 ms
64 bytes from 172.20.0.1: icmp_seq=2 ttl=64 time=0.536 ms
3.[root@centos7 yum]#dig www.goole.com
; <<>> DiG 9.9.4-RedHat-9.9.4-50.el7 <<>> www.goole.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23366
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.goole.com. IN A
;; ANSWER SECTION:
www.goole.com. 1320 IN A 87.106.83.127
;; Query time: 235 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Apr 20 16:09:30 CST 2018
網絡設置妥當后,就可直接使用yum進行安裝了
[root@centos7 yum]#yum install httpd httpd-devel php php-devel php-mysql
列出的都是已經裝好的包
[root@centos7 yum.repos.d]#yum list installed
第二部分yum應用
1.yum-config-manager –add-repo=http:….這是一個非交互式命令,可以生成配置文件
eg:
[root@centos7 ~]#cd /etc/yum.repos.d/(yum的配置文件)
[root@centos7 yum.repos.d]#yum-config-manager –add-repo=http://172.20.0.1/centos/7/
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
adding repo from: http://172.20.0.1/centos/7/
[172.20.0.1_centos_7_]
name=added from: http://172.20.0.1/centos/7/
baseurl=http://172.20.0.1/centos/7/
enabled=1
[root@centos7 yum.repos.d]#ls
172.20.0.1_centos_7_.repo CentOS-fasttrack.repo
Centos-7.repo CentOS-Media.repo
CentOS-Base.repo CentOS-Sources.repo
CentOS-CR.repo CentOS-Vault.repo
CentOS-Debuginfo.repo
[root@centos7 yum.repos.d]#cat 172.20.0.1_centos_7_.repo
[172.20.0.1_centos_7_]
name=added from: http://172.20.0.1/centos/7/
baseurl=http://172.20.0.1/centos/7/
enabled=1
2.[root@centos7 ~]#du -sh . (查看文件大小)
7.7M .
3。yum高級應用
[root@centos7 yum.repos.d]#yum history list(列出yum的歷史動作)
[root@centos7 yum.repos.d]#yum history list 8(列出yum歷史中第8個動作的具體信息)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
ID | Command line | Date and time | Action(s) | Altered
——————————————————————————-
8 | install mariadb-server | 2018-04-20 17:13 | Install | 1
history list
[root@centos7 yum.repos.d]#yum history undo 8(撤銷第8個動作,也即不安裝,等于卸載刪除!!!!它是和指定記錄中的動作執行完全相反的動作)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Undoing transaction 8, from Fri Apr 20 17:13:09 2018
Install mariadb-server-1:5.5.56-2.el7.x86_64 @172.20.0.1_centos_7_
No package matched to remove: mariadb-server-1:5.5.56-2.el7
history undo
?
[root@centos7 yum.repos.d]#yum history redo 8 (把第8個動作再重復執行一次)
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repeating transaction 13, from Fri Apr 20 17:56:22 2018
Erase mariadb-1:5.5.56-2.el7.x86_64 @172.20.0.1_centos_7_
Erase perl-DBD-MySQL-4.023-5.el7.x86_64 @172.20.0.1_centos_7_
No package matched to remove: mariadb-1:5.5.56-2.el7
No package matched to remove: perl-DBD-MySQL-0:4.023-5.el7
history redo

本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/96652

(1)
單爆手單爆手
上一篇 2018-04-20 18:11
下一篇 2018-04-20 19:45

相關推薦

  • 第二周博客作業-N31-Linux文件、目錄及其相關命令

    本篇文章主要圍繞Linux的文件、目錄及其相關的操作命令,如:mkdir、rmdir、tree、cat、tail、more、less、mv、cp、rm等命令

    2018-07-27
  • liunx 基礎知識

    命令提示符 #表示管理員 ?$ 表示普通用戶 ?。顯示提示符格式 ::修改提示符格式 ?: 命令別名 :    

    Linux筆記 2018-04-01
  • liunx基礎命令

    alias:查看命令別名(別名只針對用戶有效) alias h=hostname(定義別名) cdnet=‘cd /etc/sysconfig/network-scripts/’(帶參數命令的要帶單引號) 想長久生效修改.bashrc文件(root為/root/.bashrc,全部用戶為/etc/bashrc,其他/home/user/.bashrc) un…

    Linux筆記 2018-04-08
  • 進程和計劃管理

    進程 進程是運行中的程序。每個程序啟動后都會創建一個或多個程序。 常用查看進程的命令 ps 默認只查看當前用戶終端中打開的進程 ps aux 顯示所有進程信息,包括非終端登錄以及其他終端、用戶打開的進程 top 在當前終端以交互式方式顯示進程排名,及時跟蹤CPU、內存等系統資源的使用情況,默認三秒刷新一次。 P鍵:根據CPU占用情況對進程進行排序 M鍵:根據…

    Linux筆記 2018-05-06
  • redis

    分布式存儲一定是每個節點只存儲一部分數據。

    2018-07-20
欧美性久久久久