Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, 29 November 2014

Clean-up unused Linux Kernels in Ubuntu

Original article by Mark McBride

At development I tend to keep more than one Virtual Machine sandboxes, normally Unix-based running on a Windows host (because of reasons), so from time to time I have to clean-up the garbage and maintain the user-disk cuota as low as possible to avoid eating up the VM drive.

The original author makes a pretty good explaination on the command sintaxis (basically list the kernels and strip-down recursively to usable name strings to uninstall them), so I'm just going to copy here the actual command:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge

Only one caveat: I removed the -y argument from the apt-get purge command to avoid eliminating automatically, instead you will get prompted to purge the listed kernels.  To check the used disk space:

$ du -h /boot --max-depth=0

Install Java JDK in Ubuntu

I recently had to install Java to be able to run Cooja properly, as surely I'm going to need this at any given moment when reinstalling, testing elsewhere, etc, I'm keeping the instructions here.

Taken from Ubuntu Guia.

Install Java Oracle version 8:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Check the current version

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)


You can select between any installed Java version at any given time

$ sudo /usr/sbin/update-alternatives --config java

There are 4 choices for the alternative java
  Selection    Path                                           Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java         1063      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java         1063      manual mode
  3            /usr/lib/jvm/jdk1.8.0/bin/java                  1         manual mode
  4            /usr/lib/jvm/jre1.7.0/jre1.7.0_51/bin/java      0         manual mode
Press enter to keep the current choice[*], or type selection number: