Ubuntu MATE Installation

Ubuntu Distributions

In this document, we use a 64-bit desktop installation for release of Ubuntu 18.04 called Ubuntu MATE which uses this ISO file:
ubuntu-mate-18.04-desktop-amd64.iso
Ultimately all Ubuntu distributions are the same underneath the hood, so to speak, but the chosen Desktop manager makes them look and feel different on the surface.

Installation and Initial Access

We'll work with a USB flash drive installation. BIOS choices often specify the boot order so that the hard drive will "come first" if it can boot.

Boot from USB flash drive

Shutdown the machine. Insert the USB flash drive. Turn on the machine and repeatedly type F12 until you see a boot choice menu. You're looking for these choices in the USB_KEY group:
Legacy: ...
UEFI: ...
What we do in this case is: These boot choices menu may be inconsistent across various systems.

Before you proceed further with the installation steps, you need to configure the networking. You will need to configure the machine's network settings prior to installation. For the WCU Computer Science Linux lab, you have to establish static IP addresses assigned to pre-configured DNS entries. In general, you could do this after the installation, but the student Linux system has only 8 DHCP addresses.

Network configuration (IP4)

Access the Network Manager. You can get it by clicking the networking icon in the upper panel and choosing Edit Connections. From here,
  1. Choose the Ethernet: Wired Connection 1 and double-click to edit.
  2. Select the IPv4 Settings tab. Select Manual as the desired Method.
  3. Click the Add button in the Addresses section. Enter the following information, tabbing from one the field to the next.
    Replace LAST_OCTET by the number given to you.
    Address:  144.26.62.LAST_OCTET 
    Netmask:  26    
    Gateway:  144.26.62.129
    
  4. In the DNS servers field, enter:   144.26.63.100, 144.26.63.101
  5. In the Search Domains field, enter:   cs.wcupa.edu
  6. Click Save then Close.
To make sure it takes, again clicking the networking icon in the upper panel and choose Wired Connection 1.

Installation Steps

Start by clicking the Install Ubuntu MATE button.
  1. Keyboard Layout. Take the default. Press Continue.
  2. Updates and other software. Take the preset choice:
    Normal installation
    Check both checkboxes:
    Download updates while installing Ubuntu MATE
    Install third-party software ...
    Click Continue.
  3. Installation Type. Make the choice which represents erasing the entire disk and installing.
    Erase disk and install MATE
    Press Install Now and Continue at the popup.
  4. Where are you? Probably the default. For us New York. Press Continue.
  5. Who Are You? This provides you with a login as a non-root administrative user:
    Your name: your full name (whatever you want)
    Your computer's name: MACHINE
    Replace MACHINE by the machine name given to you.
    Ignore any message: "That name already exists on the network."
    Pick a user name: LOGIN
    Replace LOGIN by a suitable non-root account name on your machine.
    Choose a password: A password known only to you.
    Confirm your password: Re-type it.
    Keep the other default settings. Press Continue to finish the information Ubuntu needs.
  6. Restart.. The whole installation process is very short. At the end remove the flash drive and press Enter.

Initial Access

When your computer boots up again, log in.

Initial Software Update

You should see the Softare Updater on the bottom toolbar. Click to open, and the Install Now.

Browser and Course Website

Open the Firefox browser, which is already installed in the top panel. It is is intended that you follow along through the experiments in the course documents like this one by viewing them through the browser. The documents often contain hyperlinks and the code can often by copied and pasted. Enter the course URL:
https://www.cs.wcupa.edu/rkline/csc586
Add it as a bookmark and access this installation document on-line.

Terminal

The second most useful thing is a terminal shell. Get things going by finding the MATE Terminal through
Menu ⇾ System Tools ⇾ MATE Terminal
Right-click on the menu choice. It gives you these options: Another alternative, which I prefer, is to pin it to the top Panel. All you have to do is drag the menu item itself into the top Panel.

