-
Notifications
You must be signed in to change notification settings - Fork 827
How to Get a Stack Trace
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.
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.
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.)
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.
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.
Use the app normally and do whatever causes it to crash. The system will silently save a record of the crash in the background.
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.
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.
| 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 |
- "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
sudoin 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.
If you need more detail or run into an unusual setup, these are the best resources available:
- Stack Traces — GNOME Project Handbook — The clearest step-by-step guide online. Also covers Flatpak apps.
- Backtrace — Ubuntu Wiki — Official Ubuntu guide, including how to attach gdb to a running process.
-
DebuggingProgramCrash — Ubuntu Wiki — Covers Ubuntu's Apport crash-reporting system and
apport-retrace. - Getting Traces — GNOME Wiki — In-depth reference with distro-specific instructions for installing debug symbols.