Linux
How to View Device Information on a Server
· β˜• 2 min read
1. Checking the CPU Check the CPU model 1 lscpu Check the instruction set 1 cat /proc/cpuinfo | grep -iE "flags|instruction set" 2. Checking Memory Memory usage and size 1 free -h Memory module model 1 dmidecode -t memory 3. Checking Disks Check disk mounts 1 lsblk -o NAME,TYPE,SIZE,MODEL,UUID,MOUNTPOINT Check disk usage 1 df -H | grep -vE '^Filesystem|tmpfs|cdrom|loop|udev' | awk '{ print $5 "/" $2 " " $1 }' |grep " "/ Check disk speed 1 hdparm -t /dev/sda3 Check disk temperature and more 1 apt install smartmontools 1 (for disk in /dev/sd?

How to Make a Port Accessible Only to a Specified IP
· β˜• 1 min read
1. Host Service Ports 1 2 iptables -I INPUT -p tcp --dport 80 -j DROP iptables -I INPUT -p tcp -s 1.2.3.4 --dport 80 -j ACCEPT This allows only 1.2.3.4 to access port 80 on the local host. 2. Docker Service Ports For services started like docker run -d -p 80:80 shaowenchen/demo:whoami, the method above does not work; the rule has to be added to the DOCKER-USER chain.

Traffic Restriction Using Linux TC
· β˜• 5 min read
1. Traffic Control Principles Under Linux By queuing packets, we can control how data packets are sent. This kind of control is called data shaping (shape the data), and it includes the following operations on data: Adding latency Dropping packets Reordering Duplicating, corrupting Rate control Under the qdisc-class-filter structure, controlling traffic requires three steps:

Configure Scheduled Tasks with systemd timer
· β˜• 4 min read
1. Preparing the Scheduled Script If it is a Bash script, the first line needs to specify the interpreter. 1 2 mkdir -p /root/scripts vim /root/scripts/quick-clear.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #!/bin/sh /usr/local/bin/kubectl --kubeconfig /root/.kube/config get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs --no-run-if-empty -L1 /usr/local/bin/kubectl --kubeconfig /root/.

Linux Network Traffic Monitoring Terminal Tool - nload
· β˜• 1 min read
nload is a terminal tool for traffic monitoring. It reads the /proc/net/dev file and draws traffic graphs. Below is a brief introduction to using it. 1. Installation CentOS 1 yum install -y nload If your system’s repositories cannot find the nload package, run the following command to add a new