温馨提示×

怎么管理CentOS Minimal

小樊
35
2026-07-08 02:12:32
栏目: 智能运维

CentOS Minimal 是一个精简版系统,默认只有最基础的命令行环境,没有 GUI 和多余服务。管理它主要围绕 系统更新、网络、服务、用户、安全、远程管理 等方面。下面按“日常管理 → 进阶管理 → 实用技巧”来说明。


一、基础管理(刚装完必做)

1. 更新系统

yum update -y
# CentOS 8 以后用
dnf update -y

2. 配置网络

查看网卡:

ip a

编辑网卡配置(示例):

vi /etc/sysconfig/network-scripts/ifcfg-eth0

常见配置:

BOOTPROTO=dhcp
ONBOOT=yes

或静态 IP:

BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8

重启网络:

systemctl restart NetworkManager

3. 配置主机名

hostnamectl set-hostname server01

查看:

hostname

4. 配置时间 & 时区

timedatectl set-timezone Asia/Shanghai

开启 NTP:

yum install -y chrony
systemctl enable chronyd
systemctl start chronyd

二、用户与权限管理

1. 创建用户

useradd admin
passwd admin

2. 赋予 sudo 权限

vi /etc/sudoers

添加:

admin ALL=(ALL) ALL

或使用 wheel 组:

usermod -aG wheel admin

3. SSH 管理(非常重要)

修改 SSH 配置:

vi /etc/ssh/sshd_config

推荐设置:

Port 2222
PermitRootLogin no
PasswordAuthentication no

重启 SSH:

systemctl restart sshd

三、服务与进程管理(systemd)

1. 管理服务

systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl enable nginx
systemctl status nginx

2. 查看系统资源

top
htop        # 需安装
free -h
df -h

四、防火墙与端口管理

1. firewalld(推荐)

systemctl enable firewalld
systemctl start firewalld

开放端口:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

查看规则:

firewall-cmd --list-all

五、软件包管理

1. 安装软件

yum install vim wget curl net-tools -y

2. 搜索软件

yum search nginx

3. 查看已安装

rpm -qa | grep nginx

六、日志管理

常用日志位置

/var/log/messages
/var/log/secure
/var/log/dmesg

查看实时日志

journalctl -xe
journalctl -u sshd -f

七、安全加固(Minimal 推荐)

✅ 禁止 root 远程登录
✅ 使用 SSH 密钥登录
✅ 启用防火墙
✅ 定期更新系统
✅ 限制 sudo 用户
✅ 关闭无用服务


八、远程管理工具推荐

工具 用途
SSH 远程登录
scp / rsync 文件传输
tmux / screen 多任务终端
Cockpit Web 管理(可选)

安装 Cockpit:

yum install cockpit -y
systemctl enable --now cockpit.socket

访问:

https://IP:9090

九、常见问题

1. 没有 ifconfig?

yum install net-tools -y

2. 没有 wget / curl?

yum install wget curl -y

3. 最小化系统能不能装 GUI?

可以,但不推荐

yum groupinstall "GNOME Desktop" -y

十、我可以进一步帮你

你可以告诉我:

  • ✅ CentOS 7 / 8 / Stream 哪个版本?
  • ✅ 是物理机 / 虚拟机 / 云服务器?
  • ✅ 用作什么(Web / 数据库 / 容器 / 学习)?

我可以给你 一套定制化的 CentOS Minimal 管理方案

0