Ubuntu Desktop Installation

Ubuntu Distributions

The Ubuntu Linux distribution offers desktop versions for both 32-bit and 64-bit machines and server versions only for 64-bit machines. Currently 64-bit desktops more common than not. In this document, we use a non-standard installation for release of Ubuntu 16.04 called Ubuntu MATE which uses this ISO file:
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. Ubuntu's preferred Desktop manager is called Unity, but there are MANY other possibilities: This just scratches the surface. There are many other variations, like Lubuntu, based on the lightweight LXDE window manager.

Installation and Initial Access

We'll work with a USB flash drive installation. Booting from a flash drive is commonly supported these days. BIOS choices 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.

There boot choice menu is inconsistent across systems, apparently, even these lab systems. What you want is: One possibility is that a secondary boot menu gives you this choice. Another possibility is that you actually boot up to a graphical presentation with a choice of popups:
Try Ubunutu MATE   or   Install Ubuntu MATE

Clear the disk

I've had mixed results with installing this UBUNTU MATE 16.04 on top of a previous Ubuntu installation, so it seems better to start with the hard disk cleared. However you do so, get to
Try Ubunutu MATE.
Then proceed as follows:

Network configuration

Next time up, make the Install choice going all the to
Preparing to Install Ubuntu MATE
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.

Access the Network Manager. You can get it by right-clicking the networking icon in the upper panel and choosing Edit Connections; or from the menu: System ⇾ Administration ⇾ Network. From here,
  1. Choose the Ethernet: Wired Connection 1 and select 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 through the fields.
    Replace LAST_OCTET by the number given to you.
    Address:  144.26.62.LAST_OCTET 
    Netmask:  26    
  4. In the DNS servers field, enter:,
  5. In the Search Domains field, enter:   cs.wcupa.edu
  6. Click Save then Close.

Installation Steps

  1. Preparing to install Ubuntu MATE. Check both checkboxes:
    Download updates while installing Ubuntu MATE
    Install third-party software for graphics and Wi-Fi hardware, Flash, MP3 and other media
    Click Continue.
  2. Installation Type. Make the choice which represents erasing the entire disk and installing Ubuntu.
    Erase disk and install MATE
    Press Install Now and Continue at the popup.
  3. Where are you? Probably the default. For us New York. Press Continue.
  4. Keyboard Layout. Take the default. 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. Welcome to Ubuntu MATE. Wait for the installation to complete and watch the ads go by; the whole process is very short. At the end click the Restart Now button. Press ENTER to confirm reboot and remove the Flash drive.

Browser and Course Website

When your computer boots up again, log in. 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:
Add it as a bookmark and access this installation document on-line.

Install Chrome

Many people prefer Chrome to Firefox, so install that for an alternative:
$ sudo apt-get install chromium-browser


The second most useful thing is a terminal shell. Get things going by finding the MATE Terminal through
Applications ⇾ System Tools ⇾ MATE Terminal
Right-click on the menu choice. It gives you the option to add it to the Panel or add to the Desktop. I would recommend adding it to the Panel to make it convenient to use as possible.

Inhibit auto-resize on top edge

By default, the window manager automatically resizes a window to full screen when it touches the top edge. Personally I dislike this, and it's easy enough to resize it to full screen anyway. To prevent this behavior:

Basic Configuration

Update, Upgrade, Package installations

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-get update
$ sudo apt-get install aptitude
$ sudo aptitude upgrade
The aptitude command offers a more complete upgrade, specifically allowing you to upgrade the kernel. If we do a kernel upgrade, we would want to reboot the system. We'll be doing a reboot at the end of this section, anyway.