Within the terminal, install the "ifconfig" utility and check the network address:
$ ifconfig eno1
Look for the "inet" line to confirm the IP address setting.

IP6 Network Configuration

Access the Network Manager. You can get it by clicking the networking icon in the upper panel and choosing Edit Connections. From here,
  1. Choose the Ethernet: Wired Connection 1 and double-click to edit.
  2. Select the IPv6 Settings tab. Select Manual as the desired Method.
  3. Click the Add button in the Addresses section. Enter the following information, tabbing from one the field to the next.
    Replace LAST_OCTET by the number given to you.
    Address:  2605:0:103:200:144:26:62:LAST_OCTET
    Netmask:  64
    Gateway:  2605:0:103:200::1
    
  4. Click Save then Close.
Make sure it takes, again by clicking the networking icon in the upper panel and choosing Wired Connection 1.

Check your work by:
$ ifconfig eno1
Look for the second "inet6" entry.

Check network connectivity from taz

From a shell on your machine:
$ ping taz     (not fully qualified should be OK: Ctrl-C to stop)
$ ping6 taz
Log into taz from a shell:
$ ssh TAZ_LOGIN@taz     (ssh login to taz)

[taz]$ ping MACHINE 
[taz]$ ping6 MACHINE

Basic Configuration

Update, Upgrade

Often the Update Manager will automatically open when the system needs to be updated. Just follow it through. You can also update through a terminal shell, which is particularly useful for remote access. Start like this
$ sudo apt update
$ sudo apt upgrade
You won't always have to reboot, but you do so if there are updates to the kernel or to an SSL package. If so,
$ sudo reboot
Yet another similar (but not entirely) shell-based package manager is aptitude. Install it by:
$ sudo apt install aptitude
You can use aptitude in the way apt is used.

Package installations

The apt (or the near equivalent, apt-get) command is universally used to dictate necessary package installations:
$ sudo apt install some-package-1 some-package-2 ...
...
Do you want to continue: [Y/n]? ENTER
To omit the installation query, do:
$ sudo apt install -y some-package-1 some-package-2 ...
To search for, and/or get further information about installation packages there are other better graphical tools:
Administration ⇾ Software Boutique
Administration ⇾ Software Updater
Administration ⇾ Software & Updates
The "apt" approach is pedagogically better because it does not depend on the window manager and relevant GUI software presentations.

Other packages

An important installation is to set up external access through secure shell, so do:
$ sudo apt install ssh
Although not necessary, we might as well install the basic development packages:
$ sudo apt install manpages-dev build-essential
Many people prefer Chrome to Firefox, so install that for an alternative:
$ sudo apt install chromium-browser

Using a shell-based editor

Because of the common root-based low-level editing required of an administrator, possibly through a secure-shell connection, it is important that you be able to use a shell-based editor, typically either: If you have never used vi, I recommend using nano, at least initially. For the sake of definiteness, I will assume that you are using nano. If you want to use vim, simply substitute it throughout.

One useful feature of both of these editors is that you can create a file by editing it.

The files you own (initially) are all in the machine folder:
/home/LOGIN
Non-administrative users know only this as their "world" on a Linux machine. You can edit/create a FILE by doing:
$ cd  /path/to/
$ nano FILE
or
$ nano /path/to/FILE

Of course, the "/path/to" part is usually a path relative to their home directory (known a "~" in Linux) of the form:
~/relative/path/to/
Whenever you edit an administrative file (typically anything not in your home directory), preface the command with sudo, i.e.:
$ sudo nano file-or-path

Secure the login greeter

$ sudo nano /usr/share/lightdm/lightdm.conf.d/50-ubuntu-mate.conf
You should see this initial content:
[Seat:*]
user-session=mate
Add three more lines, getting:
[Seat:*]
user-session=mate
allow-guest=false
greeter-hide-users=true
greeter-show-manual-login=true
You need to reboot the system to have this take effect, so
$ sudo reboot

The vim editor

You can skip this section (at least for now) if you plan on using nano.

