How do you monitor memory usage of java threads.

It helps you track the internal memory usage running java processes

Use opensource jvmtop – https://github.com/patric-r/jvmtop

Installation is simple




tar -xvz jvmtop-0.8.0.tar.gz

set JAVA_HOME in the script – tip: Look for tools.jar in the lib folder

export JAVA_HOME=/home/admin/java/jdk1.6.0_31/


sh jvmtop.sh





Disk usage of mysql DB

To calculate the disk usage of your DBs in mysql


you can use “DU” which is less reliable and if you hosting on cloud database services, you cannot use this.

du -sh /var/lib/mysql/database


use the below query.


select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;

Port forwarding using ssh


How to use port forwarding when you are behind a firewall.

to access a service running locally on the remote server.

To setup a proxy

ssh -L 3128:localhost:80 <username>@YOURREMOTESERVER

REMOTE Port forwarding

Below example could be used to access RDP behind a firewall, but accessible from YOURREMOTESERVER


3389 – RDP port

N – will not start a terminal session.



Use localhost as the hostname/IP to establish connection from your desktop

compressing a pdf to a lower size

Use Ghost Script from commandline

gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/screen -dCompatibilityLevel=1.6 -sOutputFile=pdfoutsmallfile.pdf pdfinputlargefile.pdf

-dNOPAUSE – disable the interactive prompting
pdfwrite – create pdf files
-dCompatibilityLevel=1.6 – compatibility with each versions of adobe. Use 1.3,1.4,1.6,1.7
-sOutputFile – name of the output file.

Port check script

NC=’\033[0m’ # No Color

function checkport {
if nc -zv -w30 $1 $2 <<< ” &> /dev/null
echo “${GREEN}[O]${NC} $1:$2”
echo “${RED}[C]${NC} $1:$2”

printf “server list:”;
read server
printf “ports list[enter for default]:”
read ports_to_check

if [[ $ports_to_check = “” ]]; then
echo “using default port list”;
ports_to_check=”22 389 3306 8080″; #enter your default list of ports here
echo “$ports_to_check”;

for i in $server;do
echo “==========================================”
for j in $ports_to_check ; do
checkport $i $j
}; done

Create a md5 hash password

Here are the steps to create an MD5 hash password

To use in linux shadow file or when you want to update the password somewhere

You will need “mkpasswd”

If your server seem to be missing the mkpasswd command, install it using yum.

yum install expect

Create the password and update for the user in /etc/shadow file.

mkpasswd -l 8 -d 3 -C 1 -s 1 maugustine

l – minimum length of password

d – minimum number of digits in password

C – number of uppercase characters

s – special characters.


The user you specify in mkpasswd should exist on the system

Grep command for windows

Here is how you do grep in windows using powershell.

PS G:\> Get-ChildItem -Path G:\messages\processed | Select-String -Pattern “string pattern” | Measure-Object -Line

Find your tomcat version

Sometimes you might need to figure out your tomcat version from within the folder where you run tomcat from. The below command will help you get the details.

java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo

/usr/share/tomcat7$ java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo
Server version: Apache Tomcat/7.0.81
Server built: Aug 11 2017 10:21:27 UTC
Server number:
OS Name: Linux
OS Version: 3.13.0-95-generic
Architecture: amd64
JVM Version: 1.7.0_75-b13
JVM Vendor: Oracle Corporation