Elvenware

ConfigureLinux

Table of Contents

Configure Linux

I provide my students with a preconfigured version of Lubuntu. Nevertheless, there are various reasons why you might need to configure part or all of Linux box to use in one of my courses. This document is aimed to help both you and me configure Linux boxes.

NOTE: This document assumes that you are working with a VM I set up, or you are working in VM that has a relatively clean install of Ubuntu Server or Desktop, or you have created a new user on an Ubuntu Server or Desktop.

Your instance of Linux might be:

You might be trying to configure any one of the several varieties of Ubuntu, including:

As mentioned above, it is probably best if you are working in a VM or have a new user. Some of the steps in this process might impact the set up on an existing copy of Linux. I don't think any of the global installs (node, build essential) will cause harm in any normal setup, and most of the detailed work will affect only the current user.

Update the Machine

Our first job on a new install, and one that you should perform regularly after the install, is updating the OS. It is possible to have this done automatically, and in the Desktop versions there are tools to do it through the GUI called the Software updater. Nevertheless, I frequently do it by hand from the bash shell.

To update from the shell (command prompt), all you need do is issue the following two commands.

sudo apt-get update
sudo apt-get upgrade

The process listed above is simple to perform, and usually completes in only a few minutes or less.

Install gcc and make

Though not always necessary, it is a good idea to install to gcc and make. In particular, there are times when the VirtualBox Guest Additions appear to rely on having them installed. These utilities are not always needed, but I the need is just frequent enough to make it worthwhile installing them.

The steps are simple. You have probably already done the first two, but just in case, I will remind you to be sure your system is up to date before installing gcc.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential

Sometimes you see messages like "7 packages need to updated, 3 security updates" even after you have run the above commands. So long as it does not cause you to actually upgrade to a new version, you can try to fix those message with this command:

sudo apt-get dist-upgrade

JsObjects

Readers of this document should use Git to clone a read only copy of JsObjects:

git clone http://github.com/charliecalvert/JsObjects.git

More details are here.

Core Setup

The useful way to set up core parts of the the system quickly is with this script:

/JsObjects/Utilities/SetupLinuxBox/UbuntuAndCloudNineSetup

If you already have JsObjects setup, then this is an easier way to reach the script:

cd ~/Git/JsObjects/Utilities/SetupLinuxBox
./UbuntuAndCloudNineSetup

After running the script, do this: source ~/.bashrc.

At this stage you are done, and can leave this page.

One way to check the status of your system is with this script. Select at least the the e for essentials menu item:

$ELF_UTILS/SetupLinuxBox/SystemCheck

Ubuntu Versions

An upgrade from one release (version) to another, takes longer. For instance, moving from Ubuntu 13.10 to 14.04 takes a long time. That is natural, since it is a more complex process. It would be like upgrading from Windows Vista to Windows 8. Only without the financial cost, and usually without the hassle. Please note that on slow machines an upgrade from one release to another release can take several hours. Nevertheless, if you want to update from one version of the distro to the next version, then use this command:

do-release-upgrade

Ubuntu and Lubuntu ship twice a year, once in April and once in October. They use dates to track releases:

Every two years, on even years, in April, an LTS (Long Term Support) release is shipped. For instance, one was released in April of 2014: Ubuntu 14.04. The next LTS release should therefore come in April of 2016: Ubuntu 16.04. A corollary of this rule is that releases shipped in odd numbered years and in October are not LTS releases, and will therefore be maintained for only 9 months.

In general, it is always safe to stick with a relatively recent LTS version. If you are using one of the other versions, then you can expect to need to upgrade to a new version every six to nine months. I tend do track the latest relase, whether it is an LTS or not. There is nothing wrong with that approach in the context of our classroom. You just need to understand that it means you need to do relatively frequent upgrades.

Set up Environment

This section provides a step by step guide through a process that can be automated with the UbuntuAndCloudNine script found in the Core Setup section of this document.

At the bottom of your .bashrc place this:

if [ -z "$SSH_AUTH_SOCK" ] ; then
    eval `ssh-agent`
fi

# Basic Paths
export PATH=$PATH:$HOME/npm/bin
export JSOBJECTS=$HOME/Git/JsObjects
export NODE_PATH=:$HOME/npm/lib/node_modules    
export PYTHONPATH=${PYTHONPATH}:$JSOBJECTS/Python/:$JSOBJECTS/Python/Utils/:

# Java Path Support
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

# Android Path Support
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_PLATFORM_TOOLS="$HOME/Android/Sdk/platform-tools"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS:

# Other
export CHROME_BIN=/usr/bin/chromium-browser

After making this change, you need to process your updated .bashrc file:

source ~/.bashrc

I also maintain the code to code in .bashrc here.

Install Node

This section provides a step by step guide through a process that can be automated with the UbuntuAndCloudNine script found in the Core Setup section of this document.

The explanation is found here:

Install Geany

To get started configuring machine, you will probably want a reliable text editor. A good choice is Geany, which is the general purpose code and text editor we use in our course. We will also use WebStorm, Eclipse or some other IDE for heavy duty coding, but everyone needs a powerful text editor, and Geany is one of the best.

  1. Open up the Lubuntu Software Center.
  2. Search for Geany.
  3. Put it in the Apps Basket.
  4. Switch to the Apps Basket.
  5. Install Geany.

To install the markdown plugin for Geany:

sudo apt-get install geany-plugin-markdown

While you are in the Software Center, you will also likely want to to install:

