RedHat
-
Identifying the Process on an Open Port
There are several ways to find the process on an open port. As an example, let’s find out which process is running on port 5000. The first attempt could be to use `grep` on the port with ps -ef. This approach is only successful if a process receives the port as an argument. This is only the case in a few instances. LSOF The lsof command with the -i option followed by :<PORT> displays the processes that are keeping this port open. 💡If you are not the technical user under which the process is running, you will not see any output. Using sudo or as the user who owns the…
-
Welcher Prozess belegt wieviel Swap?
Wenn die Kommandos (in den Linux Varianten Debian, Ubuntu, RedHat und ähnlich) free cat /proc/swaps swapon -s eine hohe Auslastung des Swap Spaces anzeigen, kommt die Frage nach dem Verbraucher des Swap hoch. Folgendes Miniskript gibt die Liste der Prozesse nach Größe des belegten Swap an. Mit der Variable THRESHOLD kann man die Liste auf die Verbraucher eingrenzen, die mehr als diesen Wert in kB an Swap belegen. THRESHOLD=5000 for pid in `ls /proc`; do vmswap=`awk '/VmSwa/{print $2}' /proc/${pid}/status 2>/dev/null`; if [ ${vmswap} -gt ${THRESHOLD} ];then pName=`ps -ef|awk '$2=="'"${pid}"'" {print $8}'`; echo "PID ${pid}: ${vmswap} kB (${pName})"; fi; done 2>/dev/null|sort -un -k3 Die Ausgabe sieht wie folgt aus: PID 123857:…