linux下的yum-----软件安装与共享

1.yum的基本命令

yum  list (all,installed,available)         列出(所有,已安装,未安装)
yum  search                                 根据软件信息搜索软件
yum  whatprovides                           根据软件包中包含的文件搜索
yum  reinstall                              重新安装
yum  update                                 更新软件
yum  repolist                               列出设定yum源信息





2.查找需要下载的文件

[root@foundation42 ~]# mv   /rhel-server-7.2-x86_64-dvd.iso     /iso/
[root@foundation42 ~]# mkdir  /rhel7.0       
[root@foundation42 ~]# mkdir  /rhel7.2       
[root@foundation42 ~]# ls /
bin   dev  home  lib    media  opt   rhel7.0  root  sbin  sys  usr
boot  etc  iso   lib64  mnt    proc  rhel7.2  run   srv   tmp  var
[root@foundation42 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso  /rhel7.2/  挂载
mount:  /dev/loop0 is write-protected, mounting read-only
[root@foundation42 ~]# cd /home/kiosk/Desktop
[root@foundation42 Desktop]# mv rhel-server-7.0-x86_64-dvd.iso /iso/
[root@foundation42 Desktop]# cd /iso
[root@foundation42 iso]# ls
rhel-server-7.0-x86_64-dvd.iso  rhel-server-7.2-x86_64-dvd.iso
[root@foundation42 iso]# mount /iso/rhel-server-7.0-x86_64-dvd.iso  /rhel7.0/
mount: /dev/loop1 is write-protected, mounting read-only
[root@foundation42 iso]# ls /rhel7.0/Package/ | grep dhcp   用命令查看是否挂载成功且其中有所需命令内容
ls: cannot access /rhel7.0/Package/: No such file or directory
[root@foundation42 iso]# ls /rhel7.0/Packages/ | grep dhcp
dhcp-4.2.5-27.el7.x86_64.rpm
dhcp-common-4.2.5-27.el7.x86_64.rpm
dhcp-libs-4.2.5-27.el7.i686.rpm
dhcp-libs-4.2.5-27.el7.x86_64.rpm
[root@foundation42 iso]# cd /etc/yum.repos.d/
[root@foundation42 yum.repos.d]# ls
redhat.repo  rhel-dvd.repo  rht-extras.repo
[root@foundation42 yum.repos.d]# mkdir /repobackup
[root@foundation42 yum.repos.d]# mv * /repobackup/             建立一个文件夹把现在不需要的repo文件备份起来
[root@foundation42 yum.repos.d]# ls               

[root@foundation42 yum.repos.d]# vim  yum.repo

原来东西不能用,需要自己重新写 把原先的文件放到另外一个文件夹内

vim内

vim rhel.repo

[rhel7.2]
name=rhel7.2
baseurl=file:///rhel7.2

gpgcheck=0

:wq退出保存


[root@foundation42 yum.repos.d]# yum clean all               清除缓存
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7.2

Cleaning up everything






测试

重新安装sudo软件

[root@foundation42 Desktop]# yum reinstall sudo-1.8.6p7-16.el7.x86_64
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package sudo.x86_64 0:1.8.6p7-16.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package               Arch                    Version                          Repository                Size
===============================================================================================================
Reinstalling:
 sudo                  x86_64                  1.8.6p7-16.el7                   rhel7.2                  732 k

Transaction Summary
===============================================================================================================
Reinstall  1 Package

Total download size: 732 k
Installed size: 2.4 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : sudo-1.8.6p7-16.el7.x86_64                                                                  1/1
rhel7.2/productid                                                                       | 1.6 kB  00:00:00     
  Verifying  : sudo-1.8.6p7-16.el7.x86_64                                                                  1/1

Installed:
  sudo.x86_64 0:1.8.6p7-16.el7                                                                                 

Complete!


[root@foundation42 Desktop]# systemctl start httpd    打开服务
[root@foundation42 Desktop]# systemctl enable httpd 开机开启服务
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@foundation42 Desktop]# systemctl stop firewalld    关闭防火墙
[root@foundation42 Desktop]# systemctl disable firewalld 开机关闭服务
[root@foundation42 Desktop]# mkdir /var/www/html/rhel7.0 /var/www/html/rhel7.2
[root@foundation42 Desktop]# mount /iso/rhel-server-7.0-x86_64-dvd.iso  /var/www/html/rhel7.0
mount: /dev/loop2 is write-protected, mounting read-only
[root@foundation42 Desktop]# mount /iso/rhel-server-7.2-x86_64-dvd.iso  /var/www/html/rhel7.2
mount: /dev/loop3 is write-protected, mounting read-only      挂载镜像
[root@foundation42 Desktop]# rht-vmctl start desktop
Error: desktop not started (is already running)
[root@foundation42 Desktop]# rht-vmctl view desktop
[root@foundation42 Desktop]# rht-vmctl view desktop    打开虚拟机



共享yum源

在本地yum源配置完成之后安装apache
yum install httpd
systemctl start httpd
systemctl enable httpd
systemctl  stop firewalld
systemctl disable firewalld
mkdir  /ar/www/html/rhel7.0 /var/www/html/rhel7.2
挂在镜像

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/
开机自动挂载
vim /etc/rc.d/rc.local
在vim中
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/
:wq
chmod +x /etc/rc.d/rc.local
reboot
df  看磁盘挂载


3访问测试
在浏览器中输入地址
http://ip/rhel7.0
http://172.25.254.42/rhel7.0
http://172.25.254.42/rhel7.2

4配置虚拟机yum
rm -fr  /etc/yum.repo.d/*
vim /etc/yum.repos.d/yum.repo

[rhel7.0]
name=rhel7.0
baseurl=http://172.25.254.42/rhel7.0
gpgcheck=0





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值