Linux Labs

Inside the system: resources, kernel, processes / Stage 4 of 12

ulimit and sysctl: system ceilings

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 10 · on a machine · 5 min

Kernel parameters

The kernel itself has ceilings too. These and other kernel settings can be changed on the fly — they are the kernel parameters.

A parameter is a number or a flag: how many file watches to give a user, whether to forward packets between networks, how eagerly to go to swap. Each parameter is a file in /proc/sys, and the dotted name repeats its path: fs.inotify.max_user_watches is /proc/sys/fs/inotify/max_user_watches. The sysctl command reads and changes parameters.

Exercise · look

Try to change a parameter

Read the fs.inotify.max_user_watches parameter with sysctl and as a file in /proc/sys, then try to set it to 65536 without sudo and read it again.

First, predict

You change the parameter with sysctl -w without sudo. What will it print?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in

Anyone can read parameters; only root can change them: sudo sysctl -w <name>=<value>. A refused sysctl -w without sudo exits with code 0, so a script can easily miss it: check the value with a separate command (see sysctl).

A value set with sysctl -w lives until a reboot. At start the kernel begins with its own values, and the manual change is gone.

Ubuntu 24.04
Loading…