Tip of the Trade: strace
When a Linux or Unix program fails to run and does not offer anything helpful in the way of error messages, the resourceful admin typically resorts to Google searches and haunting user forums to find answers. This often entails a fair bit of hit-or-miss diagnosis, which is the most time-consuming and frustrating part. Find system failures fast. Strace gets under the hood and produces explanations even a nonprogrammer can understand.
What if you could look under the hood and pinpoint the failure before wandering all over cyberspace? You can, with strace, the "system call tracer."
Traditionally strace is a programmer's debugging tool, but ordinary end users can benefit from it as well. It shows each system call, arguments, and return values. The simplest way to run it is like this:
$ strace [program_name] |
For example, when Tuxracer is run from the games menu (hey, hardworking admins need relaxation, too) nothing happens, with no indication of why nothing happens.
However, with strace:
$ strace tuxracer |
Even nonprogrammers will understand much of the output, like "No such file or directory," and "tuxracer isn't developed any further. Please run 'ppracer' instead." Those are messages that apparently should be displayed somewhere, but weren't. Just for kicks, from our terminal:
| $ tuxracer tuxracer isn't developed any further. Please run 'ppracer' instead. For further Information please read /usr/share/doc/tuxracer/README.Debian |
In an ideal world, since Tuxracer is a graphical program not customarily run from the command line, error messages would be sent where they could be read. But this world is far from ideal, so here we are.
strace has a number of useful options. Because of the volume of output, consider sending it to a file:
$ strace -o tuxracer.txt tuxracer |
Use the -p option to monitor a running process. Hit Ctrl+C to stop it.
strace output isn't all that mysterious, just over-abundant. With a little patience you can usually figure out where an application went wrong.
