Skip to content

Instantly share code, notes, and snippets.

@syneart
Created May 17, 2016 13:10
Show Gist options
  • Save syneart/557921a7b4cd115427271ce3cfa3349d to your computer and use it in GitHub Desktop.
Save syneart/557921a7b4cd115427271ce3cfa3349d to your computer and use it in GitHub Desktop.
Remove all Ubuntu older linux kernels and Update to the latest kernel.
#!/bin/bash
clear
echo "Info: 移除和更新核心檔案需要權限, 請先輸入密碼 .."
sudo -v
if [ $? -eq 1 ]; then
clear
echo "Error: 未輸入正確密碼, 無法繼續執行"
sleep 3
exit 0
fi
clear
echo "Info: 正在移除舊核心, 請稍後 .."
sudo apt-get -y purge $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)
echo "Info: 正在更新新核心, 請稍後 .."
sudo apt-get update
sudo apt-get -y install linux-generic linux-headers-generic linux-image-generic
sudo update-grub
echo "Info: 更新完成!! 請手動重新開機 ~"
sleep 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment