Disable core dumps in Linux
limits.conf and sysctl
Edit /etc/security/limits.conf and append the following lines:
* hard core 0
* soft core 0Edit /etc/sysctl.d/9999-disable-core-dump.conf:
fs.suid_dumpable=0
kernel.core_pattern=|/bin/falsesudo sysctl -p /etc/sysctl.d/9999-disable-core-dump.conf/bin/falseexits with a failure status code. The default value forkernel.core_patterniscoreon a Debian server and|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %hon a Fedora desktop. These commands are executed upon crashes. In the case of/bin/false, nothing happens, and core dump is disabled.fs.suid_dumpable=0Any process that has changed privilege levels or is execute only will not be dumped. Other values include1, which is debug mode, and all processes dump core when possible. The current user owns the core dump, no security is applied.2, suidsafe mode, in which any Linux program that would generally not be dumped is dumped regardless, but only if thekernel.core_patternis sysctl is set to a valid program.
systemd
sudo mkdir /etc/systemd/coredump.conf.d/
sudo nvim /etc/systemd/coredump.conf.d/custom.conf[Coredump]
Storage=none
ProcessSizeMax=0Storage=noneandProcessSizeMax=0disables all coredump handling except for a log entry under systemd.
sudo systemctl daemon-reloadEdit /etc/systemd/system.conf. Make sure DefaultLimitCORE is commented out.
#DefaultLimitCORE=infinitysudo systemctl daemon-reexec