Which statement describes the purpose of this command?

As a root user, you executed the following command on your Oracle Linux 6 server:
[root@host] # strace – o /tmp/diag.out sh diag.sh
Which statement describes the purpose of this command?

As a root user, you executed the following command on your Oracle Linux 6 server:
[root@host] # strace – o /tmp/diag.out sh diag.sh
Which statement describes the purpose of this command?

A.
It collects the memory and swap space metrics when the diag.sh scripts runs.

B.
It collects the operating system metrics when the diag.sh script runs.

C.
It records the memory usage and CPU usage information of the processes when the diah.sh
script runs.

D.
It records the system calls, which are called by the processes when the diag.sh script runs.

Explanation:
*strace – trace system calls and signals
In the simplest case strace runs the specified command until it exits. It intercepts and records the
system calls which are called by a process and the signals which are received by a process. The
name of each system call, its arguments and its return value are printed on standard error or to the
file specified with the -o option.
*strace is a useful diagnostic, instructional, and debugging tool. System administrators,
diagnosticians and trouble-shooters will find it invaluable for solving problems with programs for
which the source is not readily available since they do not need to be recompiled in order to trace
them. Students, hackers and the overly-curious will find that a great deal can be learned about a
system and its system calls by tracing even ordinary programs. And programmers will find that
since system calls and signals are events that happen at the user/kernel interface, a close
examination of this boundary is very useful for bug isolation, sanity checking and attempting to
capture race conditions.
Each line in the trace contains the system call name, followed by its arguments in parentheses
and its return value. An example from stracing the command ”cat /dev/null” is:
open(“/dev/null”, O_RDONLY) = 3
Errors (typically a return value of -1) have the errno symbol and error string appended.
open(“/foo/bar”, O_RDONLY) = -1 ENOENT (No such file or directory)

Signals are printed as a signal symbol and a signal string. An excerpt from stracing and
interrupting the command ”sleep 666” is:
sigsuspend([] <unfinished …>
— SIGINT (Interrupt) —+++ killed by SIGINT +++
Reference: man strace



Leave a Reply 0

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