ubuntu tweak will not clean kernel cruft

Asked by Simon Bateman

UBUNTU 12.04 LTS (precise) / Unity / Ubuntu Tweak 0.8.4.1 will not clean kernel 'cruft' - just scans and produces a long list of candidates for clearing and drops program - have just updated Tweak -- it did this in previous version but now 'offers' to send an ERROR LOG!

Lenovo 3000 G530 laptop
CPU Intel(R) Celeron(R)
RAM 960 Mb

I am JUST scanning for kernel 'cruft' -- ALL other scans have worked OK!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Mark Rijckenberg
Solved:
Last query:
Last reply:
Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#1

If you prefer to use the script below, you will first need to install ksh using this command:

sudo apt-get update && sudo apt-get install ksh

Then, as a workaround, you could use the following korn shell script to delete old Linux kernels:

I suggest saving the script below as the file removekernel.sh and then making the file removekernel.sh executable:

if [[ $1 == "" ]]; then
echo "List of currently installed kernel .deb packages:"
dpkg --list | grep linux-image | egrep '^[r,i]i' | cut -d" " -f3
echo "No argument added after removekernel command"
echo "Please enter kernel package to uninstall from your pc (for example: linux-image-3.9.0-030900rc5-generic) "
read KERNELVERSION

echo "Removing kernel package $KERNELVERSION"
apt-cache search $KERNELVERSION|cut -d" " -f1|xargs sudo apt-get remove -y

else
echo "Removing kernel package $1"
apt-cache search $1|cut -d" " -f1|xargs sudo apt-get remove -y
fi

Revision history for this message
Simon Bateman (batemans-25) said :
#2

On 01/05/13 12:06, Mark Rijckenberg wrote:
> Your question #227935 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/227935
>
> Status: Open => Answered
>
> Mark Rijckenberg proposed the following answer:
> If you prefer to use the script below, you will first need to install
> ksh using this command:
>
> sudo apt-get update && sudo apt-get install ksh
>
> Then, as a workaround, you could use the following korn shell script to
> delete old Linux kernels:
>
> I suggest saving the script below as the file removekernel.sh and then
> making the file removekernel.sh executable:
>
> if [[ $1 == "" ]]; then
> echo "List of currently installed kernel .deb packages:"
> dpkg --list | grep linux-image | egrep '^[r,i]i' | cut -d" " -f3
> echo "No argument added after removekernel command"
> echo "Please enter kernel package to uninstall from your pc (for example: linux-image-3.9.0-030900rc5-generic) "
> read KERNELVERSION
>
> echo "Removing kernel package $KERNELVERSION"
> apt-cache search $KERNELVERSION|cut -d" " -f1|xargs sudo apt-get remove -y
>
> else
> echo "Removing kernel package $1"
> apt-cache search $1|cut -d" " -f1|xargs sudo apt-get remove -y
> fi
>
thanks Mark - I have not used KORN shell since last millenium!

I get :
*removekernel.sh: 1: removekernel.sh [[: not found*

and thinks it must be removing a kernel package!
though I used cut & paste - I have double checked code

Looks promising though
Simon

Revision history for this message
Mark Rijckenberg (markrijckenberg) said :
#3

I suspect you executed the command ./removekernel.sh while being in a plain /bin/sh shell environment.

You need to execute the script in either the default bash shell or in a korn shell environment.

The [[ ]] syntax is valid in most Bourne-type Shells (bash, Posix, ksh etc.) EXCEPT the original Bourne Shell (which is /bin/sh).

Or you can add the following shebang line as the very first line in the removekernel.sh script:

#!/usr/bin/ksh

So /bin/sh is not korn shell (/usr/bin/ksh), but a plain shell.

Revision history for this message
Simon Bateman (batemans-25) said :
#4

On 02/05/13 20:31, Mark Rijckenberg wrote:
> Your question #227935 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/227935
>
> Status: Open => Answered
>
> Mark Rijckenberg proposed the following answer:
> I suspect you executed the command ./removekernel.sh while being in a
> plain /bin/sh shell environment.
>
> You need to execute the script in either the default bash shell or in a
> korn shell environment.
>
> The [[ ]] syntax is valid in most Bourne-type Shells (bash, Posix, ksh
> etc.) EXCEPT the original Bourne Shell (which is /bin/sh).
>
> Or you can add the following shebang line as the very first line in
> the removekernel.sh script:
>
> #!/usr/bin/ksh
>
> So /bin/sh is not korn shell (/usr/bin/ksh), but a plain shell.
>
That has fixed it [I was running 'sudo korn' when 'sudo bash' just worked!]

Nicer to have Ubuntu Tweak working, but until then I have put it in my
things to do list.

Thanks again Mark
Simon

Revision history for this message
Best Mark Rijckenberg (markrijckenberg) said :
#5

You're welcome.

Please set the thread status to 'solved' , if the issue is still solved.

Revision history for this message
Simon Bateman (batemans-25) said :
#6

Thanks Mark Rijckenberg, that solved my question.