How Do You Use the strace Utility?

Problem scenario
You want to use the strace command. How do you use it?

Solution

  1. Go to a Linux command prompt.
  2. Run this: sleep 100 &
  3. Look at the number the above command produced (e.g., 310222). Craft a command like this (but replace 310222 with the number in the above command): strace kill 310222
  4. Run the command drafted above. You should see lines like "openat…" and "kill". In the kill command you will see the returned signal from the kernel (e.g., SIGTERM)
  5. Run this: sleep 100 &
  6. Look at the number the above command produced (e.g., 310222). Craft a command like this (but replace 310222 with the number in the above command): strace kill -9 310222
  7. Run the command drafted above. You should see lines like "openat…" and "kill". In the kill command you will see the returned signal from the kernel (e.g., SIGKILL)

FFR
The -9 flag in kill will kill a process; normally kill would just terminate the process.

To learn more about strace, see this external posting.

Leave a comment

Your email address will not be published. Required fields are marked *