6 Managing Kernel Parameters at Runtime
Some virtual files under /proc
, and especially under
/proc/sys
, are writable. You can adjust settings in the running
kernel through these files. For example, to change the hostname, you can revise the
/proc/sys/kernel/hostname
file as follows:
echo www.mydomain.com | sudo tee /proc/sys/kernel/hostname
Other files take binary or Boolean values, such as the setting of IP forwarding, which is
defined in /proc/sys/net/ipv4/ip_forward
:
cat /proc/sys/net/ipv4/ip_forward
0
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
cat /proc/sys/net/ipv4/ip_forward
1
Use the sysctl
command to view or change values under the
/proc/sys
directory.
Note:
Even root
can't bypass the file access permissions of virtual file
entries under /proc
. If you change the value of a read-only entry
such as /proc/partitions
, no kernel code exists to service the
write()
system call.
For more information, see the sysctl(8)
and
sysctl.d(5)
manual pages.