learning_notes

学习笔记

View project on GitHub

常用命令

  1. 查看公网IP ```go curl ifconfig.me

curl cip.cc

2. 查看系统启动时间:
```bash
uptime #动态查看 watch -d uptime
#08:51:35 up 4 min,  1 user,  load average: 1.55, 0.66, 0.27
  1. 查看cpu核数 ```bash grep “model name” /proc/cpuinfo | wc -l

lscpu

4. top
```bash
#R Running 运行中
#S Interruptible Sleep 可中断的睡眠状态
#D Disk sleep 不可中断的睡眠状态
#I Idle 空间进程
#Z Zombie 僵尸进程
#T(t) Stop or Trace 终止或者跟踪状态
#X Dead 消亡进程
#s 会话领导
#+ 前台进程组

  1. ifconfig ```bash lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 1697 bytes 14471237 (13.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1697 bytes 14471237 (13.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 #errors :发生错误的数据包,校验错误,帧同步错误 #dropped :丢弃的数据包,已经收到ring buffer中,内存不足等原因,丢弃 #overruns:超限数据包,网络i/o过快,导致ring buffer来不及处理,丢弃 #carrier:双工模式不匹配,物理电缆等出现问题 #collisions:碰撞数据包数量
6. netstat和ss
```bash
netstat -tunlp 
#Recv-Q Send-Q表示接收和发送队列,不为0说明消息有积压
  1. iperf3 ```bash yum install iperf3 #带宽测试工具

-s 表示启动服务端,-i 表示汇报间隔,-p 表示监听端口

$ iperf3 -s -i 1 -p 10000 #服务端

-c 表示启动客户端,192.168.0.30 为目标服务器的 IP

-b 表示目标带宽 (单位是 bits/s)

-t 表示测试时间

-P 表示并发数,-p 表示目标服务器监听端口

$ iperf3 -c 192.168.0.30 -b 1G -t 15 -P 2 -p 10000 #客户端


8. dig
```bash
nslookup www.baidu.com
#域名解析跟踪
# +trace 表示开启跟踪查询
# +nodnssec 表示禁止 DNS 安全扩展
$ dig +trace +nodnssec www.baidu.com

  1. centos防火墙配置

centos防火墙配置

  1. 统计tcp状态

```shell script netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’


11. 查看打开文件句柄数排名

```shell script
lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more
  1. 设置用户守护进程打开文件句柄数

shell script vim /etc/systemd/user.conf vim /etc/systemd/system.conf DefaultLimitNOFILE=100000 DefaultLimitNPROC=65535