iso="/mnt/iso" if [! -e "$iso"]; then mkdir$iso fi mount /dev/cdrom /mnt/iso; dvd="/etc/yum.repos.d/dvd.repo" if [-e "$dvd"]; then rm$dvd else touch$dvd fi cat <<EOF>> "$dvd"; [dvd] name=dvd baseurl=file:///mnt/cd0 gpgcheck=0 enabled=1 priority=1 EOF
yum -y install yum-priorities; path="/etc/yum.repos.d/CentOS-Base.repo" if grep -q "priority=2""$path"; then echo"已包含" else sed -i '/7/a\priority=2'"$path"; fi path="/etc/yum.repos.d/epel.repo" if grep -q "priority=11""$path"; then echo"已包含" else sed -i '11i\priority=11'"$path"; fi yum clean all && yum makecache; yum install httpd -y; yum repolist;
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
使用 sudo yum update 更新
Ubuntu 20.04:
使用 vi 打开 /etc/apt/sources.list
输入软件源:
1 2 3 4 5
# 默认注释了源码仓库,如有需要可自行取消注释 deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
CREATE USER 'root'@'%' IDENTIFIED BY '123456'; # 创建一个用户为 root 并且密码设置为 123456 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; # 授予 root 用户远程访问权限 FLUSH PRIVILEGES; # 刷新配置