(Possibly) useful tech links/notes

Advice and a request: use otter like a jump box

To give yourself and others the best working conditions, when you ssh to our servers to do your lab work, please just use otter as a stepping stone to another of the servers and do your work there.

We have machines pup1 - pup17, cub1 - cub16, and kit1 - kit4 to choose from, e.g. once you're on otter run "ssh pup13" to jump to pup13.

You still have access to the same set of programs and files (including everything in your CS account), but your processes are actually allowed to use more memory and cpu time on those machines, and the machines are also likely to be faster and be more responsive since there are fewer people on any one machine.


QUICK LINKS


Getting started/connected for CS students @VIU
Student account information (new accounts)
Student password resets (ongoing)
Accessing CSCI machines from home, Video version:youtube, viutube
- Ubuntu note: if Windows is asking you to enable a windows subsystem for linux, check this microsoft link for instructions
Physical access to CSCI labs
4 tips for ssh/C++ @csci
Accessing VIU Windows lab machines from home
Accessing CSCI machines from smartphones
Transferring files between your laptop/pc and the CSCI servers (pscp or scp)
Official department resources page
Firefox won't start (says already running)
Configuring Linux based laptop to connect to VIU-secure wireless network


Git for CS labs, projects, and assignments
Git project distribution and submission, Video version: youtube, viutube
trouble-shooting git submission issues
CSCI GitLab Server Beta


X servers and X forwarding
Humayun's guide to installing X2Go (pdf)
Running Debian in a virtual machine on your laptop
Simulating the lab's X-server on your home machine
Humayun's guide to remote access with X forwarding (pdf)

Merlin's tutorial on ssh tunnelling (markdown file)
Merlin's tutorial on ssh client configuration (markdown file)
.... and a guide to viewing markdown files in a browser
VS Code 1.49: bug causing ssh connection failure


Tutorials and resources
CSCI tutorials page, and resources
linux and vim tutorials
List of C++ compilers (from Bjarne Stroustrup)
ExplainShell: tool for explanating specific shell commands
ShellCheck: detecting common errors in shell scripts
Auto-formatting C/C++ program layouts


Other stuff
Using email on the CSCI servers
Accessing Discovery U-drives from CSCI machines
Disk quotas for student accounts (unable to save files)
Sarah's resource collection for creating your own videos (for projects etc)


...and now for a jumble of actual content...


General linux tutorials

I'm always looking for good introductory linux tutorials, let me know if you find these helpful (or find others that are better!)
RyansTutorials.net
TuxArena.com
Vim quick ref (pdf) (courtesy of Jonathan Funk)
vim guide (my old vim notes)


Creating your own videos (for projects etc)


Sarah Carruthers has provided the following collection of video making resouces (e.g. for creating and posting project demos to viutube).


Student account information

For students new to CSCI at VIU, you will obtain your linux login id and account information from one of your CSCI professors. If you are taking multiple CSCI courses in the current term, the instructor in the lowest numbered course will have your information (e.g. if you are taking CSCI 112 and 160 this term then the 112 instructor will have your information).

On VIULearn, your instructor will post an assignment named something like "CSCI Credentials", which will simply ask you for your name and student number. When the instructor "marks" the assignment, they will return your account information as the feedback.

This assignment can also be submitted by returning students, but the only account information the instructor will be able to supply is your linux loginid.

Student password resets
Important information about how to initiate communications
that involve privileged information with the CSCI Technician.  This includes:
password resets, account problems, unable to connect to server.

NOTE: if your instructor has not yet given you your csci login and password DO
NOT USE THIS PROCESS TO GET IT.  Please wait until it is handed out to you by
your instructor.  The following is only to be used if there is a problem AFTER
YOU HAVE BEEN GIVEN YOUR CREDENTIALS.

Suppose something goes wrong, and you need to ask Merlin to reset your password
or fix your csci account, what should you do??!!

Here's the plan for handling these kinds of requests, so that we can:

1) trust who it is coming from

2) send information in a secure manner

HOW TO INITIATE SENSITIVE REQUESTS WITH TECHNICIAN:

