TL;dr

Bash Snippets

1
2
3
4
5
# quietly add a user without password
adduser --quiet --disabled-password --shell /bin/bash --home /home/newuser --gecos "User" newuser
# set password
echo "newuser:newpassword" | chpasswd
nc -w 1 qq.com 80 < /dev/null && echo "tcp port ok"
1
2
3
4
5
[ -f /etc/passwd ] && ( echo "1" ) || :
sudo pipinstall ngxtop
sudo yum install -y libpcap libpcap-devel
sudo yum install -y epel-release
sudo yum install -y nethogs nload
1
2
3
4
5
/usr/bin/ncat --listen -4 -vvv --keep-open --wait 50 --sh-exec "cat -n | tee -a ./out.txt" 8080
/usr/bin/ncat --listen -4 --verbose --keep-open --wait 50 --sh-exec "cat -n | tee -a ./out.txt" 9090

/usr/bin/nping -4 --verbose -c 1 -p 9090 localhost

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
python3 -c "import socket;print([(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])"

ip a |grep <ip> |awk '{print $NF}'
ip r |grep <ip> |cut -d " " -f 3

systemd-cgls --no-pager


sysctl -a --ignore |& grep ipv4.ip_forward
sysctl -a --ignore 2>&1 | grep ipv4.ip_forward
sysctl -a --ignore 2>/dev/null | grep rp_filter
sysctl -a --ignore 2>&1 | grep ipv4.ip_

ref