Eventually, you will want to install LibreOffice, but it is probably better to set up Java first.

Shortcut way to install Geany, Meld and Chromium:

sudo apt-get install geany
sudo apt-get install meld
sudo apt-get install chromium-browser

Here is a more detailed overview of installing Geany through the software center:

From the Lubuntu menu choose System Tools | Lubuntu Software Center.

**Finding the Lubuntu Software Center**

In the Software Center, choose to install Geany. You can search for it by typing its name in the editor control on the right. Alternatively, look under the category in the Software Center called Developer Tools.

**The Lubuntu Software Center**

Put Geany in the Apps Basket. Switch to the Apps Basket view and choose Install Packages. (Remember that the default password for your copy of Lubuntu is the same as the user name.)

Install Git

The command to install git is simple:

sudo apt-get install git

Then create a directory called Git:

cd
mkdir Git
cd Git

Install Lamp

The explanation is found here:

Install SSH

On EC2, SSH is already installed. But on a fresh Ubuntu install, the steps are simple:

sudo apt-get install ssh

And then create a key pair for yourself by following the instructions found here:

Here is how to SSH to a remote machine:

ssh <userName>@<theServerYouWantToConnectTo>

For instance:

ssh ubuntu@192.168.1.23

This is an advanced trick, and not one that you necessarily want to use. You can use ssh-copy-id to install your public key in the authorized_keys file on a remote machine to which you already have access:

ssh-copy-id <userName>@<theServerYouWantToConnectTo>

On the server edit /etc/ssh/sshd_config and set Password Authentication to no.

Install OpenJdk

The following appears to work fine with Eclipse:

sudo apt-get isntall openjdk-8-jdk

Install Oracle/Sun Java

Setting up Java is optional on EC2 or other Ubuntu server instances, but it is usually required on Ubuntu or Lubuntu desktop because you need it for WebStorm.

Navigate to: ~/Git/JsObjects/Utilities/SetupLinuxBox

cd ~/Git/JsObjects/Utilities/SetupLinuxBox

Then run the the Java install script: ./InstallOracleJdk.sh

You will be prompted enumerable times and receive warnings of various kinds, (don't try to use the mouse, just enter or tab key) but if you just keep following the path of least resistance, it will eventually install. You can check your work by typing java --version

java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

Java usually gets installed in the /usr/lib/jvm directory.

The code found in my script probably looks like this:

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

And you can test it like this:

java -version

The reference for the above is here.

Install WebStorm

You can download WebStorm from the JetBrains site:

Please note that there is a student version of WebStorm and PyCharm. If you fill out the simple form on the JetBrains site, then you will quickly get permission to run these applications for free while you are a student:

When you launch WebStorm or PyCharm, you may be prompted to register. Choose Register and select JetBrains Account. If you are not prompted to register, then select Help | Register from the WebStorm menu.

NOTE: It is a bad strategy to use the trial period. Eventually it is expire, and then you will be unable to use the product until you properly register it. I have noticed that trial period tends to expire at inopportune times, such as during midterms or the night before an assignment is due. Get this taken care of now while you have time!

After downloading webstorm, you will need to decompress the package in which it came with a command like this:

tar xvfz ~/Downloads/WebStorm-X.X.X.tar.gz

For instance:

tar xvfz ~/Downloads/WebStorm-9.0.2.tar.gz

Then move the extracted files into the bin folder:

mv ~/Downloads/WebStorm-9.0.2.tar.gz ~/bin/webstorm

On Lubuntu, you should then place this file in the Desktop folder:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name[en_US]=WebStorm
GenericName=WebStorm with JavaScript support
Exec=/home/bcuser/bin/webstorm/bin/webstorm.sh
Terminal=false
Icon=/home/bcuser/bin/webstorm/bin/webide.png
Type=Application
Categories=Application;Development;
Comment[en_US]=Jetbrains JavaScript HTML

The process for install PyCharm is nearly identical, with only the obvious changes in name and path. I install PyCharm in:

~/bin/pycharm

Install Android SDK

Download the Android SDK for Linux.

Decompress the archive with a command similar to this:

tar xvfz android-sdk_r24.4.1-linux.tgz

Now create a home directory for Android:

mkdir ~/Android

Move the SDK into it:

mv android-sdk-linux/ ~/Android/Sdk

Assuming you have your path set up correctly in .bashrc, as explained above, then you simply type:

android

Because of space limitations, install as little as possible. In particular, you probably don't need the TV related modules, or probably the Atom modules.

Install MongoDb

We probably will not be installing MongoDb on our machines, but if you are curious, there is an explanation is found here:

Chrome Bin Setup

Don't do this on EC2, as you would not normally install Chrome on EC2 since there is no front end (GUI) for Ubuntu Server. But on Ubuntu and Lubuntu Desktop, it is needed in some circumstances related to development.

Under SystemCheck Common, this will fix CHROME_BIN errors.

Normally you would put this line near the bottom of ~/.bashrc.

export CHROME_BIN=/usr/bin/chromium-browser

After making the change run source ~/.bashrc.

NOTE: If you are trying to get SystemCheck to pass, then do your work in the same bash shell where you are running SystemCheck. In particular, exit the program, run the command, then run SystemCheck again.

Though the path rarely varies, to confirm the path to Chromium on your system, type which chromium-browser. Whether you specify the path to Chromium or Chrome is more or less optional. There is no wrong choice, it just depends on your preferences.