CentOS Stream 9 常用操作

文章详细介绍了如何在Linux系统中配置静态IP,包括编辑网卡配置文件、设置IP地址、掩码、网关及DNS,然后通过命令重载配置。此外,还讲解了如何切换到中科大的CentOS镜像源,以提高软件包下载速度,涉及备份原有源配置、修改repo文件并更新yum缓存。

DOC

1、配置静态 IP

1)打开网卡配置文件:
/etc/NetworkManager/system-connections/ens33.nmconnection

[connection]
id=ens33
uuid=7b014901-bd03-37c5-b71d-f9b2a0c19bfc
type=ethernet
autoconnect-priority=-999
interface-name=ens33
timestamp=1675598341

[ethernet]

[ipv4]
#method=auto
# 修改为手动配置
method=manual
# 设置 IP地址、掩码、网关
address=192.168.xxx.xxx/24,192.168.xxx.xxx
# 配置 DNS
dns=223.5.5.5;223.6.6.6


[ipv6]
addr-gen-mode=eui64
method=auto

[proxy]

2)重载配置

$ sudo nmcli c reload
$ sudo nmcli c up ens33
root@localhost ~]# nmcli c -h
Usage: nmcli connection { COMMAND | help }

COMMAND := { show | up | down | add | modify | clone | edit | delete | monitor | reload | load | import | export }

  show [--active] [--order <order spec>]
  show [--active] [id | uuid | path | apath] <ID> ...

  up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>] [passwd-file <file with passwords>]

  down [id | uuid | path | apath] <ID> ...

  add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+]

  modify [--temporary] [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+

  clone [--temporary] [id | uuid | path ] <ID> <new name>

  edit [id | uuid | path] <ID>
  edit [type <new_con_type>] [con-name <new_con_name>]

  delete [id | uuid | path] <ID>

  monitor [id | uuid | path] <ID> ...

  reload

  load <filename> [ <filename>... ]

  import [--temporary] type <type> file <file to import>

  export [id | uuid | path] <ID> [<output file>]

2、配置国内镜像源

1)yum配置文件路径
/etc/yum.repos.d/centos.repo

2) 备份源配置
cp /etc/yum.repos.d/centos.repo /etc/yum.repos.d/centos.repo.bak

3) 配置
中科大源

[baseos]
name=CentOS Stream $releasever - BaseOS
#metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/BaseOS/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[baseos-debuginfo]
name=CentOS Stream $releasever - BaseOS - Debug
#metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/BaseOS/x86_64/debug/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

[baseos-source]
name=CentOS Stream $releasever - BaseOS - Source
#metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/BaseOS/source/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

[appstream]
name=CentOS Stream $releasever - AppStream
#metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/AppStream/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1

[appstream-debuginfo]
name=CentOS Stream $releasever - AppStream - Debug
#metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/AppStream/x86_64/debug/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

[appstream-source]
name=CentOS Stream $releasever - AppStream - Source
#metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/AppStream/source/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

[crb]
name=CentOS Stream $releasever - CRB
#metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/CRB/x86_64/os/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=0

[crb-debuginfo]
name=CentOS Stream $releasever - CRB - Debug
#metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/CRB/x86_64/debug/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

[crb-source]
name=CentOS Stream $releasever - CRB - Source
#metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=source&protocol=https,http
# 配置为中科大源
baseurl=https://mirrors.ustc.edu.cn/centos-stream/9-stream/CRB/source/tree/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
enabled=0

4)更新缓存
yum makecache && yum update

CentOS Stream是一个持续提供最新软件和技术的滚动更新版本的CentOS项目。它基于RHEL源代码,并专注于最新的开源创新。以下是安装CentOS Stream 9的基本步骤: **1. 下载镜像:** 首先,你需要从CentOS官网下载CentOS Stream 9的ISO镜像文件。访问 https://www.centos.org/download/#stream9 ,选择适合你的架构(如x86_64)并下载。 **2. 准备启动U盘或DVD:** 使用像`dd`命令(对于Linux)或第三方工具(如 Rufus for Windows)将下载的ISO刻录到启动介质上。 **3. 设置BIOS/UEFI:** 进入计算机BIOS设置,确保你的系统可以从USB/DVD启动。 **4. 启动安装:** 重启电脑,然后按照引导屏幕提示选择语言和安装类型,通常是图形化界面。 **5. 安装过程:** - 按照向导完成硬件检测、分区、网络设置等步骤。 - 选择“自定义安装”,指定根分区以及是否需要额外的空间用于交换分区或LVM。 - 配置时区、用户名和密码。 - 选择安装类型,可以选择最小安装只包含基础组件,或者完整安装包含所有常用软件包。 **6. 软件源配置:** 安装过程中会询问你是否要添加默认的CentOS Stream存储库。如果之前从未使用过CentOS Stream,应该选择“是”。 - 如果有特定的软件包依赖,你可能需要手动添加其他仓库。 **7. 开始安装:** 最后确认所有的设置无误,开始安装过程。安装完成后,系统会自动重启。 **相关问题--:** 1. CentOS Stream与正式版CentOS的区别是什么? 2. 安装完成后如何验证CentOS Stream 9已经成功启用? 3. 我可以在CentOS Stream上运行哪些非官方软件包?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值