L1: Developer Environment Setup#

Objectives#

  1. Set up and use lab software

    1. Understand how to use the classroom computers / your personal computers for classwork

    2. Create a WSL container on the classroom computer

    3. Install and update packages on the Debian operating system

  2. Use git/GitHub for completing and submitting lab and assignment work

    1. Set up coursework repository we will use throughout the semester

  3. Review Bash essentials

    1. Using bash and ssh on the command line

    2. Review bash commands / operations

Overview#

This lab walks through setting up the developer environment we will use throughout the semester, followed a short lab reviewing and developing bash skills.

Context#

In this course, we will frequently run code and commands on a raspberry pi.

An efficient way to work on a remote computer like the pis is to setup a remote bash connection using ssh.

That way, you can write code on a preferred computer, while running code and other commands directly on the raspberry pi as you work.

Using ssh effectively requires getting comfortable with the CLI shell – in this course, our shell will be bash.

Part of getting comfortable with bash is simply getting in the habit of using it for useful things.

Setup#

Complete each of the following tasks:

  1. On Moodle, complete the Lab 1 Hardware & stuff survey

  2. Complete all of the steps in Developer environment setup

    Note

    If you will use a personal computer for this class, you need to do the developer environment set up on BOTH (1) a lab computer and (2) your personal computer(s).

  3. Sign up for the course repository on GitHub Classrooms

  4. CHECK THE EMAIL ASSOCIATED WITH YOUR GITHUB: accept the invitation to join the class GitHub organization.

  5. Clone the coursework repository onto your developer environment

../../_images/invitation.png

You need to find this email and accept the invitation in order to access your coursework repository.#

Tracking your coursework progress#

Throughout this class, we are going to make extensive use of git and GitHub to track our work, starting with this lab.

Open your coursework repository in VSCode, and do the following:

  1. Create a branch called lab-1

  2. in VSCode, open the lab-1/bandit-instructions.txt file

  3. Change the 2nd line Prepared by: <write your name here> such that your name is written.

  4. Immediately make a commit of that change

  5. Push that change, and the lab-1 branch, to your github repo

You’ve now begun the “flow” that both tracks the progress of your work and saves your work in a location independent of your developer environment – we are regularly going to be sharing code across devices.

bash bandit#

To get us warmed up with using ssh to connect to a remote computer, and using the various bash tools at our disposal, the bash bandit game is great practise.

For this lab, we will aim to complete all levels up to and including Level 5->6.

../../_images/bandit-screenshot.png

Each level of the bandit game requires you use one or more bash commands to complete the level.#

Getting started#

  • Open a terminal on your developer environment. All ssh commands for the game will be done here.

    • On Windows, use your WSL container

    • If working on OSX or Linux, use your default terminal

  • Open lab-1/bandit-instructions.txt in VSCode

    • You will use this file to record your progress through the lab.

  • The instructions for the lab are contained in the game itself.

    • IMPORTANT read the Note for beginners! It answers many of the questions you will no doubt have…

    • Then, proceed to Level 0

      • IMPORTANT read Level Goal and the Commands you may need to solve this level for each level. They’re helpful!

      • IMPORTANT Use man to see what the suggested command can do for you. Use Ctrl + d and Ctrl + u to scroll up and down the terminal efficiently, and / to search.

      • IMPORTANT There are lecture notes about bash essentials that cover the main commands you need for bash bandit – try looking at these if you’re stuck.

Note

if you are getting “hostname not resolved” issues in WSL, follow the steps below:

  1. sudo vim /etc/wsl.conf , add the following lines:

    [network]
    
    generateResolvConf = false
    
  2. sudo vim /etc/resolv.conf , add the line:

    nameserver 8.8.8.8
    
  3. sudo chattr -f +i /etc/resolv.conf

For more detail, see https://askubuntu.com/questions/1364984/dns-not-working-on-wsl

Documenting your progress#

As you complete each level, write down in lab-1/bandit-instructions.txt the following:

  • the password needed to start the level

    • i.e., Level 0-1 should have Password: bandit0, because bandit0 is the password needed to enter the Level0-1 server.

  • the commands used to find the next password

  • comments explaining the commands

    • e.g. necessary paramaters/flags, idea behind the command, why it works, etc.

Note

In each level, the password is a long string of random characters stored in a file on the server. You will need to copy and paste the password frequently – from your bandit-instructions.txt and to your bandit game terminal.

Copy/paste is a bit different on terminals than you may be used to:

  • Highlight the text holding Left+click

  • Copy the text using Ctrl+Shift+C

  • Paste the text using Ctrl+Shift+V

Follow the format in the bandit-instructions.txt file. Make sure you read and follow the instructions given in the comments (marked by #).

As you complete the bandit-instructions.txt file, track your progress on the lab-1 branch using git commit. Before you finish working, make sure you git push your commits to upstream lab-1 branch of this repository.

Don’t be shy: you should be committing and pushing your progress to your branch regularly, even if it is not finished – this will let you continue where you left off easily no matter what computer you are working on.

In-class demo#

During class on Monday/Friday, I will take note of your progress. Let me know if you finish early – I will ask you a few questions about your work. If you do not finish by Friday, I’ll ask you about what you have been able to do so far.

Finished early?#

  • Try to complete more of the bash bandit game! We will be returning to this in future labs, so your time won’t be wasted.

  • If you haven’t already, set up creating and storing a GitHub Personal Access token on your developer environment using pass (see the github course notes for more details.)

Rubric#

  1. Hardware & Stuff survey complete on Moodle

  2. WSL set up on lab computer

  3. Dev environment on personal computer (one of four options)

    • Windows: Same as lab computer

    • OS X: OSX setup complete

    • Linux: Linux setup complete

    • None of the above (if no personal computer will be used)

  4. coursework repository cloned to your developer environment

  5. bash bandit game started

  6. progress made on bandit-instructions.txt has been committed and pushed to your coursework repository

  7. On Friday Jan 24, you have showed your progress on all of the above to the instructor.