Linux command
purge-old-kernels 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Remove old kernels, keeping the default 2 most recent
sudo purge-old-kernels
Keep a specific number of old kernels
sudo purge-old-kernels --keep [3]
Simulate removal without making changes
sudo purge-old-kernels -s
Remove old kernels without prompting for confirmation
sudo purge-old-kernels -y
说明
purge-old-kernels removes old Linux kernel and header packages from Ubuntu and Debian systems to reclaim disk space, particularly in the /boot partition. Over time, kernel upgrades accumulate previous versions that are no longer needed, and this utility automates their safe removal. It will never remove the currently running kernel. By default the tool keeps the 2 most recent kernels, configurable with the --keep option. Any additional arguments are passed directly to apt-get(8), so -s can be used for dry-run simulation and -y to skip confirmation. The command is part of the byobu package on Ubuntu/Debian systems and requires root privileges. Note: This utility is now deprecated. Its functionality is expected to be integrated into apt(8).
参数
- --keep _N_
- Number of old kernels to keep. Defaults to 2.
FAQ
What is the purge-old-kernels command used for?
purge-old-kernels removes old Linux kernel and header packages from Ubuntu and Debian systems to reclaim disk space, particularly in the /boot partition. Over time, kernel upgrades accumulate previous versions that are no longer needed, and this utility automates their safe removal. It will never remove the currently running kernel. By default the tool keeps the 2 most recent kernels, configurable with the --keep option. Any additional arguments are passed directly to apt-get(8), so -s can be used for dry-run simulation and -y to skip confirmation. The command is part of the byobu package on Ubuntu/Debian systems and requires root privileges. Note: This utility is now deprecated. Its functionality is expected to be integrated into apt(8).
How do I run a basic purge-old-kernels example?
Run `sudo purge-old-kernels` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --keep _N_ do in purge-old-kernels?
Number of old kernels to keep. Defaults to 2.