Your SlideShare is downloading. ×
Sysctl
sysctl is a tool for examining and changing kernel parameters at runtime on linux based systems. In
order to change...
For quick testing of the new values that you want to alter or modify, you can either use 'sysctl'
command Or even 'echo' t...
Upcoming SlideShare
Loading in...5
×

Sysctl

291

Published on

sysct

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
291
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Sysctl"

  1. 1. Sysctl sysctl is a tool for examining and changing kernel parameters at runtime on linux based systems. In order to change the kernel parameters at run time, it makes use of procfs. In other words sysctl makes this possible via virtual process file system mounted at /proc/ during boot. Why it is called virtual file system? “The files and directories of the /proc filesystem are virtual” because the data is not actually stored on any sort of permanent storage like a hard disk; instead, the directories, files, and data within them are created dynamically in memory from raw kernel data whenever you attempt to read them. In a more straight & simple answer: this data is not associated with any block device but exists only in memory. Which commands internally uses this information? Number of linux commands such as ps, top, pstree, etc rely on this virtual filesystem for information. How can I make use of sysctl function to see all the kernel settings currently in use? To get a quick overview of all settings configurable in the /proc/sys/ directory, type the /sbin/sysctl -a command as root. This creates a large, comprehensive list. In order to view the list page by page, you can use the 'less' command with pipe as shown in the example below. [root@redhatcentos /]# sysctl -a | less A small portion of which looks something like the following: net.ipv4.route.min_delay = 2 kernel.sysrq = 0 kernel.sem = 250 32000 32 128
  2. 2. For quick testing of the new values that you want to alter or modify, you can either use 'sysctl' command Or even 'echo' to assign values to writable files in the /proc/sys/ directory. For instance using the ‘echo’ command: [root@redhatcentos /]# echo 1 > /proc/sys/kernel/sysrq [root@redhatcentos /]# cat /proc/sys/kernel/sysrq 1 [root@redhatcentos /]# The equivalent sysctl command is as follows: [root@redhatcentos /]# sysctl -w kernel.sysrq=1 kernel.sysrq = 1 [root@redhatcentos /]# This is temporary: While quickly setting single values like this in /proc/sys/ is helpful during testing, this method does not work as well on a production system as special settings within /proc/sys/ are lost when the machine is rebooted. To preserve custom settings, add them to the /etc/sysctl.conf file. This is permanent: Each time the system boots, the init program runs the /etc/rc.d/rc.sysinit script. This script contains a command to execute sysctl using /etc/sysctl.conf to determine the values passed to the kernel. Therefore any values added to /etc/sysctl.conf therefore take effect each time the system boots. Why did we need this in the first place? Modern operating system usually segregates virtual memory into kernel space and user space. Kernel space is strictly reserved for running the kernel, device drivers and kernel extensions. In most operating systems, kernel memory is never swapped out to disk. User space is the memory area where all user mode applications work and this memory can be swapped out when necessary. A user application cannot access kernel space directly and similarly kernel code cannot access the user space without checking whether the page is present in memory or swapped out. Even though these can not access each other directly, user and kernel space can communicate with each other using variety of ways and one of which is what we discussed above -called 'sysctl'. ashwinwriter@gmail.com

×