How do I trace systems call on linux redhat?
-
Tracing system calls is useful for debugging programs that do no work and watching the output of the system calls being used, the files being accessed, and the error codes being generated, to help solve the issue.
Linux uses a command called strace to perform a trace on system calls. The command below is only truncated output
# strace ls execve("/bin/ls", ["ls"], [/* 21 vars */]) = 0 uname({sys="Linux", node="apt1l001", ...}) = 0 brk(0) = 0x515000 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2a95556000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=121143, ...}) = 0 mmap(NULL, 121143, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2a95557000 close(3) = 0
You can pass the output to a file as follows:
# strace -o /tmp/ls.out ls
© Lightnetics 2024