Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
脚本清理ubuntu的老内核:有错误求修正!!
Experiences and Insight
1032
views ·
3
replies ·
To
floor
Go
Coollove
deepin
2012-04-21 22:39
Author
#!/bin/sh
#
# 清理ubuntu的老内核
#sudo aptitude purge ~ilinux-image-.*\(\!`uname -r`\)
CURRENT="`uname -r | awk -F"-" '{print $1"-"$2}'`"
HEADERS=""
IMAGES=""
for HEADER in `dpkg --get-selections | grep ^linux-headers | \
grep -vE "(generic|386|virtual)" | awk '{gsub(/linux-headers-/,"",$1);print $1}'`
do
if [[ "$CURRENT" < "$HEADER" ]]
then
echo "正在运行的内核不是最新的。 $CURRENT < $HEADER"
echo "Running kernel is not the newest. $CURRENT < $HEADER"
exit 1
else
[[ "$CURRENT" != "$HEADER" ]] && {
HEADERS="${HEADERS} linux-headers-${HEADER}"
IMAGE="`dpkg --get-selections | grep ^linux-image | \
grep "${HEADER}" | awk '{print $1}'`"
IMAGES="${IMAGES} $IMAGE"
}
fi
done
if [[ x"$HEADERS" == x"" ]]
then
echo "没有要清理的老内核."
echo "No old kernel need to clean."
exit 0
fi
CMD="sudo apt-get purge $HEADERS $IMAGES"
echo "$CMD"
if [ "$1" == "-e" ]
then
sh -c "$CMD"
else
echo "请确定以上命令是否正确,然后输入 $0 -e 来执行以上命令。"
echo "Be sure this command is right, then type $0 -e to execute."
fi
Copy the Code
Reply
Like 0
Favorite
View the author
All Replies
cxbii
deepin
2012-04-22 02:00
#1
记得ubuntu tweak有这个功能,用它删除应该安全点
Reply
Like 0
View the author
tuhaihe
deepin
2012-04-22 23:20
#2
赞!最近正在学习脚本,这个可以拿来学习。
Reply
Like 0
View the author
cxbii
deepin
2012-04-23 01:15
#3
ok。修复好后
添加之推荐脚本!
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
Closing lid, but display still active.
Bluetooth not working after laptop suspend mode
keyring deepin password.. WTF... Not user friendly
UNABLE TO SYNC IN BRAZIL
Popular Events
More