For most upgrades, this will work equally as well:
$ sudo apt-get upgrade
The aptitude command, however offers an effective replacement of apt-get, i.e., you can do:
$ sudo aptitude update
$ sudo aptitude upgrade
The apt-get command is universally used to dictate necessary package installations:
$ sudo apt-get install some-package-1 some-package-2 ...
Do you want to continue: [Y/n]? ENTER
To omit the installation query, do:
$ sudo apt-get 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:
System ⇾ Administration ⇾ Software Boutique
System ⇾ Administration ⇾ Software Updater
System ⇾ Administration ⇾ Software & Updates
The "apt-get" approach is pedagogically better because it does not depend on the window manager and relevant GUI software presentations.

ssh and development packages

An important installation is to set up external access through secure shell, so do:
$ sudo apt-get install ssh
Although not necessary, we might as well install the basic development packages:
$ sudo apt-get install manpages-dev build-essential


A useful feature found in modern window managers is the ability to easily find application based on matching a name entered by the user. A decent application called Synapse is already installed.

You can then find it the Accessories menu and use it from there, or drag it to the top menu bar for easier use.

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:
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
$ 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:
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

Set umask

Your first task with an editor is to modify user-based umask value so as to ensure that certain files we create have the correct permissions. Open a terminal shell. First see what they are by default:
$ umask
In your home directory, find the file .profile and edit it.
$ cd
$ ls -a
$ nano .profile
Look for the lines:
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
Uncomment the line:
umask 022
The effect will not take place until the next login, but we will soon reboot the system.

Then do the same for this system file:
$ sudo nano /etc/skel/.profile
The directory /etc/skel is the Linux "skeleton" directory used to establish the home directory of newly-created users.

Secure the login greeter

$ sudo nano /usr/share/lightdm/lightdm.conf.d/50-ubuntu-mate.conf
You should see this initial content:
Add three more lines, getting:


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-get 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:
$ touch ~/.viminfo
$ 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
After these lines look further for the lines:
"if has("autocmd")
"  au BufReadPost * if line .....
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.

The initial "touch ~/.viminfo" is necessary to avoid having root be the owner of this file after editing /etc/vim/vimrc.

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 for editing Python files:
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-get install gedit gedit-plugins
Both text editors can be invoked through the menu system by:
Applications ⇾ Accessories ⇾ Pluma Text Editor
Applications ⇾ Accessories ⇾ gedit
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 withouth closing down the editor. To do so use the nohup command:
$ nohup gedit ~/.bashrc 2>/dev/null &

Make gedit the default text editor

If locate, say, a text file SOMETHING.txt, and open it by double-clicking, it is the same as doing:
$ 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:
System ⇾ Control Center
Choose Set Preferred Applications on the left side. Choose the System tab. Pick the one you want from the dropdown list for Text Editor. The name for gedit is the non-descriptive choice, 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
instructor@MACHINE:~$ sudo su
[sudo] password for instructor: INSTRUCTOR_PASSWORD
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 '(rkline|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 -

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 cryptogaphic keys.

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 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
  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:

Host MACHINE_tunnel
  Hostname taz.cs.wcupa.edu
  LocalForward 2001 MACHINE:3389
  LocalForward 2002 MACHINE:22
  LocalForward 2003 MACHINE:80
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 with xrdp using MATE Desktop

Install these packages:
$ sudo apt-get install xrdp
The edit the file:
$ sudo nano /etc/xrdp/startwm.sh
Comment out the last line and add a new one, making the contents be this:

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
# . /etc/X11/Xsession
We *should* be able to achieve the same outcome by creating the local file ~/.xession with the single line being the line we just appended, but it doesn't work.

Remote Desktop Client information

When you log in, you are logging into MACHINE using your LOGIN account credentials.


Having the X session from you lab machine displayed on your client is an alernative approach to using Remote Desktop. There are a number of solutions, but the one I'm describing here is:
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-get update
$ sudo apt-get 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:

export GSETTINGS_SCHEMA_DIR=/usr/share/mate:/usr/share
export XDG_DATA_DIRS=/usr/share/mate:/usr/share

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 16.04 client machine, there is an available package:
$ sudo apt-get 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.


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-get 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