各大Linux版本修改ip地址

要修改CentOS7虚拟机的IP地址,首先检查当前的IP地址。
例如,已知当前IP地址为10.47.80.251。
接下来,打开网络配置目录,运行命令进入/etc/sysconfig/network-scripts目录。
在此目录中,找到并编辑ifcfg-ens33网络配置文件,将IPADDR字段更改为新分配的IP地址,确保配置正确,保存并退出编辑。
接下来,重新启动网络服务并运行systemctlrestartnetwork等命令以使更改生效。
最后再次检查IP地址,确认修改成功。
您通常可以通过ifconfig或ipaddrshow等命令查看网络接口详细信息,以验证新配置中的IP地址是否已更改。

Linux切换软件源到国内代理加速地址

1.背景

我们经常使用不同的Linux发行版。
很多时候我们都要使用yum和apt来安装软件。
但使用Linux镜像中的软件源,访问速度更慢,如果失败,每次都得上网查找对应的软件源地址。

这样的工作一次又一次地发生。
我想过收集我常用的Linux发行版的软件源替换方法。
当需要时,我可以直接粘贴本文的命令。
出来希望可以帮助到有此类需求的朋友。

2.Centos替换软件源码

目前我主要使用的是centos7和centos8,两个版本的替换步骤基本相同,只是具体命令有些差异,不要搞混了。

2.1Centos7

安装basereop源,然后备份旧的配置文件

sudomv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.bak

改为阿里云

wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo

更新

yumupdate2.2Centos8

备份原软件源文件

mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backupmv/etc/yum.repos.d/CentOS-PowerTools.repo/etc/yum.repos.d/CentOS-PowerTools.repo.backupmv/etc/yum.repos.d/CentOS-Extras.repo.backup/etc/yum.repos.d/CentOS-Extras.repo.backup.backupmv/etc/yum.repos.d/CentOS-centosplus.repo.repo/etc/yum.repos.d/CentOS-centosplus.repo.backupmv/etc/yum。
repos.d/CentOS-AppStream.repo.repo/etc/yum。
repos.d/CentOS-AppStream.repo.backup

以上文件需要重命名,因为阿里云源中的Centos-8.repo包含了以上所有文件如果只是按照以下方式更改CentOS-Base.repo文件传统方法会显示一条消息

正在更新订阅管理存储库。
无法读取消费者身份此系统未在RedHatSubscriptionManagement中注册。
您可以使用订阅管理器进行注册。
RepositoryAppStream在配置库中多次列出RepositoryextrasislistedmorethanonceintheconfigurationRepositoryPowerToolerlistedmorethanonceintheconfigurationRepositorycentosplusislistedmorethanonceintheconfiguration

更改为阿里云

wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-8.repo

运行yummakecache生成缓存

yumcleanallyummakecache3.Ubuntu

Ubuntu软件源地址有很多种。
这些类型必须写入/etc/apt/sources.list文件。
写之前最好先备份一下。

3.1Ubuntu18

备份命令如下

cp/etc/apt/sources.list/etc/apt/sources.list.bak

输入常用的阿里云软件源地址。
文件,命令如下

tee/etc/apt/sources.list<<-'EOF'debhttp://mirrors.aliyun.com/ubuntu/bionicmainrestricteduniversemultiveredeb-srchttp://mirrors.aliyun.com/ubuntu/bionicmainrestricteduniversemultiveredebhttp://mirrors.aliyun.com/ubuntu/bionic-securitymainrestricteduniversemultiversedeb-srchttp://mirrors.aliyun.com/ubuntu/bionic-securitymainrestricteduniversemultiversedebhttp://mirrors.aliyun.com/ubuntu/bionic-updatesmainrestricteduniversemultiversedeb-srchttp://mirrors.aliyun.com/ubuntu/bionic-updatesmainrestricteduniversemultiveredebhttp://mirrors.aliyun.com/ubuntu/bionic-backportsmainrestricteduniversemultiverseeb-srchttp://mirrors.aliyun.com/ubuntu/bionic-backportsmainrestricteduniversemultiveredebhttp://mirrors.aliyun.com/ubuntu/bionic-proposemainrestricteduniversemultiverseeb-srchttp://mirrors.aliyun.com/ubuntu/bionic-proposemainrestricteduniversemultiverseEOF

