Disable core dumps in Linux
limits.conf and sysctl
Edit /etc/security/limits.conf and append the following lines:
1* hard core 0
2* soft core 0Edit /etc/sysctl.d/9999-disable-core-dump.conf:
1fs.suid_dumpable=0
2kernel.core_pattern=|/bin/false1sudo 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
1sudo mkdir /etc/systemd/coredump.conf.d/
2sudo nvim /etc/systemd/coredump.conf.d/custom.conf1[Coredump]
2Storage=none
3ProcessSizeMax=0Storage=noneandProcessSizeMax=0disables all coredump handling except for a log entry under systemd.
1sudo systemctl daemon-reloadEdit /etc/systemd/system.conf. Make sure DefaultLimitCORE is commented out.
1#DefaultLimitCORE=infinity1sudo systemctl daemon-reexec