How do I use the Strace debugging tool

  • 2020-06-03 06:04:41
  • OfStack

strace is a program debugging tool in Linux environment, used to monitor the system calls used by an application and the system information it receives.
strace is a useful gadget that tracks system calls to let you know what a program is doing in the background. Strace is a basic debugging tool that is installed by default on most Linux systems. But it's a great piece of software even if you're not tracking a problem. It tells you a lot about how an Linux program works.

Let's start with a simple UNIX command, pwd, and take a closer look at what the command does in the process of accomplishing its tasks. Start xterm to create a controlled environment to experiment in, then type the following command:

$ pwd

The pwd command displays the current working directory. On my computer, the output was:

/home/bill/

Such a simple function belies the underlying complexity of the command (which, by the way, is true of all computer programs). To really understand the complexity, run the pwd command again using the strace tool:

$ strace pwd

From this command, you can see that the UNIX machine does quite a bit of work as it displays and enumerates the current working directory.

Related articles: