shell脚本快速配置yum源
我们在使用Red Hat系列与CentOS系列的 Linux系统 时经常要配置yum源,本文档提出一个快速配置yum源的方法,就是用 shell 脚本 来实现。 首先确保系统已挂载好镜像文件,然后执行vim rhel7.repo.sh 命令 ,这个 命令 是创建一个 脚本 。 在打开的文件中添加以下内 [root@linuxprobe ~]# vim rhel7.repo.sh 1 #!/bin/bash 2 3 cd /etc/yum.repos.d 4 5 cat >>rhel7.repo<<OK 6 [rhel7] 7 name=rhel7 8 baseurl=file:///media/cdrom 9 enabled=1 10 gpgcheck=0 11 OK 12 13 mkdir -p /media/cdrom 14 mount /dev/cdrom /media/cdrom 15 echo "/dev/cdrom /media/cdrom iso9660 defaults 0 0" >> /etc/fstab 16 17 yum clean all 18 yum makecache 写完脚本后记得赋予脚本执行权限: [root@linuxprobe ~]# chmod 755 rhel7.repo.sh 或 [root@linuxprobe ~]# chmod +x