麒麟Linux常用命令
#查看内核版本
cat /proc/version
uname -a
#查看发行版本
lsb_release -a
#查看系统版本
cat /etc/os-release
-------------------------------------------
检查端口
netstat -tuln | grep 80
查看哪些进程占用了特定的端口
lsof -i :8080
检查端口占用
ss -tuln | grep 端口号
-------------------------------------------
重启nginx
nginx -s reload
停止nginx
nginx -s stop
检查nginx语法
nginx -t
重启nginx
systemctl restart nginx
-------------------------------------------
检查防火墙规则
sudo firewall-cmd --list-ports
检查防火墙状态
systemctl status firewalld
启动防火墙
systemctl start firewalld
临时关闭防火墙
systemctl stop firewalld
永久关闭防火墙
systemctl disable firewalld
放行80端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=8080/tcp
重新加载防火墙配置
firewall-cmd --reload
查看已添加的规则
firewall-cmd --list-all
部分麒麟系统可能使用 iptables 或 ufw 作为防火墙工具。若上述命令无效,可尝试 sudo systemctl status iptables 检查,并通过 sudo systemctl stop iptables 和 sudo systemctl disable iptables 关闭
-------------------------------------------
查看网卡状态
systemctl status NetworkManager
重启网卡
systemctl restart NetworkManager
service network restart
-------------------------------------------
网卡配置
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
修改配置文件,去掉端口注释,修改端口号
vi /etc/ssh/sshd_config
重启SSH服务
systemctl restart sshd
service ssh restart
-------------------------------------------
查看时间设置
timedatectl status
修改时间
date -s "2026-01-16 11:19:50"
timedatectl set-time "2026-02-03 15:09:46"
将系统时间同步到硬件时钟
hwclock --systohc
将系统时间设置为RTC时间
hwclock --hctosys
-------------------------------------------
移动文件
mv 文件名 目录
mv 文件名 文件名