OpenCloudOS Server 8命令?

OpenCloudOS 是一个由腾讯主导并联合多家技术企业共同研发的开源服务器操作系统,属于 Linux 发行版之一。它基于 Linux 内核,适用于云环境、数据中心和企业级服务器部署。

OpenCloudOS Server 8 基于 RHEL 8(Red Hat Enterprise Linux)系,因此其命令和操作方式与 CentOS 8、Rocky Linux 8、AlmaLinux 8 等非常相似。


🧰 常用 OpenCloudOS Server 8 命令汇总

1. 系统信息相关

# 查看操作系统版本
cat /etc/os-release

# 或者:
cat /etc/redhat-release

# 查看内核版本
uname -r

# 查看主机名
hostname

# 查看 IP 地址
ip a
# 或
nmcli device show

# 查看系统运行时间及用户登录情况
uptime
who

2. 软件包管理(dnf/yum)

OpenCloudOS 8 使用 dnf 作为默认包管理器(兼容 yum 命令):

# 更新软件包列表
dnf makecache

# 安装软件包
dnf install package_name

# 卸载软件包
dnf remove package_name

# 升级所有已安装的软件包
dnf upgrade

# 搜索软件包
dnf search keyword

# 查看已安装的软件包
dnf list installed

# 清理缓存
dnf clean all

3. 服务管理(systemd)

使用 systemctl 管理服务:

# 启动服务
systemctl start service_name

# 停止服务
systemctl stop service_name

# 重启服务
systemctl restart service_name

# 查看服务状态
systemctl status service_name

# 设置开机自启
systemctl enable service_name

# 禁止开机自启
systemctl disable service_name

# 列出所有服务
systemctl list-units --type=service

4. 网络配置

使用 nmcli(NetworkManager 命令行工具):

# 查看网络连接
nmcli connection show

# 修改 IP 地址(示例:静态 IP)
nmcli connection modify eth0 ipv4.addresses 192.168.1.100/24
nmcli connection modify eth0 ipv4.gateway 192.168.1.1
nmcli connection modify eth0 ipv4.dns "8.8.8.8"
nmcli connection up eth0

# 更改 DNS
nmcli connection modify eth0 ipv4.dns "8.8.8.8"

编辑网络配置文件(路径):

/etc/sysconfig/network-scripts/ifcfg-<interface_name>

修改后需重启网络服务:

systemctl restart NetworkManager
# 或
nmcli connection reload

5. 防火墙(firewalld)

# 查看防火墙状态
systemctl status firewalld

# 开启防火墙
systemctl start firewalld

# 设置开机启动
systemctl enable firewalld

# 查看当前开放的端口和服务
firewall-cmd --list-all

# 开放端口(如开放 80/tcp)
firewall-cmd --permanent --add-port=80/tcp

# 添加服务(如 http)
firewall-cmd --permanent --add-service=http

# 重新加载防火墙规则
firewall-cmd --reload

6. 用户和权限管理

# 添加用户
useradd username

# 设置密码
passwd username

# 删除用户
userdel username

# 添加 sudo 权限(编辑 sudoers 文件)
visudo

# 创建用户组
groupadd groupname

# 将用户加入某个组
usermod -aG groupname username

7. 日志查看

# 实时查看日志(journal)
journalctl -u service_name.service -f

# 查看历史日志
journalctl --since "1 hour ago"

# 查看常规日志
tail -f /var/log/messages

8. 其他常用命令

# 查看磁盘空间
df -h

# 查看目录大小
du -sh /path/to/dir

# 查看内存使用
free -h

# 查看进程
top
htop   # 可先安装 htop 工具

# 查找文件
find /path/to/search -name filename

# 查看系统时间
timedatectl

# 设置时区
timedatectl set-timezone Asia/Shanghai

✅ 推荐安装常用工具

dnf install -y net-tools vim wget curl git tmux screen

如果你有具体需求或场景(比如安装 Nginx、Docker、设置 SSH 登录等),欢迎继续提问,我可以提供详细步骤!

是否需要我为你提供一份常用的初始化脚本?