[Linux Tip] debuging a command

this is very useful when you are running a script that calls other scripts.

# set -x
# ls
+ ls --color=auto
anaconda-ks.cfg  install.log  install.log.syslog
++ printf '33]0;%s@%s:%s33\' root kmassada '~'

  -x Print commands and their arguments as they are executed.

Another indepth tool is strace. it logs all of the system calls made. it is a very verbose and useful way to see what is happenening on your shell

# strace -t ls
14:52:02 execve("/bin/ls", ["ls"], [/* 29 vars */]) = 0
14:52:02 brk(0)                         = 0x2244000
14:52:02 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd643d18000
14:52:02 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
14:52:02 open("/etc/ld.so.cache", O_RDONLY) = 3
14:52:02 fstat(3, {st_mode=S_IFREG|0644, st_size=87611, ...}) = 0
14:52:02 mmap(NULL, 87611, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd643d02000
14:52:02 close(3)                       = 0

.... 

    -t Shows time of the day