IT lexicon › Security › securelevel

securelevel

Security På svenska → Updated: 2026-11-08

A BSD kernel setting that limits what even root may do, and can only be raised while the system is running.

The idea arrived with 4.4BSD: root is too powerful, so the kernel gets a latch that root itself cannot lift. kern.securelevel runs from -1 (off) to 2. At level 1, file flags such as schg (immutable) and sappnd (append-only) can no longer be cleared, kernel modules cannot be loaded and /dev/mem cannot be written. Level 2 also forbids raw writes to mounted disks and setting the clock backwards.

Only init can lower the value, in practice by rebooting into single-user mode. That is also the weakness: an attacker with root can edit the startup scripts and wait for the next reboot, unless those are flagged immutable too. Most machines therefore run at the default level, making the feature better known than used.

← Back to the lexicon