core(5)
๐ core(5) โ the manual page bestie, but make it a group chat ๐
okay so this is core(5) from the File Formats Manual, and it's literally the lore behind that sad little core file that shows up in your directory and ruins your vibe. we're doing part 1 today, more coming, don't go anywhere ๐ซถ
โจ NAME โจ
core โ core dump file ๐
like. the file. the one that appears. bestie it's the core dump file.
๐ธ DESCRIPTION ๐ธ
so here's the tea: certain signals have a default action of making a process terminate and produce a core dump file. that file is basically a whole image of the process's memory at the exact moment it terminated. iconic, tragic, very main character.
and you can take that image into a debugger (like gdb(1)) and be like "okay so what was happening right before you died" โ you get to inspect the state of the program at the time it terminated. full detective mode ๐. and if you want the list of exactly which signals cause a process to dump core, that lives in signal(7).
a process can also set its soft RLIMIT_CORE resource limit to put an upper limit on how big the core dump file can get if it receives a "core dump" signal. details in getrlimit(2). so you can literally cap the drama.
now. the sad part. there are SO many circumstances where a core dump file is justโฆ not produced. like the kernel said "no โค๏ธ". here they all are:
- no permission to write the core file. by default the core file is called
coreorcore.pid, where pid is the ID of the process that dumped core, and it's created in the current working directory. (naming details below, we get there.) writing the core file fails if the directory where it should be created isn't writable, or if a file with the same name already exists and that file is not writable or is not a regular file (so like, it's a directory, or a symbolic link ๐). - more than one hard link. a (writable, regular) file with the same name as would be used for the core dump already exists, but there is more than one hard link to that file. yeah. nope.
- filesystem problems. the filesystem where the core dump file would be created is full; or has run out of inodes; or is mounted read-only; or the user has reached their quota for the filesystem. it's giving "my disk said absolutely not".
- the directory doesn't exist. the directory in which the core dump file is to be created does not exist. obviously ๐ญ
- resource limits are zero. the
RLIMIT_CORE(core file size) orRLIMIT_FSIZE(file size) resource limits for the process are set to zero; seegetrlimit(2)and the docs for your shell'sulimitcommand (limitincsh(1)). however,RLIMIT_COREwill be ignored if the system is configured to pipe core dumps to a program. noted! - the binary isn't readable. the binary being executed by the process does not have read permission enabled. this is a security measure, so that an executable whose contents are not readable doesn't produce a โ possibly readable โ core dump containing an image of the executable. makes sense honestly.
- set-user-ID / set-group-ID / file capabilities. the process is executing a set-user-ID (set-group-ID) program that is owned by a user (group) other than the real user (group) ID of the process, or the process is executing a program that has file capabilities (see
capabilities(7)). (however, see the description of theprctl(2)PR_SET_DUMPABLEoperation, and the description of the/proc/sys/fs/suid_dumpablefile inproc(5)โ there's an escape hatch iykyk.) - empty pattern +
core_uses_pidis 0./proc/sys/kernel/core_patternis empty and/proc/sys/kernel/core_uses_pidcontains the value0. (both files described below, bestie.) and listen โ note that if/proc/sys/kernel/core_patternis empty and/proc/sys/kernel/core_uses_pidcontains the value1, core dump files will have names of the form.pid, and such files are hidden unless one uses thels(1)-aoption. sneaky little dotfiles ๐ป - (Since Linux 3.7) the kernel was configured without the
CONFIG_COREDUMPoption. no config, no core, periodt.
and one more thing! a core dump may exclude part of the address space of the process if the madvise(2) MADV_DONTDUMP flag was employed. selective memory, literally.
also โ on systems that employ systemd(1) as the init framework, core dumps may instead be placed in a location determined by systemd(1). see below for further details.
๐ Naming of core dump files ๐
by default, a core dump file is named core. but the /proc/sys/kernel/core_pattern file (since Linux 2.6 and 2.4.21) can be set to define a template that's used to name core dump files. and this template can contain % specifiers, which get substituted with the following values when a core file is created:
%% A single % character.
%c Core file size soft resource limit of crashing process (since
Linux 2.6.24).
%C CPU the task ran on (since Linux 6.2).
%d Dump modeโsame as value returned by prctl(2) PR_GET_DUMPABLE
(since Linux 3.7).
%e The process or thread's comm value, which typically is the same
as the executable filename (without path prefix, and truncated
to a maximum of 15 characters), but may have been modified to be
something different; see the discussion of /proc/pid/comm and
/proc/pid/task/tid/comm in proc(5).
%E Pathname of executable, with slashes ('/') replaced by
exclamation marks ('!') (since Linux 3.0).
%f Actual filename of executable, which may differ from %e (since
Linux 5.9).
%F PIDFD of dumped process (since Linux 6.16).
%g Numeric real GID of dumped process.
%h Hostname (same as nodename returned by uname(2)).
%i TID of thread that triggered core dump, as seen in the PID
namespace in which the thread resides (since Linux 3.18).
%I TID of thread that triggered core dump, as seen in the initial
PID namespace (since Linux 3.18).
%p PID of dumped process, as seen in the PID namespace in which the
process resides.
%P PID of dumped process, as seen in the initial PID namespace
(since Linux 3.12).
%s Number of signal causing dump.
%t Time of dump, expressed as seconds since the Epoch, 1970-01-01
00:00:00 +0000 (UTC).
%u Numeric real UID of dumped process.
okay a few rules about these, and they matter:
- a single
%at the end of the template is dropped from the core filename. - same deal for a
%followed by any character other than those listed above โ dropped. - all other characters in the template become a literal part of the core filename.
- the template may include
/characters, which are interpreted as delimiters for directory names. - the maximum size of the resulting core filename is 128 bytes (64 bytes before Linux 2.6.19).
- the default value in this file is
"core". - for backward compatibility: if
/proc/sys/kernel/core_patterndoes not include%pand/proc/sys/kernel/core_uses_pid(see below) is nonzero, then.PIDwill be appended to the core filename.
and the paths situation ๐ง: paths are interpreted according to the settings that are active for the crashing process. that means the crashing process's mount namespace (see mount_namespaces(7)), its current working directory (found via getcwd(2)), and its root directory (see chroot(2)). so it's the vibe of the process that crashed, not yours.
Since Linux 2.4, Linux has also provided a more primitive method of controlling the name of the core dump file. the rules:
- if
/proc/sys/kernel/core_uses_pidcontains the value0, the core dump file is simply namedcore. - if this file contains a nonzero value, the core dump file includes the process ID in a name of the form
core.PID.
Since Linux 3.6, if /proc/sys/fs/suid_dumpable is set to 2 ("suidsafe"), the pattern must be either an absolute pathname (starting with a leading / character) or a pipe, as defined below. no exceptions bestie, that's the law.
๐ Piping core dumps to a program ๐
Since Linux 2.6.19, Linux supports an alternate syntax for the /proc/sys/kernel/core_pattern file. if the first character of this file is a pipe symbol (|), then the remainder of the line is interpreted as the command-line for a user-space program (or script) that is to be executed. so instead of a file, your core dump gets piped to a whole program. slay.
and here's a version-difference tea moment ๐ต that you NEED to know about:
- Since Linux 5.3.0, the pipe template is split on spaces into an argument list before the template parameters are expanded.
- in earlier kernels, the template parameters are expanded first and the resulting string is split on spaces into an argument list.
why does that matter? because in earlier kernels, executable names added by the %e and %E template parameters could get split into multiple arguments. so the core dump handler needs to put the executable names as the last argument and ensure it joins all parts of the executable name using spaces. and yeah โ executable names with multiple spaces in them are not correctly represented in earlier kernels, meaning that the core dump handler needs to use mechanisms to find the executable name. messy, honestly.
so instead of being written to a file, the core dump is given as standard input to the program. and here's the notes, all of them, no skipping:
- the program must be specified using an absolute pathname (or a pathname relative to the root directory,
/), and must immediately follow the|character. - the command-line arguments can include any of the
%specifiers listed above. for example, to pass the PID of the process that is being dumped, specify%pin an argument. - the process created to run the program runs as user and group root ๐.
- running as root does not confer any exceptional security bypasses. namely, LSMs (e.g.,
SELinux) are still active and may prevent the handler from accessing details about the crashed process via/proc/pid. root is not a force field, bestie. - the program pathname is interpreted with respect to the initial mount namespace as it is always executed there. it is not affected by the settings (e.g., root directory, mount namespace, current working directory) of the crashing process.
- the process runs in the initial namespaces (PID, mount, user, and so on) and not in the namespaces of the crashing process. one can utilize specifiers such as
%Pto find the right/proc/piddirectory and probe/enter the crashing process's namespaces if needed. - the process starts with its current working directory as the root directory. if desired, it is possible to change to the working directory of the dumping process by employing the value provided by the
%Pspecifier to change to the location of the dumping process via/proc/pid/cwd. - command-line arguments can be supplied to the program (since Linux 2.6.24), delimited by white space (up to a total line length of 128 bytes).
- the
RLIMIT_CORElimit is not enforced for core dumps that are piped to a program via this mechanism. yeah, that limit just doesn't apply here. noted!
๐ฆ /proc/sys/kernel/core_pipe_limit ๐ฆ
so when you're collecting core dumps via a pipe to a user-space program, it can be useful for the collecting program to gather data about the crashing process from that process's /proc/pid directory. makes sense, very useful.
but to do this safely, the kernel must wait for the program collecting the core dump to exit, so as not to remove the crashing process's /proc/pid files prematurely. which is great, exceptโฆ this in turn creates the possibility that a misbehaving collecting program can block the reaping of a crashed process by simply never exiting. ๐ a program just vibing forever and holding everything up. rude.
Since Linux 2.6.32, the /proc/sys/kernel/core_pipe_limit can be used to defend against this possibility. the value in this file defines how many concurrent crashing processes may be piped to user-space programs in parallel. and if this value is exceeded, then those crashing processes above this value are noted in the kernel log and their core dumps are skipped. so like, the limit is the limit, and the extras just get logged and dropped. that's the defense ๐ก๏ธ
okay that's part 1 bestie, we are SO not done, more is coming ๐
Fr though, a value of 0 in this file is special, and not in a cute way. It means unlimited processes may be captured in parallel, but no waiting will take place โ i.e., the collecting program is not guaranteed access to /proc/<crashing-PID>. The default value for this file is 0. ๐ซ
๐ Controlling which mappings are written to the core dump ๐
Since Linux 2.6.23, there's a Linux-specific file, /proc/pid/coredump_filter, and bestie, it is literally the remote control for which memory segments get written to the core dump file when a core dump is performed for the process with the corresponding process ID. ๐
The value in the file is a bit mask of memory mapping types (peep mmap(2)). If a bit is set in the mask, then memory mappings of the corresponding type are dumped. If it's not set, they are not dumped. No in-between, it's giving binary. ๐
The bits in this file mean:
bit 0โ Dump anonymous private mappings.bit 1โ Dump anonymous shared mappings.bit 2โ Dump file-backed private mappings.bit 3โ Dump file-backed shared mappings.bit 4(since Linux 2.6.24) โ Dump ELF headers.bit 5(since Linux 2.6.28) โ Dump private huge pages.bit 6(since Linux 2.6.28) โ Dump shared huge pages.bit 7(since Linux 4.4) โ Dump private DAX pages.bit 8(since Linux 4.4) โ Dump shared DAX pages.
By default, the following bits are set: 0, 1, 4 (only if the CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS kernel configuration option is enabled), and 5. And this default can be modified at boot time using the coredump_filter boot option. โจ
The value of this file is displayed in hexadecimal. (So the default value is displayed as 33.) ๐งฎ
Memory-mapped I/O pages like frame buffer are never dumped. Never ever. And virtual DSO (vdso(7)) pages are always dumped, regardless of the coredump_filter value โ they're the main characters here, the rules don't apply to them. ๐
A child process created via fork(2) inherits its parent's coredump_filter value, and the coredump_filter value is preserved across an execve(2). Family trauma but make it memory mappings. ๐ญ
It can be useful to set coredump_filter in the parent shell before running a program, for example:
$ echo 0x7 > /proc/self/coredump_filter
$ ./some_program
Heads up though: this file is provided only if the kernel was built with the CONFIG_ELF_CORE configuration option. No option, no file, no vibes. ๐ฆ
๐ Core dumps and systemd ๐
On systems using the systemd(1) init framework, core dumps may be placed in a location determined by systemd(1). To do this, systemd(1) employs the core_pattern feature that allows piping core dumps to a program. One can verify this by checking whether core dumps are being piped to the systemd-coredump(8) program:
$ cat /proc/sys/kernel/core_pattern;
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %e
In this case, core dumps will be placed in the location configured for systemd-coredump(8) โ typically as zstd(1) compressed files in the directory /var/lib/systemd/coredump/. Compression on or off is configurable via coredump.conf(5). ๐พ
One can list the core dumps that have been recorded by systemd-coredump(8) using coredumpctl(1):
$ coredumpctl list | tail -5;
Wed 2017-10-11 22:25:30 CEST 2748 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:29:10 CEST 2716 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:30:50 CEST 2767 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:37:40 CEST 2918 1000 1000 3 present /usr/bin/cat
Thu 2017-10-12 08:13:07 CEST 2955 1000 1000 3 present /usr/bin/cat
The information shown for each core dump includes the date and time of the dump, the PID, UID, and GID of the dumping process, the signal number that caused the core dump, and the pathname of the executable that was being run by the dumped process. ๐
Various options to coredumpctl(1) allow a specified coredump file to be pulled from the systemd(1) location into a specified file. For example, to extract the core dump for PID 2955 shown above to a file named core in the current directory, one could use:
$ coredumpctl dump 2955 -o core;
For more extensive details, see the coredumpctl(1) manual page. ๐
To (persistently) disable the systemd(1) mechanism that archives core dumps โ restoring to something more like traditional Linux behavior โ one can set an override for the systemd(1) mechanism, using something like:
# echo "kernel.core_pattern=core.%p" > \;
/etc/sysctl.d/50-coredump.conf
# /lib/systemd/systemd-sysctl;
It is also possible to temporarily (i.e., until the next reboot) change the core_pattern setting using a command such as the following (which causes the names of core dump files to include the executable name as well as the number of the signal which triggered the core dump):
# sysctl -w kernel.core_pattern="%e-%s.core";
โจ NOTES โจ
- The
gdb(1)gcorecommand can be used to obtain a core dump of a running process. ๐ฅ - In Linux versions up to and including 2.6.27: if a multithreaded process dumps core โ or, more precisely, a process that shares its memory with another process by being created with the
CLONE_VMflag ofclone(2)โ then the process ID is always appended to the core filename, unless the process ID was already included elsewhere in the filename via a%pspecification in/proc/sys/kernel/core_pattern. (This is primarily useful when employing the obsolete LinuxThreads implementation, where each thread of a process has a different PID.) ๐งต
๐ EXAMPLES ๐
The program below can be used to demonstrate the use of the pipe syntax in the /proc/sys/kernel/core_pattern file. The following shell session demonstrates the use of this program (compiled to create an executable named core_pattern_pipe_test):
$ cc -o core_pattern_pipe_test core_pattern_pipe_test.c
$ su
Password:
# echo "|$PWD/core_pattern_pipe_test %p UID=%u GID=%g sig=%s" > \
/proc/sys/kernel/core_pattern
# exit
$ sleep 100
^\ # type control-backslash
Quit (core dumped)
$ cat core.info
argc=5
argc[0]=</home/mtk/core_pattern_pipe_test>
argc[1]=<20575>
argc[2]=<UID=1000>
argc[3]=<GID=100>
argc[4]=<sig=3>
Total bytes in core dump: 282624
๐ธ Program source ๐ธ
/* core_pattern_pipe_test.c */
#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define BUF_SIZE 1024
int
main(int argc, char *argv[])
{
ssize_t nread, tot;
char buf[BUF_SIZE];
FILE *fp;
char cwd[PATH_MAX];
/* Change our current working directory to that of the
crashing process. */
snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
chdir(cwd);
/* Write output to file "core.info" in that directory. */
fp = fopen("core.info", "w+");
if (fp == NULL)
exit(EXIT_FAILURE);
/* Display command-line arguments given to core_pattern
pipe program. */
fprintf(fp, "argc=%d\n", argc);
for (size_t j = 0; j < argc; j++)
fprintf(fp, "argc[%zu]=<%s>\n", j, argv[j]);
/* Count bytes in standard input (the core dump). */
tot = 0;
while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
tot += nread;
fprintf(fp, "Total bytes in core dump: %zd\n", tot);
fclose(fp);
exit(EXIT_SUCCESS);
}
๐ SEE ALSO ๐
bash(1), coredumpctl(1), gdb(1), getrlimit(2), mmap(2), prctl(2), sigaction(2), elf(5), proc(5), pthreads(7), signal(7), systemd-coredump(8)
ok so that's the whole page bestie, and the receipts say it's from Linux man-pages 6.20, dated 2026-05-07. go forth and core dump responsibly, mwah ๐๐๐ฆ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2006-2008, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms