似乎无法删除旧的 Xubuntu 内核,我收到错误,提示目录不为空,或者我没有权限删除它

似乎无法删除旧的 Xubuntu 内核,我收到错误,提示目录不为空,或者我没有权限删除它

我是 Linux 新手,所以可能需要一些 ELI5 语言方面的帮助。我的磁盘空间不足。我看到很多不再需要的旧内核,但我似乎无法删除它们。

当我尝试这个时:

sudo apt clean && sudo apt autoclean && sudo apt autoremove -y

我明白了:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 107 not upgraded.

之后仍有许多内核残留。当我尝试手动删除它们时,使用以下命令:

sudo apt-get autoremove linux-image-4.4.0-31-generic

当我手动执行此操作时,我得到了以下信息:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  linux-image-5.15.0-41-generic*
0 upgraded, 0 newly installed, 1 to remove and 107 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 260814 files and directories currently installed.)
Purging configuration files for linux-image-5.15.0-41-generic (5.15.0-41.44~20.04.1) ...
rmdir: failed to remove '/lib/modules/5.15.0-41-generic': Directory not empty

我不认为该目录是空的,因为仅这个特定目录就占用了 1.6gb。请参阅此处的屏幕截图。

有人能帮我弄清楚如何删除这些旧内核吗?它们似乎占用了很多空间,而我只剩下 2 GB 了!

答案1

sudo -i
rm -r /lib/modules/5.15.0-41-generic

删除命令:

rm [option] FileOrFolderName

使用递归选项(以 -r 表示)删除目录及其内容。以下命令显示如何删除 Simple-Directory 及其内容:

rm -r Simple-Directory

有关的:如何使用 Linux 命令行删除文件和文件夹

相关内容