Ubuntu Desktop installs a minimal version of vim, /usr/bin/vim.tiny which is accessible only through the "vi" command. Install the improved version and its documentation:
$ sudo apt install vim vim-doc
After installation, both the vi and vim commands access the newly installed /usr/bin/vim.basic. Ubuntu keeps track of alternative versions through a symbolic linking scheme maintained by the update-alternatives command. You can see the "vi" and "vim" alternatives by typing:
$ update-alternatives --display vi
$ update-alternatives --display vim
Some basic vim operations are:
i, o, a:     enter insert mode from command mode
Esc:         leave insert mode
:            give a line command
:q!          quit without saving changes
:w           save changes
:x           save changes and quit (also :wq)
Learning vim requires some practice. It probably is worth your while to run:
$ vimtutor

vim global settings

vim's features, for all users, can be controlled in the global features file /etc/vim/vimrc. I highly recommend that you enable the following vim feature. It gives the ability to edit files repeatedly and never lose your place. Edit the global vim config file:
$ sudo vim /etc/vim/vimrc
If you scroll down, you'll see the syntax highlighting already "turned on" in the lines
if has("syntax")
  syntax on
endif
After these lines look further for the lines:
"if has("autocmd")
"  au BufReadPost * if line .....
"endif
The initial double-quote character is a line comment. Remove it from these three lines. vim "remembers" the files you have edited in the hidden ~/.viminfo file.

vim personal settings

If you want your own personal settings, add these into your own personal ~/.vimrc file:
$ vim ~/.vimrc
A very useful addition is this, which makes vim more usable:
set tabstop=4 shiftwidth=4 expandtab
Another possibility is create automatic line numbering in files with:
set number
This, however, can be an annoyance sometimes, so it might be easier to turn it on/off using these commands when running vim with these commands:
:set number
:set nonumber

GUI Editor

We discussed vim and nano above. It is essential that you be able to use one of these. Both support syntax colorization although nano relies on the file extension to engage the colorization whereas vim is more sophisticated.

The gedit editor

In many cases a simple graphical editor is a good choice. The one which comes with Ubuntu MATE is called pluma; however, a more well-known, effectively equivalent editor is gedit, but it must be installed. A good idea is to also install the plugins which come with it:
$ sudo apt install gedit gedit-plugins
Both text editors can be invoked through the menu system by:
Accessories ⇾ Pluma
Accessories ⇾ Text Editor
The gedit editor seems to have a richer support, so I'll use this one. For the most part, you can use gedit as a replacement for nano wherever I use nano in the notes.

These editors, as well as other Linux graphical editors, can be easily invoked from the shell, which is sometimes easier than crawling through graphical file structure. For example, try:
$ gedit ~/.bashrc
Again, remember to preface with sudo to edit administrative files:
$ sudo gedit /path/to/SOME_ADMIN_FILE
You can run the terminal shell concurrently with the editor if you run this command in the background like this:
$ gedit ~/.bashrc &
[1] PID
$ 
The shell prints a "job number" with the editor's process id (PID) and then gives you back the shell. Sometimes, due to glitches or whatever, the graphical application invoked generates warning messages, which will be displayed in the shell itself. To avoid seeing these messages, a more lengthy alternative is one which redirects standard error into the "black hole" file /dev/null:
$ gedit ~/.bashrc 2>/dev/null &
An even better idea is to disconnect the GUI editor from the terminal shell so that you can close the terminal shell without closing down the editor. To do so use the nohup command:
$ nohup gedit ~/.bashrc 2>/dev/null &

Make gedit the default text editor

Install gnome-open. This is the equivalent of open on MAC OS X.
$ sudo apt install libgnome2-bin
To bring up a file in a GUI window you can do this:
$ gnome-open .    (open the current directory)
Then double-click to open a selected file, say, SOMETHING.txt. Alternatively, you can do it from the shell:
$ gnome-open SOMETHING.txt
There are default applications for most files on the system. The default for text files is Pluma. If you want to make the default be gedit, then invoke:
Preferences ⇾ Preferred Applications
Choose the System tab. Pick the one you want from the drop-down list for Text Editor. The name for gedit is the obvious choice gedit Text Editor.

