Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Tired of core files going wherever, whenever? Best thing to do about it is setup yourself a global core file repository.

First thing to do is make a directory for the new core files. It must be done by the user id, for example for UID 1000:

mkdir -pv -m 0700 /var/core/1000
chown 1000 /var/core/1000

Then to make things user readable, or just make it wherever you want to make it to (as the user):

ln -sv /var/core/$UID ${HOME}/core

Now we have to setup the sysctl for this (for more information see man 5 core). As an example:

echo 'kernel.core_pattern=/var/core/%u/%p-%t-%h-%e.core' >> /etc/sysctl.conf

Finally, setup for the user, put this in your shell rc file, something like this should do:

echo 'ulimit -c unlimited' >> "$HOME/.`basename $SHELL`rc"

or globally (as root):

echo 'ulimit -c unlimited' >> /etc/profile.d/

Optionally, I also put it in my shell rc to inform me if I didn't notice something dumped a core:

[ $(ls -1 /var/core/${UID} | wc -l) -ne 0 ] && echo "New corefiles are available in /var/core/`whoami`"
Retrieved from ""

Last modified: Fri, 05 Sep 2008 23:17:00 +0000 Hits: 5,442