Where Does GDB Read Init Files From?
GDB loads system gdbinit, then ~/.config/gdb/gdbinit, then ./.gdbinit, with auto loading locked down by default.
Last updated
GDB reads a short chain of init files at startup: system wide, then user, then the current directory. The user file moved to the XDG config home in modern builds, which strands old guides pointing at home root.
Auto loading from the current directory stays disabled unless you allow it, a deliberate defense against malicious projects. Enhancers like GEF and Pwndbg hook in through these same files.
Where GDB stores this, by platform
~/.config/gdb/gdbinit
Modern user init file, with ~/.gdbinit kept as fallback on older builds. System file sits in /etc/gdb/gdbinit.d. Local ./.gdbinit loads only with auto-load permission granted.
~/.config/gdb/gdbinit
Same XDG path on Mac. Codesigning requirements bite before config does: an unsigned GDB cannot attach to anything regardless of init files.
Frequently asked questions
why is gdb ignoring my gdbinit
Check which path your build reads: new ones want ~/.config/gdb/gdbinit while old ones read ~/.gdbinit. Run show data-directory and check home versus XDG to confirm.
how do i load gef or pwndbg automatically
Source the enhancer script from your user gdbinit. Keep one enhancer per file to avoid them fighting over prompts and hooks.
is it safe to auto load gdbinit from projects
Only for projects you trust, since init files run arbitrary commands. Enable it per directory with add-auto-load-safe-path rather than globally.
Notice an outdated path? Let us know.