How many file descriptors opened by my java application?

# Get hte java process ID
ps -ef | grep java
# Count filedescriptors opened by this java process
cd /proc/<java_PID>/fd
ls -l | wc -l
# And if you want to verify what your java application has opened, just inside the same directory
ls -l
# if you want to see more details about filedescriptors opened
lsof -a -p <java_PID>

All the threads binded to a process

top -n 1 -H -p <PID>

Process listening on a port

Beware that apache ssl virtualhost *:443 with lsof or netstat will appear as a name *:https not *:443

lsof -i | grep 8009
lsof -i | grep https
netstat -pao |grep 8009
netstat -pao |grep https

Debug shell script: Use -x option to run the shell interpreter to facilitate your debugging session

It can be useful for debuging:

#!/bin/bash -x
#
# myscript.sh

echo "hello world"
i=0
((i++))
echo "i = $i"
$> ./test.sh
+ echo 'hello world'
hello world
+ i=0
+ (( i++ ))
+ echo 'i = 1'
i = 1