Find process running on port 9981
sudo netstat -ltnp | grep -w ':9981' NOTE: to run the above you do need net-tools installed you can use sudo apt-get install net-tools to install

Count all the files recursively find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done Reference https://unix.stackexchange.com/questions/4105/how-do-i-count-all-the-files-recursively-through-directories