更多新命令软件源信息如下如下

aptupdate3.2Ubuntu20

备份命令如下

cp/etc/apt/sources.list/etc/apt/sources.list.bak

编写常用阿里云软件源地址到文件,命令如下

wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo1

更新软件源信息的命令如下

aptupdate4、debian必须更改软件源

Debian系统和Ubuntu的替换方法基本相同,只是内容不同,所以不要't混淆内容。

4.1debian10

备份命令如下

cp/etc/apt/sources.list/etc/apt/sources.list.bakwget-O/etc/yum.repos.d/CentOS-基础.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo4

更新软件源信息命令如下Vis

aptupdate4.2debian9

备份命令如下如下

cp/etc/apt/sources.list/etc/apt/sources.list.bakwget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo7

更新软件源信息的命令为如下

aptupdate5.Macos

MacOS系统通常使用brew来安装软件,但是brew的来源也是国外,下载软件总是很慢这里我们可以放一些常用的软件仓库即镜像仓库阿里云

5.1Brew替换软件源码

第一。
全部替换的是啤酒厂本身的仓库地址这里必须进入啤酒厂的git仓库目录。
命令行如下:

wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo&&wget-O/etc/嗯。
repos.d/epel.repohttp://mirrors.aliyun。
no/repo/epel-7.repo9

进入brew的git仓库目录后,需要将外部地址更改为阿里云仓库地址命令如下

yumupdate0

然后需要更换自制程序。
-核心仓库地址,也必须先进入这个仓库的目录。
命令如下

yumupdate1

输入进入homebrew核心仓库后,需要替换外部仓库地址如下

yumupdate3

作者:唐青松

微信:songboy8888

Linux命令下快速修改IP地址linux命令修改ip

随着网络技术的快速发展,Linux操作系统在网络设备技术的发展中占有举足轻重的地位。
Linux还具有强大的命令行管理工具,可以让您快速、轻松地管理您的网络设备。
许多Linux服务器需要定期更改IP地址以满足业务变化的需要,因此了解如何在Linux系统上更改IP地址非常重要。
首先,在Linux系统上,您可以使用ifconfig命令获取服务器及其主机的IP地址。
该命令不仅可以查看某个网络接口的统计信息,还可以查看所有网络接口当前配置的IP地址。

格式为:$sudoifconfig。
默认情况下,该命令显示系统地址和指定网络接口的所有IP地址。
如果需要查看特定主机的IP地址,可以添加网卡接口。
ifconfig之后:$sudoifconfigeth0该命令将显示eth0接口的IP地址等信息。
如果需要更改IP地址,可以使用ifconfig来完成。
格式如下:$sudoifconfigeth0192.168.0.2这次将eth0接口的IP地址更改为192.168.0.2。
同样使用ifconfig来设置子网掩码和网关,其格式如下:$sudoifconfigeth0192.168.0.2netmask255.255.255.0broadcast192.168.0.255gateway192.168.0.1此时eth0接口的IP地址将更改为192.168.0.2和子网掩码将被安装​​为255.255.255.0,网关为192.168.0.1。
除了使用ifconfig命令更改IP地址外,还可以使用ip命令更改IP地址。
格式为:$sudoipaddradd192.168.0.2/24broadcast192.168.0.255deveth0。
将接口eth0的IP地址更改为192.168.0.2,并将网关设置为192.168.0.1。
最后,如果想检查服务器的网络配置,可以使用route命令:$Route-n该命令会检查当前设备的网关以及各个网络接口的路由信息​​。
设置服务器网络。
总之,Linux系统提供了方便的命令行工具来更改和重新配置IP地址,可以快速有效地使网络更加灵活和高效,从而从而提供更安全的网络服务和管理。