[内容] Linux 官方软件源链接列表 (CentOS Linux 版)

内容一:CentOS 7 基础软件源列表

1.1 CentOS 7 基础软件源官方推荐链接列表

1.1.1 CentOS-7 – Base

http://mirror.centos.org/centos/7/os/x86_64/

1.1.2 CentOS-7 – Updates

http://mirror.centos.org/centos/7/updates/x86_64/

1.1.3 CentOS-7 – Extras

http://mirror.centos.org/centos/7/extras/x86_64/

1.1.4 CentOS-7 – Plus

http://mirror.centos.org/centos/7/centosplus/x86_64/

1.2 CentOS 7 基础软件源官方推荐链接列表

1.2.1 CentOS-7 – Base

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=$infra

1.2.2 CentOS-7 – Updates

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=$infra

1.2.3 CentOS-7 – Extras

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=$infra

1.2.4 CentOS-7 – Plus

http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=centosplus&infra=$infra

内容二:CentOS 8 基础软件源列表

2.1 CentOS 8 基础软件源官方链接列表

2.1.1 CentOS Linux 8 – BaseOS

http://mirror.centos.org/centos/8/BaseOS/x86_64/os/

2.1.2 CentOS-8 – Updates

http://mirror.centos.org/centos/8/AppStream/x86_64/os/

2.2 CentOS 8 基础软件源官方推荐链接列表

2.2.1 CentOS Linux 8 – BaseOS

http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=BaseOS&infra=$infra

2.2.2 CentOS Linux 8 – AppStream

http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=$infra

[工具] Shell 批量设置官方软件源 (openSUSE Leap 15.2 版)

介绍

基本信息

作者:朱明宇
名称:批量设置官方软件源(openSUSE 版)
作用:批量设置官方软件源(openSUSE 版)

使用方法

1. 服务器清单 $add_repo_servers_list.txt 每个服务器名占用 1 行,并和此脚本放在同一目录下
2. 在此脚本的分割线内写入相应的内容
3. 给此脚本添加执行权限
4. 执行此脚本

脚本分割线里的变量

add_repo_servers_list.txt #指定存放要设置官方软件源的文件

注意

1. 此脚本执行前必须要先保证执行此脚本的用户能无密码 ssh 远程这些远程服务器
2. 服务器的系统需要是 openSUSE 15.2 版本
3. 服务器系统要配置好可用的软件源(最好是软件数量最多的官方版本)
4. 这些远程服务器要能够连接外网

脚本

#!/bin/bash

####################### Separator ########################

add_repo_servers_list.txt

####################### Separator ########################

cat add_repo_servers_list.txt
read -p "will add opensuse_leap_15.2 repo please input y " a
echo $a

if [ "$a" != "y" ];then
        echo "you don't agree so exit now"
        exit
fi

for i in `awk '{print $1}' add_repo_servers_list.txt`
do
        ssh $i '
        sudo -u root su - root -c "zypper mr -da"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/distribution/leap/15.2/repo/oss/ OpenSUSE_Leap_152_x64_update-oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/distribution/leap/15.2/repo/non-oss/ OpenSUSE_Leap_152_x64_update-non-oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/update/leap/15.2/oss/ OpenSUSE_Leap_152_x64_oss"
        sudo -u root su - root -c "zypper ar -fcg http://download.opensuse.org/update/leap/15.2/non-oss/ OpenSUSE_Leap_152_x64_non-oss"
        sudo -u root su - root -c "zypper ref"
done

[步骤] 软件源的设置 (openSUSE 版) (本地镜像版)

步骤一:加载本地镜像到系统光驱

(步骤略)

步骤二:挂载本地镜像

# mount /dev/cdrom /mnt

(补充:这里以挂载 /dev/sr1 到 /mnt 目录为例)

步骤三:添加本地镜像里的软件源

# zypper ar file:///mnt/Module-Basesystem openSUSE15-Base

或者:

# zypper ar -f /mnt/Module-Basesystem openSUSE15-Base

(补充:这里以将 /mnt/Module-Basesystem 添加到软件源并命名为 openSUSE15-Base 为例)

[命令] Linux 命令 dnf (管理软件)

内容一: 帮助文档相关

1.1 显示 dnf 帮助信息

# dnf help

1.2 显示 dnf 子选项的帮助信息

# dnf help <option>

或者:

# dnf <option> help

内容二:软件相关

2.1 安装软件

2.1.1 交互式
# dnf install <software>
2.1.2 非交互式
# dnf -y install <software>

或者:

# dnf install <software> -y

2.2 删除软件

2.2.1 交互式
# dnf remove <software>
2.2.2 非交互式
# dnf -y remove <software>

或者:

# dnf remove <software> -y

2.3 升级软件

2.3.1 升级软件
2.3.1.1 交互式
# dnf update <software>
2.3.1.2 非交互式
# dnf -y update <software>

