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:

Running on hardware as the primary operating system.

Running in VirtualBox or VmWare

Running in EC2

Running somewhere else.

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

Ubuntu Desktop

Ubuntu Server

Ubuntu Minimal

Lubuntu

And to a large degree, even the Ubuntu flavored Mint releases.

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.

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-getdist-upgrade

On completion, there are sometimes old files, particularly linux-header and linux-image files, that are no longer needed. To remove them run the following command:

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.

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:

One of things this script does is clone my massive and disorganized JsObjects repository. If you want a more simplified view of this repository, see the SimpleView branch.

cd ~/Git/JsObjects
git checkout SimpleView

To return to the normal view:

git checkout master

Configure Ubuntu Setup

After you reboot, run UbuntuSetup. You now have JsObjects installed so there is an easy way to run the script:

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

NOTETyping slb should also take you to the SetupLinuxBox directory.

The UbuntuSetup script displays a simple menu. From the options available, select:

a) Run All (Basic and Node Related)

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

Though this is probably more than a bit out of date, you can check the status of your system is with this script. Select at least the the e for essentials menu item:

$ELF_UTILS/SetupLinuxBox/SystemCheck

At this stage you are done, and most readers can leave this page. Go back to whatever assignment sent you here. Your system is (hopefully) now properly configured.

NOTE: This is really the end of the Core Setup section. If you ran UbuntuSetup, then you are done. You don't need to read any more of this document unless you are trying to troubleshoot some problem.

Ubuntu Versions

NOTE: This is not part of the core setup. See the note at the end of the previous section.

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:

Ubuntu 13.04: Shipped April, 2013

Ubuntu 13.10: Shipped October, 2013

Lubuntu 15.04: Shipped April, 2015

Ubuntu 15.10: Shipped October, 2015.

And so on...

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.

LTS: 5 Years of maintenance. Shipped in April of even numbered years.

Other: 9 Months of maintenance. Shipped in October of each year.

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 UbuntuSetup script found in the Core Setup section of this document.

Update NPM

If you are using the one in /usr/bin/npm delete it and optionally create a symbolic link to the one in your npm directory. It might be something like this:

sudo rm /usr/bin/npm

Then, optionally, you can do this:

sudo ln -s ~/npm/bin/npm /usr/bin/npm

This symbolic link doesn't really help that much, but it doesn't hurt either. I think it is simpler to not create the link for /usr/bin/npm because then which npm points at your local version of NPM.

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.

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

From the Lubuntu menu choose System Tools | 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.

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.)

SSH Copy Id

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>

This will, by default, put id_rsa.pub in the authorized_keys file of the remote machine.

To copy a specific public key:

ssh-copy-id -i ~/.ssh/<public-key><username>@<hostname>

For instance:

$ ssh-copy-id -i Prog272-Calvert bcuser@192.168.2.16
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "Prog272-Calvert.pub"
/usr/bin/ssh-copy-id: INFO: attempting tologinwiththe new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
bcuser@192.168.2.16's password:
Number of key(s) added: 1
Now try logging intothe machine, with: "ssh 'bcuser@192.168.2.16'"and check to make sure that only the key(s) you wanted were added.

Optionally, 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

Install WebStorm

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:

Install MongoDb

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.

exportCHROME_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.