debug/

netcat example

Listen on specified port:

nc -l -v -k 8888

Connect via netcat:

nc -v google.com 80
| 29 Mar 2021

Extract and count IP addresses from logs

journalctl -n 1000 | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sort | uniq -c
| 29 Mar 2021

Record all traffic on specific port

Create TCP dump of all traffic on localhost on port 8888

sudo tcpdump -i lo "port 8888" -w dump
| 15 Feb 2021

List files installed by a package

To list all files installed by dnf package:

rpm -ql dnf
| 29 Jan 2021

Monitor thread count

watch -n 0.5 "ps -eLf | grep traffic_server | wc -l"
| 15 Jan 2021

Log denied connections in firewalld

Edit file /etc/sysconfig/firewalld:

FIREWALLD_ARGS=--debug=10
| 1 Jan 2020

Debug route table

List all routes in system:

route -n

Get route for a specific IP:

ip route get 1.1.1.1
| 1 Jan 2020

Log executed command

14:27 $ (set -x; sleep 1 && sleep 2)
+ sleep 1
+ sleep 2
| 1 Jan 2020

Monitor process with top

One liner to monitor a process with the name /wshub:

top -p "$(pgrep -f /wshub)"
| 1 Jan 2020

Monitor cpu and memory usage of the process

Print every second cpu and memory usage of the process:

watch -n 1 "ps -eo pid,pcpu,pmem,args | kazy -i xnotitle -e kazy"
| 1 Jan 2020