Thursday, April 8, 2021

How to change python default version in ubuntu?

 In ubuntu By default python version was 2.7. We need to use python3 to run the python files with the latest version.

Steps to change the default python version to 3

Check the current version 

#python --version

Python 2.7.17

Execute this command to switch to python 3.6. 

#sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1


sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

Check python version

python --version

Python 3.6.9

Tuesday, April 6, 2021

How to Install innotop in linux?

Innotop is an efficient command-line monitoring tool for local and remote MySQL servers running under Innodb. It helps to monitoring several operations like MySQL replication status, user statistics, query list, InnoDB buffers, InnoDB I/O information etc.

To Install Innotop

Run the following command to install Innotop

In RedHat

yum install innotop

In Ubuntu

Fetch innotop from its GIT repository:

Install Perl dependency:

sudo apt install libterm-readkey-perl libclass-dbi-perl libclass-dbi-mysql-perl make 

sudo apt-get install git

git clone



cd innotop/

perl Makefile.PL

Note:If there no warnings and errors (in case you have to fix other dependencies), proceed with the installation of this good MySQL InnoDB real-time monitor:

sudo make install

Innotop can be launched in several ways, the easiest is to provide, on the command line, username and password (with -u [user] and -p [password]) of a privileged user.


sudo innotop -uuser -ppassword

Now the terminal will be logged in.

Press " ?" help symbol to view the various option available.

To Monitor the remote mysql server

If you want to monitor the remote mysql server, run the below command. Login the remote mysql server enter the mysql username, password and hostname.

sudo innotop -uuser -ppassword -hip_address

Wednesday, March 24, 2021

How to find the file size of a remote HTTP object?

There are times when you need to know the file size of an HTTP object without actually downloading the file. This little trick comes in very handy when web servers respond with the Content-Length of an object in the HEAD request itself.

Using curl command:


curl -sI | grep Content-Length

Content-Length: 2877227008

Let’s try and make this human-friendly:

curl -sI | grep Content-Length | sed 's/[^0-9]//g' | numfmt --to=si


Where The Numfmt command will convert the numbers to/from human-readable format.

Wednesday, December 30, 2020

how to convert from one date format to another format in linux ?

 how to convert from one date format to another format in linux ?

echo 04-11-2021 | { IFS=- read d m y && echo "$y$m$d"; }


echo 04-11-2021 | { IFS=- read d m y && echo "$y/$m/$d"; }


 echo 04-11-2021 | { IFS=- read d m y && echo "$d$m$y"; }


 echo 04-11-2021 | awk -F- '{print $3$2$1}'


echo 04-11-2021 |gawk -F, '{split($1, a, "-"); print a[3] a[2] a[1]}' 


echo 04/11/2021 | { IFS=/ read d m y && echo "$y$m$d"; }


date -d "20211104" "+%Y-%m-%d"


date -d 04/11/2021 +%F


 %F   full date; same as %Y-%m-%d

Monday, December 28, 2020

how to add user using shell script?

 #!/bin/bash -x 

if [ $(id -u) -eq 0 ]; then

read -p "Enter username : " username

read -s -p "Enter password : " password

egrep "^$username" /etc/passwd >/dev/null

if [ $? -eq 0 ]; then

echo "$username exists!"

exit 1


if [ -f /usr/bin/mkpasswd ]; then

pass=$(mkpasswd -m sha-512 $password)

#mkpasswd will create encrypted password.

useradd -m -p "$pass" "$username"

[ $? -eq 0 ] && echo "User has been added to system!" && chage -d0 $username  || echo "Failed to add a user!"


echo "install package apt-get install whois"




echo "Only root may add a user to the system."

exit 2