linux修改内核禁用模块,(新增修改版)一个删除不用内核模块目录的小脚本,仅仅是为了自己方便。...

(新增修改版)一个删除不用内核模块目录的小脚本,仅仅是为了自己方便。

发布时间:2009-12-12 06:47:19来源:红联作者:一米短绳

[i=s] 本帖最后由 一米短绳 于 2009-12-12 15:24 编辑 [/i]

可以再加其它的东西,比如删除旧的/boot/下文件,旧的这个那个,昨天敲键盘频繁的我手麻,为了方便就写了这个小脚本。[code]#!/bin/bash

#Description:

# In order to be comvenient to delete the modules ,which is the old

# kernel's.It will detect "/lib/modules/x.y.z*" directory for removing

# each specified old modules.

#

#2009/12/12 一米短绳

#

PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

if [ "$1" ] ; then

version="$1"

else

read -p "Input the kernel version:" version

fi

if [ -d "/lib/modules/$version" ] ; then

echo "Remove the /lib/modules/$version?"

else

echo "$version is NOT exist! Exit!" && exit

fi

read -p "y or n ?" choice

if [ "$choice" == "y" ] ; then

rm -rf /lib/modules/$version && echo "Complete!"

else

echo "Script suspended!" && exit

fi[/code]再附上修改版,增加了选项功能,让我更爽~~哈哈 不用再输入挺长的version了。而且将目的目录由之前内定的/lib/modules/ 改写成一个变量来代替,这样可以把这个脚本再作点手脚,很简单的就能改成方便的交互式“rm“,免去了rm后面跟一堆文件名的麻烦。[code]#!/bin/bash

#Description:

# In order to be comvenient to delete the modules ,which is the old

# kernel's.It will detect "/lib/modules/x.y.z*" directory for removing

# each specified old modules.

#Tips:

# <1>...You can use the variable of "$1" in the script's options' region.

# (e.g.: ./**.sh 2.6.18.old , the variable of "$1" is "2.6.18.old" in this instance.) ;

#Option:

# ./**.sh ( OR "sh **.sh" )

# ./**.sh x.y.z ("x.y.z" is the old kernel's version)

#

#2009/12/12 一米短绳

#

PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

DIR_foe=/lib/modules/

if [ "$1" ] ; then

version="$1"

else

echo "This is a name-list of directory to contain kernel modules in your system curently."

ls -1 $DIR_foe | nl -s " ==> "

echo "You can select the number( in order to access easily)"

read -p "Remove number:" number

version=$(ls -1 $DIR_foe | sed -n "${number}p")

fi

echo $version

if [ -d "$DIR_foe$version" ] ; then

echo "Remove the $DIR_foe$version?"

else

echo "$version is NOT exist! Exit!" && exit

fi

read -p "y or n ?" choice

if [ "$choice" == "y" ] ; then

rm -rf $DIR_foe$version && echo "Complete!"

else

echo "Script suspended!" && exit

fi

[/code]下面是最终的执行效果图:

[attach]28517[/attach]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值