sysctl.si › Parameters › kernel.yama.ptrace_scope

kernel.yama.ptrace_scope

Controls which processes may attach a debugger to others.

Default
0 or 1
Typical value
1

When to change it

Stops one process from debugging an unrelated one. Debuggers such as gdb then need root or a parent relationship.

Check the current value

sysctl kernel.yama.ptrace_scope

Change it until the next reboot

sudo sysctl -w kernel.yama.ptrace_scope=1

Make it permanent

echo "kernel.yama.ptrace_scope = 1" | sudo tee /etc/sysctl.d/99-custom.conf
sudo sysctl --system

Related parameters

kernel.pid_max · kernel.kptr_restrict

Generate a full sysctl config for your server

Values are starting points. Test on a staging machine and measure before and after.