似乎無法刪除舊的 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 命令列刪除檔案和資料夾

相關內容