• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

ltrace Command Examples in Linux

by Deepika

The ltrace command can be used to intercept and record the dynamic calls made to shared libraries. The amount of output generated by the ltrace command can be overwhelming for some commands (especially if the -S option is used to also show system calls). You can focus the output to just the interaction between the program and some list of libraries. For example, to execute the id -Z command and show the calls made to the libselinux.so module, execute:

$ ltrace -l /lib/libselinux.so.1 id -Z
is_selinux_enabled(0xc1c7a0, 0x9f291e8, 0xc1affc, 0, -1)a
       =1	
getcon(0x804c2c8, 0xfee80ff4, 0x804b179, 0x804c020, 0)a
       =0
user_u:system_r:unconfined_t

Remember that you can see what libraries a program is linked against using the ldd command.

ltrace Command Examples

1. Print (trace) library calls of a program binary:

# ltrace ./program

2. Count library calls. Print a handy summary at the bottom:

# ltrace -c path/to/program

3. Trace calls to malloc and free, omit those done by libc:

# ltrace -e malloc+free-@libc.so* path/to/program

4. Write to file instead of terminal:

# ltrace -o file path/to/program

Filed Under: Linux

Some more articles you might also be interested in …

  1. mailstat Command Examples in Linux
  2. cpupower: command not found
  3. K3b Nero like CD/DVD Burning Software in Ubuntu Linux
  4. What is Anacron and usage of Anacron in Linux
  5. –force V/s –nodeps : rpm command options to install or uninstall a package
  6. How to Find Filesystem Inode Utilization in Linux
  7. “aws s3 mv” Command Examples
  8. tee: command not found
  9. traceroute Command Examples in Linux
  10. flyctl: Command-line tool for flyctl.io

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright