Skip to content

How to Get a Stack Trace

Oleg Shparber edited this page Mar 21, 2026 · 1 revision

Who is this for? Anyone using an app on Ubuntu or other modern Linux systems who has been asked to provide a stack trace after a crash. No programming knowledge needed — just copy and paste the commands below.


What is a stack trace?

A stack trace is a snapshot of what the app was doing at the moment it crashed. It helps developers figure out what went wrong and fix the bug. Think of it like a black box flight recorder, but for software.


Before you start

You'll need to open a Terminal window. You can usually find it by searching "Terminal" in your app launcher or applications menu. (On some desktop environments like GNOME, the shortcut Ctrl + Alt + T also works.)


Step 1 — Install the debugger tool

Copy and paste this into the Terminal, then press Enter. You may be asked for your password.

sudo apt install gdb

You only need to do this once.


Step 2 — Check that crash recording is enabled

Most modern Ubuntu systems (22.04 and later) automatically record crashes. To confirm, run:

cat /proc/sys/kernel/core_pattern

If the output contains the word systemd-coredump, you're all set — move on to Step 3.

If it does not, talk to your system administrator or the developer who asked for the trace. They may need to enable it for you.


Step 3 — Reproduce the crash

Use the app normally and do whatever causes it to crash. The system will silently save a record of the crash in the background.


Step 4 — Generate the stack trace

After the crash, go back to your Terminal and run:

coredumpctl gdb

This opens a debugging prompt. You may see some questions:

  • "Enable debuginfod for this session? (y or [n])" → Type y and press Enter.
  • "Continue without paging?" → Type c and press Enter (you may need to do this more than once).

Once you see the (gdb) prompt, type:

bt full

Press Enter. A wall of text will appear — that's the stack trace!

When it finishes, type:

quit

Press Enter and confirm with y if asked.


Step 5 — Save and share the output

The easiest way to capture everything cleanly is to re-run the whole thing with output saved to a file. Instead of coredumpctl gdb, run:

coredumpctl gdb 2>&1 | tee ~/stack-trace.txt

Then repeat the bt full and quit steps above. A file called stack-trace.txt will be saved in your home folder. Send that file to the developer who asked for it.


Quick reference (cheat sheet)

Step Command
Install debugger (once) sudo apt install gdb
Check crash recording cat /proc/sys/kernel/core_pattern
Open last crash coredumpctl gdb
Get the stack trace bt full
Quit the debugger quit
Save output to file coredumpctl gdb 2>&1 | tee ~/stack-trace.txt

Troubleshooting

  • "No coredumps found" — The system hasn't recorded a crash yet. Reproduce the crash first, then try again.
  • "Permission denied" — Try running the command with sudo in front, e.g. sudo coredumpctl gdb.
  • The stack trace is full of ??? or hex addresses — That's okay, send it anyway. The developers can usually still work with it, especially on Ubuntu 22.04+ where debug symbols are fetched automatically.

Further reading

If you need more detail or run into an unusual setup, these are the best resources available:

Clone this wiki locally