cgset
Set control group parameters
SYNOPSIS
cgset [-r|--recursive] [-s|--stat name=value] cgroup_path
PARAMETERS
-s name=value, --stat name=value
Sets the specified cgroup parameter (name) to the given value. The name typically follows the format controller.parameter_file (e.g., cpu.shares, memory.limit_in_bytes) and corresponds to a file within the cgroup's virtual filesystem.
-r, --recursive
Applies the setting recursively to all sub-cgroups within the specified cgroup_path, ensuring that child groups inherit or are updated with the same parameter value.
-h, --help
Displays a concise help message detailing command usage and options, then exits.
-v, --version
Displays the version information for the cgset utility and then exits.
cgroup_path
The absolute path to the target control group within the cgroup hierarchy that needs to be modified (e.g., /user.slice/mygroup). This path determines which specific cgroup's parameters will be affected.
DESCRIPTION
The cgset command is a utility from the cgroup-tools package, designed to dynamically modify parameters and settings of existing Linux control groups (cgroups). Cgroups are a powerful kernel feature that allow administrators to limit, account for, and isolate the resource usage (such as CPU, memory, network I/O, and disk I/O) of collections of processes.
With cgset, you can adjust various resource limits and properties for specific cgroups, thereby influencing the behavior and resource consumption of processes associated with those groups. It operates by writing specified values to control files within the cgroup virtual filesystem, which the kernel then interprets to enforce the desired resource management policies.
CAVEATS
Using cgset typically requires root privileges because it directly manipulates system resource allocations. The specified cgroup must already exist in the cgroup hierarchy. Supplying incorrect parameter names or invalid values can lead to errors or undesirable system behavior. A solid understanding of cgroup controllers and their specific parameters is crucial before making any changes.
CGROUP FILESYSTEM INTERACTION
Under the hood, cgset translates command-line arguments into direct writes to control files exposed by the kernel via the cgroup virtual filesystem, which is commonly mounted at /sys/fs/cgroup. For instance, running `cgset -s cpu.shares=512 /mygroup` effectively writes the string "512" into the file /sys/fs/cgroup/cpu/mygroup/cpu.shares, instructing the kernel to adjust the CPU shares for that group.
PERMISSIONS AND SECURITY
Modifying cgroup parameters has direct implications for system resource allocation and can affect overall system stability and performance. Consequently, these operations almost invariably require superuser (root) privileges. It is critical to restrict access to cgset and similar cgroup manipulation tools to authorized users to maintain system security and integrity.
HISTORY
cgset is an integral component of the cgroup-tools suite, a collection of utilities developed to provide user-space interaction with the Linux kernel's control group (cgroup) feature. Its functionality has been consistent since its inception, evolving with the kernel's cgroup implementation (from v1 to v2) while maintaining its core purpose of modifying controller-specific parameters via the cgroup filesystem interface.
SEE ALSO
cgcreate(1), cgexec(1), cgget(1), cgclassify(1), lscgroup(1)


