这里主要是关于 centos7 的总结
查看系统内核版本信息
cat /proc/version
uname -a
查看centos版本,如centos 7.9
cat /etc/redhat-release
查看CPU型号及支持的指令集
gcc -march=native -Q --help=target|grep marchcat /proc/cpuinfocpuid (需安装此命令)增加用户
adduser xx 创建用户passwd xx 按提示设置密码xx ALL=(ALL) ALL ,再改为只读权限删除用户
userdel xx
free -m 查看交换内存情况
通过swap分区文件增加swap空间
dd if=/dev/zero of=swapfile bs=1M count=1024 bs是每个块大小,count是块数量,这里设置共1Gmkswap swapfile 格式化交换分区文件swapon swapfile 启用swapfile swap swap defaults 0 0 注意使用全路径使用文件作为交换内存的好处:
查看磁盘存储空间
df -h
查看某进程的磁盘读写速度(需执行命令 yum install -y pidstat)
pidstat -p ${pid} -d 1
检测磁盘读写速度,一种不太准确的方式
写 dd if=/dev/zero of=test.file bs=1G count=2 oflag=direct
读 dd if=test.file of=/dev/null iflag=direct
在win下查看linux的端口是否打开(需开启telnet服务)
telnet 172.17.15.12 8000
netstat -nlp | grep 8080 查看本机端口
systemctl start firewalld 开启防火墙
firewall-cmd --query-port=666/tcp 查看想开的端口是否已开
firewall-cmd --add-port=666/tcp 开端口号
firewall-cmd --remove-port=666/tcp 移除端口