All sensitive account requests (password resets, unable to connect, account
troubles) must go through VIU Learn, as follows:

 1. Log into VIU Learn and navigate to one of your courses.
 2. Select Communication -> Classlist
 3. Locate Merlin Hansen (Instructor) in the list.
 4. Click the down arrow beside Merlin's name and select Send Email.
 5. Enter an appropriate subject (example: Please reset my CSCI password).
 6. Enter an appropriate message in the Body and include your:
     1. Name and student number.
     2. CSCI Linux username (if known).
     3. What CSCI course(s) you are enrolled in.
     4. A detailed description of the issue you are having.
 7. Note: Do not provide your old password or what you recall as your password. 
    A good SysAdmin will never need or ask for your password.
 8. Click Send
 9. Wait for a reply from your Friendly Neighbourhood SysAdmin.

Upon receiving a request such as above the CSCI Technician will

 1. Verify the information provided by the student including confirming identity
    and enrolment status.
 2. For a password reset request:
     1. Generate a new one-time-password.
     2. Generate a one-time-viewable message containing the new password, the
        student's username, or both (as the situation requires).
 3. Send a reply to the student via VIU Learn containing a custom URL pointing
    to the one-time-viewable message, and/or any relevant information or
    queries.

If you have any questions or concerns about this, please forward them to the department
chair (chair@csci.viu.ca) or technician (tech@csci.viu.ca) for clarification.


Transferring files between your laptop/pc and the CSCI servers


Auto-formatting C/C++ program layouts

OK, after a little playing with the linux 'indent' command, I've got a set of options that will take poorly-formatted C++ programs and produce formatting very close to the CSCI 160 standards. It isn't perfect, but it's pretty good.

First, copy the following file to your home directory: .indent.pro
The changes will be usable the next time you login.
(You only need to do the copy/save this once.)

