VMware 虚拟机装 Linux Centos 7.9 保姆级教程(附资源包)

概述

这篇博客是针对linux合集 1-3篇的笔记

安装 VMware 17.5.1 + centos 7.9

1、下载资源包(虚拟机+镜像)

  • VMware-17.5.1 安装包+秘钥.zip
  • Linux Centos 7.9 镜像

有需要资源包的小伙伴,私聊我获取资料包!

2、centos 7.9 下载地址

1、Centos 官网 www.centos.org/

2、阿里巴巴镜像站 developer.aliyun.com/mirror/

3、查看网络命令 ifconfig 或 ip addr

4、登陆服务器

bash 复制代码
ssh stark@192.168.31.131

初始化后的坑

sudo命令的坑

bash 复制代码
[stark@192 ~]$ sudo yum update -y
[sudo] password for stark: 
stark is not in the sudoers file.  This incident will be reported.

会有错误信息stark is not in the sudoers file. This incident will be reported. ,解决步骤:

1、切换到 root 用户 输入 之前的初始化密码用户的密码之后就能登录。

bash 复制代码
su -

2、把用户添加到 wheel 组

CentOS 系统中,wheel 组的用户默认拥有 sudo 权限。你可以使用以下命令将用户stark添加到 wheel 组:

bash 复制代码
usermod -aG wheel stark

3、确认 wheel 组是否有 sudo 权限

要保证/etc/sudoers文件里有如下配置行(如果被注释掉了,就取消注释):

bash 复制代码
%wheel  ALL=(ALL)       ALL

4、以现有 sudo 用户身份添加用户到 sudo 组

bash 复制代码
sudo usermod -aG wheel stark

yum源的坑

1、临时修改DNS服务器

编辑/etc/resolv.conf文件,添加公共 DNS 服务器:

bash 复制代码
echo -e "nameserver 8.8.8.8\nnameserver 114.114.114.114" > /etc/resolv.conf

2、替换 CentOS 官方镜像源为阿里云镜像源

bash 复制代码
# 备份原镜像源配置
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

# 下载阿里云镜像源配置
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

# 清理并生成缓存
yum clean all
yum makecache

3、处理 CentOS 7 EOL 后的镜像源问题

bash 复制代码
sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*
sed -i 's|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

4、额外建议

如果仍然遇到问题,可以尝试禁用fastestmirror插件:

bash 复制代码
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf

VMware Tools 设置时间

设置宿主机与虚拟机时间不一致的问题:

1、设置: 虚拟机 -> 设置 -> 选项

2、在虚拟机中安装 VMware Tools

bash 复制代码
#下载
sudo yum install open-vm-tools open-vm-tools-desktop
#启动
sudo systemctl enable --now vmtoolsd
#验证
systemctl status vmtoolsd
#更新时间
sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
相关推荐
SFLYQ3 分钟前
隔离内网下 AI Agent 工程实战
后端·agent·ai编程
凤山老林15 分钟前
Spring Boot 集成 Netty 构建高性能 TCP 长连接网关:协议解析、心跳检测与集群广播实战
spring boot·后端·tcp/ip
IT大白鼠16 分钟前
彭大帅的AI运维助手——自然语言管理 Linux 集群与网络设备——第 0 篇 · 导读:把 Linux 运维交给 AI,到底靠谱吗
linux·运维·人工智能
AI智讯中枢37 分钟前
高性能 C++ 实战 (五):perf+FlameGraph 火焰图生产实战,精准定位 CPU / 缓存 / 锁瓶颈,避坑 + 完整实操案例
linux·c++·性能调优·性能分析·perf·flamegraph·火焰图
Json____1 小时前
基于 Spring Boot + Vue3 的在线考试管理系统实战
java·spring boot·后端·it学习·wwwoop.com
Sam_Deep_Thinking1 小时前
如何理解java的信号量
java·后端·面试·程序员
xbzb1 小时前
Linux SELinux 安全加固与标签排错手册
linux·运维·安全
东风破_1 小时前
NestJS 快速入门:先别背装饰器,把一条请求跑明白
后端
晴空蓝天1 小时前
MDC traceId 全链路日志追踪:Spring Boot 3.5 里把日志串成一条线
java·spring boot·后端·python
明月_清风1 小时前
干了 6 年前端,我是怎么一步步转型到 AI 的?
前端·后端·ai编程