Instructor admin account

This is just a convenience for the instructor to be able to access your system if necessary. Creating the instructor user as follows. In the shell dialog, type Enter for all prompts except for the password entries. Look at the sheet I gave you for the INSTRUCTOR_PASSWORD.
$ sudo adduser instructor
Adding user `instructor' ...
Adding new group `instructor' (1001) ...
Adding new user `instructor' (1001) with group `instructor' ...
Creating home directory `/home/instructor' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:   INSTRUCTOR_PASSWORD
Retype new UNIX password:  INSTRUCTOR_PASSWORD
passwd: password updated successfully
Changing the user information for instructor
Enter the new value, or press ENTER for the default
    Full Name []: 
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] 
Then give sudo privileges by adding the newly created user to the sudo group:
$ sudo adduser instructor sudo

Verify and let me know

Verify what you've done.
LOGIN@MACHINE:~$ su - instructor
Password: INSTRUCTOR_PASSWORD
instructor@MACHINE:~$ sudo su
[sudo] password for instructor: INSTRUCTOR_PASSWORD
root@MACHINE:/home/instructor# 
Exit twice (or ^D) to get back to original shell.

When you've completed this, please inform so I can test it.

Linux Account Information

To understand linux accounts a little better, do
$ ll /home
to see the homes of all users with their default permissions. Then look at the relevant administrative entries:
$ sudo egrep '(LOGIN|root)' /etc/{passwd,group,shadow}
A standard Linux user account has these features which establish its credentials: Compare the group listing to that of your login:
$ grep LOGIN /etc/group
Observe that you have many more entries. These extra entries make you a "member" of a group, thus giving you extra privileges. These group memberships establish you as an official "non-root administrative user" who can do things that other non-root users cannot do. For example, by virtue of being a member of the sudo group, you are permitted to use the sudo command.

Set the root password

You almost never need the root password in an Ubuntu system since all administrative actions can be effected through sudo. However, setting it to your password gives you another access in case something goes wrong.
$ sudo passwd root
Enter new UNIX password:  YOUR-LOGIN-PASSWORD
Retype new UNIX password: --- repeat ---
passwd: password updated successfully
Test it out by doing "full root login"
$ su -
Password: YOUR-LOGIN-PASSWORD
# 

SSH root access restriction

The default setting specifying the accessibility by root is seen in this line in /etc/ssh/sshd_config
$ sudo grep prohibit /etc/ssh/sshd_config 
#PermitRootLogin prohibit-password
This means you cannot access SSH into your machine as root by giving a password. You can do so using cryptographic keys. The initial "#" indicates that this setting is the default for ssh.

The taz ssh tunnel

Your machine is only accessible within the WCU Linux cluster, in particular from the public student Linux server, taz. Nevertheless, with some preparation, you can access your lab machine through clients such Remote Desktop external to the Linux cluster. The gimmick is to use port forwarding through SSH to create a tunnel from your local client through taz's SSH port (22) to the target port (i.e. service) on your lab machine.

Choose unused ports which to forward to ports on MACHINE through taz. You want port numbers greater than 1024. Windows may ask you to verify this usage with respect to the its firewall. For definiteness I have chosen these:

SSH Clients

An SSH client can get you to taz, and from there to your lab machine. A more significant role is to create a tunnel through taz, so you need such a client with this capability. Here are some possibilities:
  1. Windows PuTTy Secure Shell. PuTTy is "portable executable" which needs no installation.
  2. Windows Cygwin Shell. I highly recommend installing this as a complement to what you learn in this course. It is a UNIX-like environment offering a decent BASH shell for Windows and a replacement, in most circumstances, for the miserable Windows built-in Command Shell. The initial Basic Installation section from the online document is sufficient. Just make sure that ssh is installed.
  3. MAC/Linux: You already have a decent terminal shell running bash with SSH installed (or easily install-able).

Tunnel setup with PuTTy on Windows

It is possible that Windows will make you confirm the usage of this port as administrator. Run PuTTy and follow these steps:
  1. Type taz.cs.wcupa.edu into the Host Name field
  2. Type MACHINE_tunnel in the Saved Sessions field and click Save
  3. Go to Connection ⇾ SSH ⇾ Tunnels
  4. Enter 2001 in the Source port field
  5. Enter MACHINE:3389 in the Destination field
  6. Click the Add button. It should create an entry:

    L2001   MACHINE:3389
    
  7. Repeat steps 4, 5, 6 two more times creating these additional forwards:
    L2002   MACHINE:22
    L2003   MACHINE:80
    L2004   MACHINE:4000
    
  8. Go back to the Session and click Save. The tunnel is set up.
  9. Click Open.
  10. Log into taz using your taz account information. The tunnel is now active.
With this done, the only steps necessary to "Activate the Tunnel" in the future are:

MAC, Linux, Windows+Cygwin Tunnel

This approach works as long as you have a UNIX-like shell and your system runs ssh. So it is suitable for MAC, Linux, Windows/Cygwin with ssh installed.

First check that the ~/.ssh directory exists and create it if not:
$ mkdir -p ~/.ssh
To prepare the tunnel, edit or create the file ~/.ssh/config, adding this content:

~/.ssh/config
Host MACHINE_tunnel
  Hostname taz.cs.wcupa.edu
  User TAZ_LOGIN
  LocalForward 2001 MACHINE:3389
  LocalForward 2002 MACHINE:22
  LocalForward 2003 MACHINE:80
  LocalForward 2004 MACHINE:4000
Activate the tunnel from a Terminal shell by logging into taz in this way:
$ ssh MACHINE_tunnel
Give your taz password for the password prompt and leave the shell open throughout the remote desktop session.

Remote Desktop Access

Server setup

Install these packages:
$ sudo apt install xrdp vino

Remote Desktop Client information

Get the tunnel going and then establish one of these client connections:

x2Go

Having the X session from you lab machine displayed on your client is an alternative approach to using Remote Desktop. There are a number of solutions, but the one I'm describing here is:
x2go
We'll describe how to set up the server side and explain the client side for Windows, MAC and Linux.

Server side

Log in to your lab machine and make the following installations. First you have to add this package repository:
$ sudo add-apt-repository ppa:x2go/stable
It will query you to commit; just type Enter. Then update to pick up the new available packages and do the installation:
$ sudo apt update
$ sudo apt install x2goserver x2goserver-xsession x2gomatebindings
To get MATE desktop to work, edit your ~/.profile file:
$ nano ~/.profile
Append these lines to the end of the file:

~/.profile (append)
export GSETTINGS_SCHEMA_DIR=/usr/share/mate:/usr/share
export XDG_DATA_DIRS=/usr/share/mate:/usr/share
In general, you would make these accessible to all users, but since you're the only user, this suffices.

Client side

From the main x2go site, follow the links in the GetX2Go section at the top and install:
Download X2Go Client, either:
Windows installer (XP and Later), or
OS X 10.6 and higher DMG, or
OS X 10.9 and higher DMG
As mentioned, OS X uses the XQuartz package.

For Ubuntu client machines, there is an available package:
$ sudo apt install x2goclient
The clients are going to the local port 2022 to the SSH port 22 on the lab machine. Create a new session entry with this information and then click OK.
Session name: MACHINE 

Host:      localhost
Login:     LOGIN 
SSH port:  2002 

Session type:

To activate, click on the session from the right-hand side. Key in the password to MACHINE, and click OK. The "800x600" size is not a restriction, you can enlarge it.

No Machine NX

This is the Cadillac of the remote access software. It's just like being there. The software you need is here:
https://www.nomachine.com/
There is are packages for both Ubuntu and MacOSX/Windows which you should install, resp., The one package provides both the client and server parts.

tunnel

The tunnel should be through port 4000, which we've already set up to be local port 2004.

NX connection

Start making a new connection from the client. Many of the steps in establishing the are instructional, just "Continue" on. At one point you'll want to create the actual connection; use this:
protocol: NX
host: localhost
port: 2004
Use the default "Password" authentication. Make the name of the connection be "MACHINE".

Prior to activating the connection, activate the tunnel. Follow through some more steps, the most important is providing login/password information. Afterwards, there are a number of steps to set up the display. You can "OK" your way past these, at least the first time.

At the end of the steps, you'll get the MACHINE login screen.

Discussion

Package Management

It is, obviously, useful to get information about installed and available packages on any operating system. The most basic informational command for Ubuntu are dpkg and apt-cache. For example, this gives a listing of all installed packages
$ dpkg -l
It's often useful to pipe this through grep to find specific matches, like:
$ dpkg -l | grep mate
With the capital "-L" option, you get information about a specific installed package:
$ dpkg -L bash
To find the installed package which contains a certain file, use the "-S" option:
$ dpkg -S /bin/cat 
The apt-cache command is used for finding information about all packages, installed or not. For example
$ apt-cache search bash
What it is finding is any package with "information about" bash. Specifically, one of the entries is the (not-installed) yash package. If you do:
$ apt-cache show yash
you'll see a reference to bash in the description.

To search for files in all available packages you need to install the apt-file command like this:
$ sudo apt install apt-file
$ sudo apt-file update
Once complete, here is an sample search:
$ apt-file search /*/date

System directories and disk partitions

UNIX-like systems use path-based directory organizations with/ (root) at the top. These are common directory usages:
/etc:              configuration files
/dev:              device files
/lib, /usr/lib:    dynamic libraries (".so"), the kernel modules
/proc:             process information (this is a proc filesystem)
/bin, /usr/bin:    programs
/sbin, /usr/sbin:  static programs — don't use dynamic libraries
/usr/share:        package configuration files
/boot:             kernel and boot files
/lib/modules:      kernel modules
/home:             user directories
/root:             home directory for the root user
/media:            user-mountable devices (USB,CDROM)
/usr/local, /opt:  non-package software locations
/tmp:              world writable holding temporary files
/var:              system logs, print spool files, cached files, email, etc.
/usr/include:      system software header files
The du command can be used to find out the size of a directory. It is usually a good idea to use the -h option to simplify the size information:
$ du -h /usr/bin
Files reside on the hard disc(s) within partitions. Any Linux installation requires at least two partitions: A disk partition hold files by being associated to a directory within the path hierarchy with an operation called mounting. In this case it is called a file system. The low-level utilities parted and fdisk are used to view and manipulate these partitions, although nothing can be done to a mounted partition which is in use. You can see the partition choices made by the Ubuntu installer (on an 80GB drive) via:
$ sudo parted /dev/sda print
..
Number  Start   End     Size    Type      File system     Flags
 1      1049kB  77.9GB  77.9GB  primary   ext4            boot
 2      77.9GB  80.0GB  2100MB  extended
 5      77.9GB  80.0GB  2100MB  logical   linux-swap(v1)

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/sda1        72G   21G   48G  31% /
...
Intel-based systems support up to four primary partitions numbered 1-4. One of these can be an extended partition which permits unlimited so called logical partitions numbered upwards from 5. The partition which contains the kernel and other boot files (in Linux, the /boot subdirectory) must reside on a primary partition.

Our default Ubuntu installation uses the minimal partitioning described above with partition #1 mounted on root and partition #5 the swap space. The size of the swap space is commonly related to the size of RAM. You can compare these by: typing:
$ free -h
Making the swap size equal to the RAM size makes sense for hibernation, where we need to store the contents of RAM onto the disk.


© Robert M. Kline