Subsequently, whenever you want to auto-reformat your C++ code, use the following command:
indent oldfilename.cpp -o newfilename.cpp
(e.g. indent lab5a.cpp -o lab5b.cpp

If you then wanted to rename the auto-formatted lab5b.cpp to lab5.cpp (for example), you can then use the move command syntax: mv oldname newname, e.g.
mv lab5b.cpp lab5.cpp


Accessing VIU Windows lab machines from home

Students can now use the Remote Computer Access Dashboard portal to connect to VIU's Windows lab machines from home.
The portal is here: remoteaccess.labstats.com/Vancouver-Island-University
And instructions are here: technology.viu.ca/student-online-software


Accessing CSCI machines from home

If you wish to connect to our servers from home you can use virtually any secure shell (ssh) utility. ssh is already installed on most linux and mac machines.

For those running Windows 10, holding down the Windows key and hitting X will bring up a menu from which you can select PowerShell. Within the resulting PowerShell window you can enter the same ssh command as is listed above for linux/mac.

For those on older Windows machines, another commonly used program is PuTTY, which is freely available for download.

Once connected, you will have your command window to work in, very much like the terminal windows we open in the labs.

Important note: the gedit editor won't work when connecting this way. There are a number of other editors that can run inside your open terminal window - emacs, nano, and vim to name a few. vim and emacs both have a bit of a learning curve to them (but are ultimately worth knowing), nano might be the easiest to get started with. Thus to edit a file you would type nano filename instead of gedit filename
nano uses the control key to issue basic commands, e.g. control-X to exit, control-G for help, control-O to save (writeout), etc. A short menu of command options can be seen at the bottom of the window while you're working in nano.
Alternatively, see Humayun's guide to installing X2Go, which will allow you to use tools like VSCode and GEdit on our servers but using your home machine.


Accessing CSCI machines from smartphones

Connecting from a smartphone is much like the access from home section above, it's just a matter of getting the correct app installed first. There are a variety of apps out there, including ConnectBot for android, ssh for iphone, and BBSSH for blackberry.


Access to CSCI labs

Access to the CSCI labs is now controlled by your VIU student id card, and should be automatically updated periodically during the semester based on your course registrations, assuming you've picked up your student id card.

Note that the old cardkey system is no longer supported, and older student ids (issued before July 1, 2019) will need to be replaced to be usable with the new system.


Using email on the CSCI servers

You can access email from a terminal window on the machines in labs 102 or 115 as follows:


Accessing Discovery U-drives from CSCI machines

Please find appended instructions on accessing your DISCOVERY U: drive from the Computer Science Linux lab in 315-102.

This document describes how a Computer Science student can access their DISCOVERY U: drive from an Xterminal in 315-102. The same basic procedure probably works in 315-115, but this is untested.

Steps:

1. Login to a Linux system in 315-102 or 315-115.

2. From the main menu select: Places->Connect to Server...

3. Select Service Type: Windows share

4. Set Server: dolphin.discovery.mala.bc.ca

5. Set Share: users$

6. The folder name consists of three components based on your student number - the second last digit, the last digit and the student number itself, separated by slashes. For example, if your student number is 123456789, set Folder: 8/9/123456789

7. Click Add bookmark

8. Set Bookmark name: UDrive

9. Click Connect - you should get a file browser window with the contents of your DISCOVERY U: drive.

Notes:

1. To copy files or folders from one system to the other, the only method that appears to work consistenly is Copy/Paste: right click on the item you wish to copy and select Copy, then right click where you wish to move the file and select Paste. You can bring up a file browser with your home directory, from the main menu select Places->Home Folder.

2. Some files, such as (some) PDF files, can be opened directly from the U: drive, others probably need to be copied.

3. On subsequent logins, if you create a file browser (Places->Home Folder) you should be able to click on UDrive in the lower left pane to access your DISCOVERY U: Drive.


Trouble-shooting git submission issues

Getting unexpected messages when trying to submit your lab/assignment in git? Here are a few common messages/solutions:


Disk quotas for student accounts

If you're having trouble saving files on your linux account (error messages when you try to save) it is entirely possible your account is over its disk quota (typically 1GB for a student account).

You can check your quota and current usage using quota -sp

If you're over the limit you'll need to hunt around for any large files causing the issue.

A useful pair of commands for finding large files or directories is
du -k | sort -n | tail -20

You can use the rm filename command to get rid of an offending file, or drag it to the Trash icon and empty the trash (the space isn't freed until you actually empty the trash).

Problems often come about due to web browsers storing a large amount of data in the cache - you can dig around the preferences for your chosen browser to find the right option to limit that (if desired) or find and remove their cached files (e.g. for chromimum look in ~/.cache/chromium, for firefox look in ~/.cache/mozilla)

If problems arise from having too many files (a less frequent problem, but students can sometimes exceed their limit), you can find directories containing many files using
find . -printf '%h\n' | sort | uniq -c | sort -k 1 -n | tail -20


Running Debian in a virtual machine on your laptop

Want to run debian linux on your own laptop, but without changing your laptop OS?

One option is to create a virtual machine on your laptop, and install/run debian linux "inside" that. One widely-used (free) tool for installing/running virtual machines is VirtualBox. Installing VirtualBox is relatively painless, and you can then install/run other operating systems within virtual environments.

A guide to installing Debian through VirutalBox is available here: (BrianLinkLetter)


Simulating the lab's X-server on your home machine

Want to use the csci server's graphical elements but have the display show up on your home machine?

Two free solutions are to install either

You can then start an xserver in whichever you installed, open an xterm window through it, then run this command to connect to our server:
ssh -Y -l yourusername csci.viu.ca
(that's an uppercase letter Y and a lowercase letter L)

At that point you can start up the tools you would usually use in the lab (gedit, wish, etc) and the display will show up properly (though perhaps slowly) on your home machine.


VS Code 1.49: bug causing ssh connection failure

There is a bug in VS Code 1.49 (August release and latest) which causes ssh connections to fail. Symptoms include: The solution: Your connections should now work.

What happens if the above does not work....

For those of you interested... The latest version of VS Code has a problem with locking on NFS mounted file systems (which is what /student uses). Setting the option to true tells VS Code to use an alternate method of locking by storing a unique file in /tmp (thus avoiding the NFS issue).
The bug has been reported to the VS Code folk.
The bug does not seem to exist in previous versions of VS Code.


Firefox won't start (already running or no profile)

Often the "already running" arises when firefox has left a stray lock file behind from its last run, or the "no profile" arises when it cannot find user profile information for you.

In either case we can run firefox from the command line, telling it to ask us for a profile (instead of just refusing to run). The command is simply:

firefox -p

Firefox will generate a popup giving us a choice between existing profiles or the opportunity to create a new one.


Configuring Linux based laptop to connect to VIU-secure wireless network

Although IT does not generally support Linux, Android and Linux are close enough that you can use the information given for Android to configure your Linux box. The IT page can be found here: technology.viu.ca/help/wireless with a section for Android near the bottom.

There are several ways to configure your wireless network using your favorite application that varies from distro to distro. Whichever application you choose to use, take the settings from the above link when configuring the wireless.

If you are using iwd (Internet Wireless Daemon) you have two ways to configure it: via Network Manager gui, or via the command line. Below we will consider the latter method:

Note: this is not an exhaustive guide of iwd, just enough to get things working.

iwd uses configuration files in "/var/lib/iwd" for each wireless network you want to connect to. The files names are a combination of the SSID and Security method used. For VIU-secure you want to create a file called viu-secure.8021x and place the following contents in it:
[Security]
EAP-Method=PEAP
EAP-Identity=yourstudentnumberhere@viu.ca
EAP-PEAP-Phase2-Method=MSCHAPV2
EAP-PEAP-Phase2-Identity=yourstudentnumberhere@viu.ca
EAP-PEAP-Phase2-Password=yourpasswordpasswordhere

[Setting]
Autoconnect=true

You can also choose not to have your password in the file. In that case you will be prompted for the password when you attempt to connect.

To test the new configuration use iwctl:
$ iwctl
[iwd]# station *device* connect viu-secure
If all goes well you should be connected. For more information on using iwctl see the Arch Linux wiki wiki.archlinux.org/title/Iwd


CSCI GitLab server Beta

Good news from Merlin:

CSCI GitLab server [BETA] available

CSCI now has its own GitLab server available for CSCI faculty and students. 

You will need to request access to the server by sending a message to the CSCI
Technician via D2L. Once approved you will be able to log into the CSCI GitLab
server using your VIU computer account credentials. NOTE: not your CSCI
credentials, but your student number and VIU password.

Server information:
- By default each student can have up to 10 repositories.
- The server is accessible from both the CSCI network and the Internet.
- The server URL is gitlab.csci.viu.ca

Note: I consider this service to be in Beta. What this means is that although I
will do my best to ensure the server is stable and available 24/7, it is not
guaranteed at this stage. Also, currently the server is not backed up offline.
This means that there is a very small possibility that your repos may be lost at
some point. However, so long as you have a local clone this is not really a
concern. I do not foresee a situation where repos will be lost but you have been
warned.

Future plans: The Beta will last then next few months depending on the adoption
and usage of the server. As time progresses I will fine tune and tweak the
server until it can be considered production ready.

NOTES:
- This GitLab server does not in any way replace the Git Assignment Submission
system used in some CSCI courses.
- Yes you can use this GitLab server to move code between your CSCI account and
your home computer.

If you have questions, please fire away. Please report any issues, no matter how
small, to me so that I can investigate them.


Guide to viewing markdown files in a browser

Another handy-dandy guide from our resident wizard, thanks Merlin!

If you are like me you love Markdown for use in documentation, all over the place. As great as Markdown is, viewing it in a browser as Markdown leaves something to be desired and converting it to HTML is a bit of a pain to maintain.

If you use Google Chrome or Firefox then there is a nice solution... a Firefox and Chrome extension that allows you to view Markdown files as either Markdown or as HTML:

Firefox: https://addons.mozilla.org/en-US/firefox/addon/markdown-viewer-chrome/

Chrome: https://chrome.google.com/webstore/detail/markdown-viewer/ckkdlimhmcjmikdlpkmbgfkaikojcbjk

Of course it is an open source project, and is hosted at https://github.com/simov/markdown-viewer

I've been running this extension for a couple of years now and have found it easy and useful (especially since I keep handing Dave Markdown files to put up on his Tech Notes page and write all of the CSCI documentation in Markdown). If you are interested, read on...

When you install the extension you will want to configure it to give it access to the websites where you want to view Markdown as HTML. By default it does not have permissions to access any websites, which is good. To give it access to pages hosted on csci.viu.ca when viewing them:

- click on the extensions icon in Chrome (the puzzle piece shaped icon)

- click on "markdown viewer" to pop up the options page

- click on "Advanced options", which will open a new tab showing the "Allowed Origins" configuration page for the extension

- click on the drop-down and select "*://" instead of "https://"
- enter "csci.viu.ca" (where it says raw.githubusercontent.com), and click "Add"

- the new entry will show up in the list lower in the page

Note: You will also see an entry in the list for "file://" which allows any locally stored Markdown file you view in the browser to be displayed as HTML via the extension.

Now to view a Markdown page as html browse to a Markdown page such as: http://csci.viu.ca/~wesselsd/guides/Tutorial-sshClient.md, click on the puzzle piece and select "markdown viewer" again to bring up the options. Then click on the "HTML/MARKDOWN" toggle button two switch viewing the page in the two modes.

Hope you find this useful.