或者:

# dnf update <software> -y
2.3.2 升级所有软件
2.3.2.1 升级所有软件
2.3.2.1.1 交互式
# dnf update
2.3.2.1.2 非交互式
# dnf -y update

或者:

# dnf update -y
2.3.2.2 升级除某软件外的所有软件
2.3.2.2.1 交互式
# dnf update --exclude=<software>
2.3.2.2.2 非交互式
# dnf -y update --exclude=<software>

或者:

# dnf update --exclude=<software> -y
2.3.2.3 显示所有可以升级的软件
# dnf check-update

2.4 显示软件

2.4.1 显示软件
2.4.1.1 显示软件
# dnf list all | grep <software>
2.4.1.2 显示软件详细信息
# dnf info | grep <software>
2.4.2 显示所有软件
# dnf list all

内容三:软件组相关

3.1 安装软件组

3.1.1 交互式
# dnf groupinstall <group>
3.1.2 非交互式
# dnf -y groupinstall <group>

或者:

# dnf groupinstall <group> -y

3.2 删除软件组

3.2.1 交互式
# dnf groupremove <group>
3.2.2 非交互式
# dnf -y groupremove <group>

或者:

# dnf groupremove <group> -y

3.3 显示所有可用软件组

# dnf group list

内容四:安全相关

4.1 Errata

4.1.1 Errata
4.1.1.1 安装 Errata
4.1.1.1.1 交互式
# dnf update --advisory=<errata>
4.1.1.1.2 非交互式
# dnf -y update --advisory=<errata>

或者:

# dnf update --advisory=<errata> -y
4.1.1.2 显示 Errata 的详细信息
# dnf updateinfo <errata>
4.1.2 所有 Errata
4.1.2.1 安装所有 Errata
4.1.2.1.1 交互式
# dnf update-minimal --security
4.1.2.1.2 非交互式
# dnf -y update-minimal --security

或者:

# dnf update-minimal --security -y
4.1.2.2 显示所有 Errata 和相关软件版本
# dnf updateinfo list
4.1.2.3 显示所有 Errata 和相关的 CVE
# dnf updateinfo info security

4.2 CVE

4.2.1 CVE
4.2.1.1 安装 CVE
4.2.1.1.1 交互式
# dnf update --cve <CVE>
4.2.1.1.2 非交互式
# dnf -y update --cve <CVE>

或者:

# dnf update --cve <CVE> -y
4.2.2 所有 CVE
4.2.2.1 显示所有 CVE 和相关软件版本
# dnf updateinfo list cves
4.2.2.2 显示所有 CVE 和相关的 Errata
# dnf updateinfo info security

4.2 安全补丁

4.2.1 安全补丁
4.2.1.1 安装安全补丁
4.2.1.1.1 交互式
# dnf update <security patch>
4.2.1.1.2 非交互式
# dnf -y update <security patch>

或者:

# dnf update <security patch> -y
4.2.2 所有安全补丁
4.2.2.1 安装所有安全补丁
4.2.2.1.1 交互式
# dnf update --security
4.2.2.1.2 非交互式
# dnf -y update --security

或者:

# dnf update --security -y
4.2.2.2 显示所有安全补丁
# dnf check-update --security

内容五:软件源相关

5.1 显示所有软件源

# dnf repolist

5.2 缓存软件源列表

5.2.1 缓存所有已启用软件源列表
# dnf repolist
5.2.2 清除所有软件源列表缓存
# dnf clean all
5.2.3 保存所有软件源列表缓存
# dnf makecache

内容六:管理相关

6.1 显示 yum 历史命令

# dnf history

6.2 显示 yum 安装记录

# dnf history info

[步骤] Linux 脚本的管理 (通过 systemd 实现)

步骤一:要被管理的脚本

# vim /root/12456.sh

创建以下内容:

#!/bin/bash
for i in {1..5}
do
echo $i
done

(补充:这里以创建 /etc/root/for.sh 脚本为例)

步骤二:创建 systemctl 的管理文件

# vim /etc/systemd/system/12456.service

创建以下内容:

[Unit]
Description=12345
After=default.target

[Service]
Type=oneshot
ExecStart=/root/12456.sh

[Install]
WantedBy=default.target

(补充:这里以创建 /etc/systemd/system/12456.service 来管理 ExecStart=/root/12456.sh 为例)

步骤三:加载刚刚创建的 systemctl 管理文件

# systemctl daemon-reload

步骤四:给 systemctl 的管理文件添加执行权限

# chmod u+x /etc/systemd/system/12456.service

步骤五:通过 systemd 管理脚本

5.1 启动脚本

# systemctl start 12456.service

5.2 关闭脚本

# systemctl stop 12456.service

5.3 重启脚本

# systemctl restart 12456.service

5.4 让脚本开机自启

# systemctl enable 12456.service