Run a shell script with -x option
$ bash -x script-name
$ bash -x shell-script.sh
Use a set builtin command
set -x : Display commands and their arguments as they are executed.
set -v : Display shell input lines as they are read
i.e. in bash-script.sh
#!/bin/bash -xv
OR
set -x #turn on debug mode
set _x #turn off debug mode