C Shell Wiki
Posts (Latest 10 updated) :
Read all
Contents:
  1. [Linux] C Shell (csh) sysctl 用法等价: Manage kernel parameters at runtime
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] C Shell (csh) sysctl 用法等价: Manage kernel parameters at runtime

Overview

The sysctl command is used to examine and modify kernel parameters at runtime in Unix-like operating systems. It allows users to view and change system settings that affect the kernel’s behavior without needing to reboot the system.

Usage

The basic syntax of the sysctl command is as follows:

sysctl [options] [arguments]

Common Options

  • -a: Display all current kernel parameters.
  • -w: Write a new value to a kernel parameter.
  • -n: Show the value of a kernel parameter without the parameter name.
  • -p: Load parameters from a specified file.

Common Examples

Here are some practical examples of using the sysctl command:

  1. Display all kernel parameters:
    sysctl -a
    
  2. Get the value of a specific parameter:
    sysctl net.ipv4.ip_forward
    
  3. Set a new value for a kernel parameter:
    sysctl -w net.ipv4.ip_forward=1
    
  4. Load parameters from a configuration file:
    sysctl -p /etc/sysctl.conf
    
  5. Show the value of a parameter without the name:
    sysctl -n vm.swappiness
    

Tips

  • Always check the current value of a parameter before modifying it to understand its impact.
  • Use the -p option to apply multiple settings from a configuration file, making it easier to manage system parameters.
  • Be cautious when changing kernel parameters, as incorrect settings can affect system stability and performance.