1. Creating a GitHub Account

You are about to register for an online account.

When registering, ONLY use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

When registering, only use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

When registering, only use letters and numbers (a-z A-Z 0-9) in your GitHub username and in your GitHub password.

  1. Go to http://github.com and register for an account.
  2. Save your GitHub username and password in a secure location.
  3. Verify your email account by clicking on the link in the email that was sent to you by GitHub.com.
  4. Provide your instructor with your GitHub username.

 

2. Create a GitHub Personal Access Token

GitHub now requires users to use personal access tokens rather than passwords to authenticate themselves when communicating remotely with the GitHub servers.

When you follow the instructions in the tutorial below, do the following:

In Step 6, name your token anything you like
In step 7, choose “no expiration”
In step 8, grant the token all rights by checking all of the boxes

After you’ve created your personal access token, paste the token to an accessible document file on your laptop.

To create a personal access token follow the direction in the GitHub tutorial named Creating a personal access token.

 

 

3. Cloning a Repository

Here we assume that you have set up Git, created a GitHub account, and created a GitHub personal access token.  In addition, we assume your instructor has created a repository on GitHub and shared it with you.

View Our Shared Repo on GitHub

To view our shared repository, log onto GitHub, and navigate to your profile. You can find your profile page by clicking on the user icon in the upper right corner of the page and selecting Your profile in the drop-down menu.

On your profile page, in the bottom left side of the page, click on the icon listed under Organizations.

On the organization page you should see a link to your repository.  Write down the organization name and the repository name.  You’ll need to use them below.

Clone Our Shared Repository

To clone our shared GitHub repository onto the Linux server, execute the following command while replacing

    • USER_NAME with your GitHub username
    • ACCESS_TOKEN with your GitHub personal access token
    • REPO_NAME with our GitHub repository name (which is your BC username)

Note:  the following command is typed on a single line.

$ git clone https://USER_NAME:ACCESS_TOKEN@github.com/BC-CSCI/REPO_NAME

Git will create a new folder with the same name as the repository name in your working directory and copy over all the files that are in the GitHub repository.

Type pwd on the command line to see your current working directory.  You should see a path similar to the one below except rmcgregor will be replaced with your Bridgewater username.  This is your home directory.

/home/rmcgregor

Now, list the contents in your current working directory using the ls command to see the repository that was just created.  You should see a directory with the name of your repository.  That directory IS your repository.  You’ll put all of your work for this course in that repository.

Change directory into the repository by issuing the following command, replacing repository-name with the name of your repository.

$ cd repository-name

Type pwd again on the command line.  You should see a path similar to the following, except instead of rmcgregor you should see your Bridgewater username twice.

/home/rmcgregor/rmcgregor

Keep Your Repository Organized

The work you do will eventually end up in the repository on GitHub where your instructor can review your work.  To get credit for your work, please organize your work as instructed by your instructor.

    • If your instructor asks you to create a directory with a specific name, please name it exactly as specified. 
    • If he asks you to give a file a specific name, give it the name exactly as specifies. 
    • Directory and file names are case-sensitive on Linux.

 

4. Pushing a File to GitHub

Prerequisite

I assume you’ve cloned our shared repository onto the Linux machine.  If you haven’t yet done so, please do so before continuing on with this tutorial.

Create README.md

Log into your Linux machine and change your working directory so that you are in the base directory of your repository.

Using an editor, create a file named README.md (if it doesn’t already exist).  Note that the filename is case sensitive.

Include at the top of the file a line of text that simply reads

# YOUR_FULL_NAME

where YOUR_FULL_NAME is replaced by your full name (spaces are allowed).

Submit Your Work

Anytime you want to copy your work (like the README.md file) to GitHub you need to do the following:

      1. Add the names of the files that you’ve modified or created to the staging list.
      2. Commit the changes to the files in the staging list to your local repository.
      3. Push your committed changes to our shared repository on GitHub.com.

Note that all of the following commands must be executed inside your repository directory.

STEP 1: Add the names of the files that you’ve modified or created to the staging list by issuing the following command.  Replace FILE_NAMES with the names of all of the files and directories (separated by spaces).

$ git add FILE_NAMES

STEP 2: Commit the changes to the files in the staging list to your local repository by issuing the following command. Include the double quotes and replace YOUR_MESSAGE with a short message describing your changes.

If you are submitting your code for review because you have a bug, add in the commit message @erimcg followed by a precise description of the issue you are trying to solve.  Note that “@erimcg can not find bug” is not sufficient.  Do not include @erimcg if you are submitting your work for a grade.

$ git commit -m "YOUR_MESSAGE"

STEP 3: Push your committed changes to our shared repository on GitHub.com by issuing the following command.

$ git push origin main

Final Step

Always check that your files were successfully copied to our shared repository on GitHub.com by logging onto GitHub.com and visually checking our shared repository.  If they’re not on GitHub, I can’t pull them.

For more information on git, please see the online reference manual: http://git-scm.com/book.

Off-Campus Access to cs.bridgewater.edu

In order to ssh into cs.bridgewater.edu from off campus you need to use the college’s VPN.  The VPN will create a secure encrypted channel between your computer and the college’s network.  Be sure, once you are finished using cs.bridgewater.edu, that you turn off the VPN so that your internet traffic does not travel through the college’s network.

In order to use the college’s VPN, you first need to install it.  You can find instructions on where to download the VPN and how to use it in a tutorial on the IT department’s web site.

