在 CentOS 里“导入配置”这个说法比较宽泛,通常指从备份或其他系统把配置文件恢复进来。下面按常见场景给你一个实用速查表,你可以按需看对应的部分。
# 复制配置文件
cp ifcfg-eth0 /etc/sysconfig/network-scripts/
# 重启网络
systemctl restart network
⚠️ CentOS 8+ 默认不再使用 network-scripts
nmcli connection reload
nmcli connection up eth0
或从备份恢复:
cp eth0.nmconnection /etc/NetworkManager/system-connections/
chmod 600 /etc/NetworkManager/system-connections/eth0.nmconnection
nmcli connection reload
/etc/
/etc/ssh/
/etc/httpd/
/etc/nginx/
/etc/firewalld/
示例:
cp sshd_config /etc/ssh/sshd_config
systemctl restart sshd
/etc/profile
/etc/profile.d/*.sh
~/.bashrc
~/.bash_profile
应用:
source ~/.bashrc
firewall-cmd --reload
iptables-restore < iptables.rules
cp my.cnf /etc/my.cnf
systemctl restart mariadb
mysql -u root -p < backup.sql
rsync -av /backup/etc/ /etc/
rsync -av /backup/root/ /root/
tar -xzvf config-bak.tar.gz -C /
⚠️ 务必确认路径,避免覆盖关键系统文件
docker load < image.tar
docker-compose up -d
systemctl status xxx
ss -lntp
firewall-cmd --list-all
| 问题 | 解决 |
|---|---|
| 服务起不来 | 看 journalctl -xe |
| 权限不对 | chmod / chown |
| SELinux 拦截 | setenforce 0 测试 |
| 配置文件格式错 | nginx -t / sshd -T |
你可以直接告诉我:
我可以给你一步一步的命令。