Files
LinuxMirrors/docs/use/command-options.md

158 lines
8.8 KiB
Markdown
Raw Normal View History

2023-05-03 22:50:12 +08:00
| 名称 | 含义 | 选项值 |
| - | - | :-: |
2023-06-20 06:04:56 +08:00
| `--abroad` | 使用海外软件源 | 无 |
| `--edu` | 使用中国大陆教育网软件源 | 无 |
2023-06-24 11:06:30 +08:00
| `--source` | 指定软件源地址(域名或IP) | 地址 |
| `--source-security` | 指定 Debian 的 security 软件源地址(域名或IP) | 地址 |
| `--source-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源地址(域名或IP) | 地址 |
| `--use-official-source` | 使用操作系统官方软件源 | 无 |
| `--branch` | 指定软件源分支(路径) | 分支名 |
2023-06-20 06:04:56 +08:00
| `--branch-security` | 指定 Debian 的 security 软件源分支(路径) | 分支名 |
| `--branch-vault` | 指定 CentOS/AlmaLinux 的 vault 软件源分支(路径) | 分支名 |
2024-01-18 12:15:13 +08:00
| `--codename` | 指定 Debian 系操作系统的版本代号 | 代号名称 |
2024-01-31 22:39:05 +08:00
| `--protocol` | 指定 WEB 协议 | `http``https` |
| `--intranet` | 优先使用内网地址 | `true``false` |
2023-05-03 23:41:43 +08:00
| `--install-epel` | 安装 EPEL 附加软件包 | `true``false` |
| `--only-epel` | 仅更换 EPEL 软件源模式 | 无 |
2023-05-03 23:41:43 +08:00
| `--close-firewall` | 关闭防火墙 | `true``false` |
| `--backup` | 备份原有软件源 | `true``false` |
2023-05-09 20:09:38 +08:00
| `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 |
2024-01-19 02:01:46 +08:00
| `--upgrade-software` | 更新软件包 | `true``false` |
2023-05-03 23:41:43 +08:00
| `--clean-cache` | 清理下载缓存 | `true``false` |
| `--print-diff` | 打印源文件修改前后差异 | `true``false` |
2023-05-04 00:31:04 +08:00
| `--help` | 查看帮助菜单 | 无 |
2023-05-03 22:50:12 +08:00
2023-06-24 11:06:30 +08:00
> 软件源格式 `<指定WEB协议>://<软件源地址>/<软件源分支>`
2023-05-03 22:50:12 +08:00
## 示例
### 指定软件源地址
若不想通过交互选择默认提供的软件源,你可以使用该命令选项指定软件源地址
``` { .bash .no-copy }
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source mirror.example.com
2023-05-03 22:50:12 +08:00
```
### 指定软件源分支
2024-01-17 17:14:51 +08:00
使用场景:目标镜像站有对应的系统镜像但是不符合本项目脚本关于软件源分支设置的默认规则
2023-05-03 22:50:12 +08:00
2024-01-17 17:14:51 +08:00
项目脚本为了适配大的环境不会针对某一镜像站独特的镜像分支名称而单独适配,默认使用的分支名称如下
2023-05-03 22:50:12 +08:00
<div class="annotate" markdown>
2024-06-07 04:17:31 +08:00
| 系统名称 | 涉及的分支名称 |
| --- | :---: |
| <a href="https://www.debian.org" target="_blank"><img src="/assets/images/icon/debian.svg" width="16" height="16" style="vertical-align: -0.45em"></a> Debian | debian |
| <a href="https://cn.ubuntu.com" target="_blank"><img src="/assets/images/icon/ubuntu.svg" width="16" height="16" style="vertical-align: -0.15em"></a> Ubuntu | ubuntu / ubuntu-ports |
| <a href="https://www.kali.org" target="_blank"><img src="/assets/images/icon/kali-linux.svg" width="16" height="16"></a> Kali Linux | kali |
| <a href="https://www.deepin.org" target="_blank"><img src="/assets/images/icon/deepin.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Deepin | deepin |
| <a href="https://www.armbian.com" target="_blank"><img src="/assets/images/icon/armbian.png" width="16" height="16" style="vertical-align: -0.2em"></a> Armbian | armbian |
2024-02-27 06:49:36 +08:00
| <a href="https://www.proxmox.com" target="_blank"><img src="/assets/images/icon/proxmox.svg" width="16" height="16" style="vertical-align: -0.2em"></a> Proxmox | proxmox |
| <a href="https://access.redhat.com/products/red-hat-enterprise-linux" target="_blank"><img src="/assets/images/icon/redhat.svg" width="16" height="16" style="vertical-align: -0.1em"></a> Red Hat Enterprise Linux :material-information-outline:{ title="9版本使用 <code>Rocky Linux</code> 7、8版本使用<code>CentOS</code>" } | centos / centos-altarch / rocky |
| <a href="https://fedoraproject.org/zh-Hans" target="_blank"><img src="/assets/images/icon/fedora.ico" width="16" height="16" style="vertical-align: -0.2em"></a> Fedora | fedora |
| <a href="https://www.centos.org" target="_blank"><img src="/assets/images/icon/centos.svg" width="16" height="16" style="vertical-align: -0.2em"></a> CentOS | centos / centos-stream / centos-altarch / centos-vault |
| <a href="https://rockylinux.org/zh_CN" target="_blank"><img src="/assets/images/icon/rocky-linux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> Rocky Linux | rocky |
| <a href="https://almalinux.org/zh-hans" target="_blank"><img src="/assets/images/icon/almalinux.svg" width="16" height="16" style="vertical-align: -0.25em"></a> AlmaLinux | almalinux / almalinux-vault |
| <a href="https://www.opencloudos.org" target="_blank"><img src="/assets/images/icon/opencloudos.png" width="16" height="16" style="vertical-align: -0.25em"></a> OpenCloudOS | opencloudos |
| <a href="https://www.openeuler.org/zh" target="_blank"><img src="/assets/images/icon/openeuler.ico" width="16" height="16" style="vertical-align: -0.2em"></a> openEuler | openeuler |
| <a href="https://www.opensuse.org" target="_blank"><img src="/assets/images/icon/opensuse.svg" width="16" height="16"></a> openSUSE | opensuse |
| <a href="https://archlinux.org" target="_blank"><img src="/assets/images/icon/arch-linux.ico" width="16" height="16" style="vertical-align: -0.15em"></a> Arch Linux | archlinux / archlinuxarm |
| <a href="https://www.alpinelinux.org" target="_blank"><img src="/assets/images/icon/alpine.png" width="16" height="16" style="vertical-align: -0.15em"></a> Alpine Linux | alpine |
</div>
2023-05-03 22:50:12 +08:00
请看下面的例子
2024-06-07 04:17:31 +08:00
``` { .bash title="使用阿里云的 Rocky Linux 软件源" }
2023-05-06 16:44:27 +08:00
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
2023-05-03 22:50:12 +08:00
--source mirrors.aliyun.com \
--branch rockylinux
```
2023-06-24 11:06:30 +08:00
阿里云镜像站的 Rocky Linux 镜像分支名称为 [`rockylinux`](https://mirrors.aliyun.com/rockylinux),不符合默认规则,但是可以通过命令选项绕过脚本默认规则来实现。
2023-07-03 19:56:26 +08:00
什么是默认规则?参考这几个例子: `Debian GNU/Linux => debian``Rocky Linux => rocky``AlmaLinux => almalinux`
2023-05-03 22:50:12 +08:00
### 单独更换 EPEL 源
2024-06-07 04:17:31 +08:00
!!! info "EPEL (Extra Packages for Enterprise Linux) 是由 Fedora 组织维护的一个附加软件包仓库,它主要适用于除 Fedora 操作系统以外的红帽系 Linux 发行版,配置 EPEL 仓库已成为广大用户的普遍需求,建议默认安装它"
有些时候你会发现想使用的镜像站没有 epel 镜像仓库,那么你可以在第一次运行脚本时不安装或更换 epel 源然后再单独执行下面的命令
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --only-epel
```
2024-01-17 17:14:51 +08:00
### 恢复使用官方源
当你不小心删除了官方源的备份时可以使用此命令来恢复,使用此命令选项后将跳过选择软件源步骤
``` bash
2023-10-14 06:17:24 +08:00
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --use-official-source
```
2024-06-07 04:17:31 +08:00
> 部分系统不存在官方源例如 `Arch Linux`,届时会自动更换成兼容性较高的阿里云镜像站
### 自定义 Debian Security 源
2023-05-09 20:09:38 +08:00
如果你想尽可能提高服务器的安全性则建议使用官方源,因为镜像同步存在延迟
2023-05-09 20:09:38 +08:00
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source-security security.debian.org \
--branch-security debian-security
```
2024-06-07 04:17:31 +08:00
### 指定 Debian 系 Linux 操作系统的版本代号
2023-06-20 06:04:56 +08:00
2024-02-27 06:49:36 +08:00
大多数情况下自定义版本代号用于更换系统版本,请看下面的例子
2023-06-20 06:04:56 +08:00
2024-06-07 04:17:31 +08:00
=== "升级 Debian 至最新 12 版本 Bookworm"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--codename bookworm
```
=== "将 Debian 版本切换到测试分支"
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--codename testing
```
2024-02-27 06:49:36 +08:00
更换软件源后还需要执行系统更新命令 `apt-get dist-upgrade`,并且建议在更新完成并重启系统后重新执行本换源脚本,因为仅更换软件源配置中的系统版本代号可能会在后期使用时产生一些兼容性问题
``` { .bash title="若脚本无法实现指定版本代号,你也可以在执行脚本后手动替换" }
sed -i "s/$(lsb_release -cs)/指定版本代号/g" /etc/apt/sources.list
```
2023-06-20 06:04:56 +08:00
2024-06-07 04:17:31 +08:00
### 更换 Ubuntu EOF版本软件源
!!! info "EOF 为生命周期结束的缩写End Of LifeUbuntu 迭代速度较快一般非长期支持(LTS)版本的生命周期只有9个月。官方会定期从主仓库移除不在生命周期内的版本仓库目录届时可能就需要使用镜像站的 `Ubuntu Old Releases` 分支"
具体版本支持情况详见官方 [Wiki](https://wiki.ubuntu.com/Releases),关于 `Ubuntu Old Releases` 分支的支持情况详见各镜像站
``` bash
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
--source mirrors.ustc.edu.cn \
--branch ubuntu-old-releases
```
2023-05-03 22:50:12 +08:00
## 无人值守
不通过交互完成换源操作,需要使用大量命令选项来实现,建议熟悉后再使用
``` { .bash .no-copy title="参考命令" }
2023-05-06 16:44:27 +08:00
bash <(curl -sSL https://linuxmirrors.cn/main.sh) \
2023-05-03 23:41:43 +08:00
--source mirror.example.com \
2024-01-31 22:39:05 +08:00
--protocol http \
2023-05-03 22:50:12 +08:00
--intranet false \
--install-epel true \
--close-firewall true \
--backup true \
2024-01-19 02:01:46 +08:00
--upgrade-software false \
2023-05-03 22:50:12 +08:00
--clean-cache false \
--ignore-backup-tips
```