To find the tutorial do the following:

    • Navigate a browser to help.bridgewater.edu.
    • Click on the Knowledge Base tab on the menu bar.
    • Press the Sign in link in the upper right corner and sign in with your BC credentials.
    • Click the Information Technology category.
    • Click the Wifi & Network category.
    • Select the Using VPN to Gain Access to the Network article.

Download, install, and start the VPN by following the instructions in the knowledge base tutorial.  If you have any problems getting the VPN installed or started, please open an IT ticket by emailing help@bridgewater.edu and sending them a detailed description of the process you have taken and what the problem is.  Provide screenshots if applicable.

Once the VPN is started, you can open your terminal or Command Prompt and ssh into cs.bridgewater.edu.

Again, be sure, once you are finished using cs.bridgewater.edu, that you log out of cs.bridgewater.edu and turn off the VPN so that your internet traffic does not travel through the college’s network.

Reaching the AWS Console With an AWS Educate Student Account

Prerequisite:  You should have applied for an AWS Educate account and received an email from AWS accepting your application.

  1. Click on the hyperlink on the line of your acceptance email that says, “Bookmark the AWS Educate Student Portal for easy access, or click here to sign in directly.”
  2. Log into the AWS Student Portal.
  3. Click on AWS Account at the top-right of the page.
  4. Click on AWS Educate Starter Account.
  5. Click on AWS Console under Your AWS Account Status.

Using Kattis’ Client on Linux

Create a Kattis Account

  1. Create an account on open.kattis.com. Choose Log in with e-mail, then choose Sign up for a Kattis account. Use your Bridgewater College email address when creating an account.

Getting the Kattis Client and Config File

  1. Log into open.kattis.com.
  2. Choose the Help tab, then choose the How to submit link located near the bottom of the page.
  3. Read the How to submit page carefully before continuing.
  4. Scroll down to the section titled Downloading a configuration file and client.
    1. Cut and paste the contents of your personal configuration file into a new file on your laptop and save the file in your Downloads directory as kattisrc.txt.
    2. Download the Kattis client into your Downloads directory by clicking on the file name.
  5. Open terminal or GitBash and change the working directory to the location of the files you downloaded (in your Download directory).
  6. Use the following command to copy your personal configuration file and submit.py to your home directory on cs.bridgewater.edu.
scp <file name to transfer> <bc_username>@cs.bridgewater.edu:<file name to transfer>

Note that when typing the above command you need to replace <file name to transfer> and <bc_username> with appropriate information.

Setting Up Submit.py

  1. SSH into cs.bridgewater.edu
  2. Run chmod 700 submit.py.
  3. Create a subdirectory in your home directory named bin and move submit.py into bin.

Setting up .kattisrc

  1. Rename the kattis config file (e.g. kattisrc.txt) to .kattisrc.

Testing the Script

  1. Navigate to https://open.kattis.com/problems/hello with a browser to view the hello problem.
  2. Write a program that solves the hello problem with a class named Hello in a file named Hello.java.
  3. Submit your program to Kattis using the following command: submit.py -p hello -l Java -m Hello Hello.java
  4. Navigate to open.kattis.com with a browser and click on your name in the upper right corner to see if your solution was accepted.

Bash

Bash

The shell that is started by default on our host is called bash. When bash is run it displays a command prompt (a.k.a. system prompt or bash prompt) to the user.  This prompt often includes the name of the directory that the user is logged into followed by $.  When the command prompt appears on the screen, the user can enter commands after the prompt and press enter to have the shell execute the command.

Bash’s Hidden Files

If we run the following command we can see all of the files in the current directory including the hidden files.  A hidden file is a file whose name starts with a period.  If we run the command from our home directory we can see the three files: .bash_history, .bash_profile and .bashrc.

$ ls –al

Bash History

When at the command prompt, we can use the up arrow and down arrow keys to display on the command prompt previous commands that we’ve had the shell execute.    These previous commands are stored in .bash_history.

The up arrow and down arrow keys can help speed up the development process. Rather than having to retyping a compile command, for example, we can just use the up arrows to repeat the command to we entered earlier.

The .bashrc and .bash_profile Script Files

Both .bash_profile and .bashrc are script files that are editable by the user.  When we start a terminal application to gain access to a shell prompt, the terminal typically starts a non-login shell.  When starting a non-login shell the script file ~/.bashrc is executed.  When we SSH into a machine, a login shell is started and the scripts in .bash_profile and .bashrc are run.

Some useful things to add in these script files are definitions for environmental variables and aliases.

An environmental variable is a string that can be used to refer to another string (usually much longer) in a script or program.  For example, suppose I often change my current working directory to /home/eric/courses/csci105. I can add an environmental variable named INTRO to .bashrc and use it to refer the path.  In .bashrc  I would add the following.

INTRO=/home/eric/courses/csci105
export INTRO

In order to be able to use the new environmental variable we need to reload the .bashrc file.  To do this you need to either log out and back in or run the following command:  (dot space dot bashrc)

$ . .bashrc

Now when you want to go to your homework directory you can substitute the environmental variable for the homework path.

$ cd $INTRO

Aliases are used to define shortcuts to commands that are invoked repeatedly or are lengthy to type.  Suppose I would like to make it so that when I typed ls the shell executed ls -l.  I can do this by creating an alias for ls -l.

alias ls=’ls –l’

Don’t forget to reload the .bashrc file.  After it has been reloaded, when you type the command ls it will execute ls –l.