LightLimit is an advanced CPU management tool for Linux systems that allows you to control CPU usage limits, set processor affinities, and monitor system resources with an interactive interface.
- CPU Usage Limiting: Cap total CPU usage for your system
- Core Affinity Control: Bind processes to specific CPU cores
- Interactive Monitor: Visual process manager with kill functionality
- System Information: View detailed CPU and memory statistics
- CGroup Management: Leverages Linux control groups for resource management
- Cross-Distribution Support: Works on Debian/Ubuntu, Fedora, Arch, and more
- Linux-based operating system
- Root privileges (for most functionality)
- GCC compiler
- ncurses development libraries
LightLimit includes an automated dependency detection and installation process:
git clone https://github.com/QKing-Official/lightlimit.git
cd lightlimit
make install-deps # Install dependencies for your distribution
make # Build the executable
make install # Install to /usr/local/bin (optional)If you prefer to install dependencies manually:
# Debian/Ubuntu
sudo apt-get install build-essential libncurses-dev
# Fedora/RHEL/CentOS
sudo dnf install gcc ncurses-devel
# Arch Linux
sudo pacman -S gcc ncurses
# Build and install
make
sudo make install # OptionalLightLimit provides several commands for managing CPU resources:
Usage: lightlimit COMMAND [ARGS]
Commands:
total <cpu_percentage> Sets total CPU limit for all processes (0-100%)
preference <core_list> Sets CPU affinity (e.g., '0,1,3')
reset Resets CPU limits and cgroup
info Displays CPU and memory info
monitor Interactive process monitor with task management
uninstall Removes the cgroup that lightlimit creates
help Displays this help message
Limit the system to use only 50% of available CPU resources:
sudo lightlimit total 50Restrict LightLimit to use only cores 0 and 1:
lightlimit preference 0,1Launch the interactive process monitor:
lightlimit monitorIn the monitor interface:
- Use arrow keys to navigate the process list
- Press
kto kill a selected process - Press
qto quit - Press
rto refresh manually
Display system CPU and memory information:
lightlimit infoRemove CPU limits and the cgroup created by LightLimit:
sudo lightlimit resetCompletely uninstall the tool:
sudo make uninstallLightLimit uses Linux control groups (cgroups) to manage CPU resources. The tool creates a cgroup at /sys/fs/cgroup/cpu/lightlimit to control CPU quotas for processes.
The interactive monitor provides real-time information about running processes, including:
- Process ID (PID)
- CPU usage percentage
- Memory usage percentage
- Memory consumption in MB
- Process command name
- Cgroups are usually available by default
- Make sure to run
make install-depsor installlibncurses-devmanually
- The cgroup filesystem might need to be mounted
- Requires the
ncurses-develpackage
- Install the
ncursespackage for the monitor functionality - The cgroup filesystem should be available by default
Most commands require root privileges. If you encounter permission errors, run the command with sudo.
If you get errors about missing cgroup files, make sure your system has cgroups enabled and mounted:
# For older systems (v1 cgroups)
sudo mkdir -p /sys/fs/cgroup/cpu
sudo mount -t cgroup -o cpu,cpuacct none /sys/fs/cgroup/cpu
# For systemd-based systems with cgroup v2
sudo mkdir -p /sys/fs/cgroup/cpuIf colors aren't displaying correctly:
- Ensure your terminal supports colors
- Try setting the
TERMenvironment variable:export TERM=xterm-256color
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository and create your feature branch from
main - Make your changes following our coding standards
- Add tests for any new functionality
- Ensure it works
- Submit a pull request with a clear description of your changes
For more detailed information, please read our Contributing Guidelines.