主机常用命令

linux常用命令(粗略记录,不同版本自行区别)

磁盘相关:

查看磁盘使用情况  
查看当前目录的文件大小 du -h --max-depth=1
查看文件同时看文件大小 ls -lh
查看内存占用 cat /proc/{pid}/status

系统信息查询:

查看CPU个数 cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
查看CPU核数 cat /proc/cpuinfo | grep 'process' | sort | uniq | wc -l
查看内存 cat /proc/meminfo
查看进程的内存占用  cat /proc/{pid}/status

防火墙相关:

查看防火墙某个端口是否开放
firewall-cmd --query-port=3306/tcp

查看防火墙状态
systemctl status firewalld
关闭防火墙
systemctl stop firewalld
打开防火墙
systemctl start firewalld
重启防火墙
firewall-cmd --reload

开放防火墙端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
关闭某个端口
方式一:firewall-cmd --zone= public --remove-port=5005/tcp --permanent
方式二:firewall-cmd --remove-port=3000/tcp --permanent

开放一段端口
firewall-cmd --zone=public --add-port=40000-45000/tcp --permanent
关闭一段连续的多个端口
firewall-cmd --zone= public --remove-port=1000-2000/tcp --permanent

查看开放的端口列表
firewall-cmd --zone=public --list-ports

端口占用查询:

netstat -anp |grep 端口号
netstat -nultp 查看已使用端口情况

grep语法使用:
grep -C 5 foo file 显示file文件里匹配foo字串那行以及上下5行
grep -B 5 foo file 显示foo及前5行
grep -A 5 foo file 显示foo及后5行

Windows

查看进程命令:tasklist
杀死进程命令:tskill  进程名 (比如杀死nginx进程:tskill  nginx)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值