开发测试

Linux常用命令大全(持续维护)

  • 目录操作

查看目录(文件夹)大小

du -h --max-depth=1
  • 防火墙操作

查看防火墙的状态

systemctl status firewalld

开启防火墙

systemctl start firewalld

关闭防火墙

systemctl stop firewalld

查看已开放的端口

firewall-cmd --list-ports

开启80的端口号

firewall-cmd --zone=public --add-port=80/tcp --permanent

关闭80的端口号

firewall-cmd --permanent --zone=public --remove-port=80/tcp

重新加载配置

firewall-cmd --reload
  • 查看CPU信息

查看物理CPU个数

cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每个物理CPU中core的个数(即核数)

cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看逻辑CPU的个数

cat /proc/cpuinfo| grep "processor"| wc -l

# 查看CPU信息(型号)

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
  • 端口操作

#查看端口监听

netstat -atunlp
  • 路由操作

route del -net 192.168.3.0 netmask 255.255.255.0 dev eth1

加入永久路由

echo “route add -net 9.123.0.0 netmask 255.255.0.0 gw 9.123.0.1” >> /etc/rc.local

实际中发现,CentOS7.4默认环境下,rc.local中不会执行,需要赋权才可以

chmod +x /etc/rc.local


定时同步时间


0 23 * * * ntpdate asia.pool.ntp.org >> /var/log/ntpdate.log

标签: Linux命令

作者:lzcz 分类:经验分享 浏览:2440 评论:0