CentOS Minimal 是一个精简版系统,默认只有最基础的命令行环境,没有 GUI 和多余服务。管理它主要围绕 系统更新、网络、服务、用户、安全、远程管理 等方面。下面按“日常管理 → 进阶管理 → 实用技巧”来说明。
yum update -y
# CentOS 8 以后用
dnf update -y
查看网卡:
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
hostnamectl set-hostname server01
查看:
hostname
timedatectl set-timezone Asia/Shanghai
开启 NTP:
yum install -y chrony
systemctl enable chronyd
systemctl start chronyd
useradd admin
passwd admin
vi /etc/sudoers
添加:
admin ALL=(ALL) ALL
或使用 wheel 组:
usermod -aG wheel admin
修改 SSH 配置:
vi /etc/ssh/sshd_config
推荐设置:
Port 2222
PermitRootLogin no
PasswordAuthentication no
重启 SSH:
systemctl restart sshd
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl enable nginx
systemctl status nginx
top
htop # 需安装
free -h
df -h
systemctl enable firewalld
systemctl start firewalld
开放端口:
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
查看规则:
firewall-cmd --list-all
yum install vim wget curl net-tools -y
yum search nginx
rpm -qa | grep nginx
/var/log/messages
/var/log/secure
/var/log/dmesg
journalctl -xe
journalctl -u sshd -f
✅ 禁止 root 远程登录
✅ 使用 SSH 密钥登录
✅ 启用防火墙
✅ 定期更新系统
✅ 限制 sudo 用户
✅ 关闭无用服务
| 工具 | 用途 |
|---|---|
| SSH | 远程登录 |
| scp / rsync | 文件传输 |
| tmux / screen | 多任务终端 |
| Cockpit | Web 管理(可选) |
安装 Cockpit:
yum install cockpit -y
systemctl enable --now cockpit.socket
访问:
https://IP:9090
yum install net-tools -y
yum install wget curl -y
可以,但不推荐
yum groupinstall "GNOME Desktop" -y
你可以告诉我:
我可以给你 一套定制化的 CentOS Minimal 管理方案。