Привет, Апок. Спасибо за код. Я ни в чем тебя не виню, я знаю, что рисковал. Просто хочу понять, что я сделал не так, и предотвратить то, чтобы кто-то еще допустил такую же ошибку. Я попробовал запустить очищенную версию твоего файла, чтобы позаботиться о ядре в /usr/lib/modules и /boot, а также очистить репозиторий. В итоге в /boot и в /usr/lib/modules не осталось файлов; скрипт удалил все файлы ядра в обеих папках, но не тронул `.`. Это был (почти) пустой тестовый сервер, поэтому я перенесу VM из него, прежде чем попытаюсь перезагрузить его. У меня мало надежд на то, что он загрузится, если только кто-то не знает, как повторно заполнить обе папки. А как насчет файлов apt, которые он удалил? Ты думаешь, мне лучше отформатировать его и перестроить с нуля?
Вот код, который я запустил:
```bash
#!/bin/bash
################################################
# Cleanup Linux Installation
# Author: Thomas Burger
# Version 1.4
# Date: 2020-10-23
################################################
counter=0
### Cleaning up
clear
echo "### CLEANING UP LINUX INSTALLATION"
# /lib/modules AND /boot
kernelVersion=`uname -r`
myPath="/lib/modules"
echo "Cleaning up >$myPath<"
myPathContent=$null
myPathContent=`ls -1 "$myPath"`
for item in $myPathContent ;
do
if [[ "$item" == "$kernelVersion" ]] ;
then
#echo "break the loop"
break
else
#echo "delete >$myPath/$item<"
if ! [[ -d "$file" ]] ;
then
sudo rm -rf "$myPath/$item"
counter=$(($counter+1))
#boot files
correspondingBootFiles=`sudo find /boot | grep $item`
for bootItem in $correspondingBootFiles ;
do
#echo "delete >$bootItem<"
if ! [[ -d "$file" ]] ;
then
sudo rm -f "$bootItem"
counter=$(($counter+1))
fi
done
fi
fi
done
echo "Cleaning up configuration files from removed packages"
sudo dpkg -l | awk '/^rc/{print $2}' | sudo xargs apt-get purge -y
# update grub
echo "Updating grub"
sudo update-grub
# Cleanup apt cache
echo "Cleaning up apt-cache via apt-get"
sudo apt-get clean -y
sudo apt-get autoremove -y
```
Когда я запустил скрипт командой "sh ./clean_linux.sh", я получил ошибки на этих 3 строках:
```bash
if [[ "$item" == "$kernelVersion" ]] ;
if ! [[ -d "$file" ]] ;
if ! [[ -d "$file" ]] ;
```
Вот ошибки, которые я получил:
```
Cleaning up >/lib/modules<
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 153: [: not found
./clean_kernel.sh: 159: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
./clean_kernel.sh: 169: [: not found
```
Спасибо.