Everyone:

Next week, we will explore how to use some of the more advanced features of the Unix shell, including how to manipulate files and control processes, which are two fundamental abstractions the Unix operating system provides to the end user. You are also encouraged to learn more about a particular text editor of your choice such as vim, emacs, or nano.

TL;DR

The focus of this reading is to review the basics of manipulating files and processes in the Unix Shell.

Branching

As discussed in class, each reading and homework assignment must be completed in its own git branch; this will allow you to separate the work of each assignment and for you to use the merge request workflow describe at the end of this document.

To create a branch in your local repository, follow the instructions below:

$ cd path/to/cse-20289-sp18-assignments   # Go to assignments repository

$ git checkout master                     # Make sure we are in master branch

$ git pull --rebase                       # Make sure we are up-to-date with GitLab

$ git checkout -b reading01               # Create reading01 branch and check it out

$ cd reading01                            # Go into reading01 folder

Once these commands have been successfully performed, you are now ready to add, commit, and push any work required for this assignment.

Branching off Master

For the assignments in this class, you should always branch off the master branch. To determine which branch you are on, you can do the following:

$ git branch

To create and switch to a new branch, you can use the git checkout -b BRANCH as described above. Once you have performed this command, you can check which branch you are on:

$ git branch
  master
* reading01

To change to another existing branch, you can use the git checkout BRANCH command. Suppose you are on the reading01 branch and want to switch back to the master branch. To do so, you can do the following:

$ git checkout master

Python 3

Throughout the semester, we will be using Python 3 for a variety of purposes. Because the student machines do not have Python 3 by default, you will need to add the following line to your ~/.cshrc file:

setenv PATH /afs/nd.edu/user15/pbui/pub/anaconda3/bin:$PATH

You can then source this file to load that environment variable:

$ source ~/.cshrc

To check that Python 3 works, you can run the following:

$ python3 -V
Python 3.6.3 :: Anaconda custom (64-bit)

This will be necessary for the .scripts/submit.py script in your assignments repository.

Python Packages

If you wish to use your local machine for your work, you will need Python 3, Requests, and PyYAML.

Once you have Python 3 installed, you can install the later two packages by doing:

$ pip3 install requests pyyaml

Alternatively, you can use the Anaconda distribution of Python 3, which will include the interpreter along with many other libraries including Requests and PyYAML. This is the same software that is provided on the student machines.

Readings

The readings for Monday, January 22 are:

  1. The Linux Command Line:

    • Chapter 6 - Redirection
    • Chapter 7 - Seeing the World as the Shell Sees it
    • Chapter 8 - Advanced Keyboard Tricks
    • Chapter 9 - Permissions
    • Chapter 10 - Processes

Bash

The default Unix shell on the student machines is TCSH. However, The Linux Command Line book and the course requires that you use Bash. To temporarily switch to Bash, simply run the following after logging in:


$ bash

In addition to reading the above chapters, it is recommended that you learn a command-line text editor such as one of the following:

  1. nano: This text editor is the easiest to get started with, but also has the least amount of features. It is what I recommend for newcomers to Linux.

  2. vim: This text editor has many features such as syntax highlighting, plugins, and even spell checking. That said, it has a steep learning curve due to its foreign keyboard interface.

  3. emacs: This text editor also has many features (perhaps too many). In fact, Emacs is so powerful, there is saying "Emacs is an excellent operating system. All it's missing is a decent text editor". Bazinga!

This is my editor

All joking aside, your exact choice in a text editor is not important. What is important, however, is that you become comfortable with at least one of them and are capable of editting text efficiently in terminal. As the creed goes:

This is my editor. There are many like it, but this one is mine.

My editor is my best friend. It is my life. I must master it as I must master my life.

Without me, my editor is useless. Without my editor, I am useless.

Optional References

The following are additional resources that you may find useful:

  1. Introduction to Linux

Quiz

Once you have completed the readings, answer the following Reading 01 Quiz questions:

Submission

To submit your answers, you will need to create an answers.json or answers.yaml file in the reading01 folder of your assignments repository:

  1. If you have not already, follow the instructions at the top of this document to create a reading01 branch in your assignments Git repository.

  2. You can either hand-write the answers file using your favorite text editor or you can use the online form to generate the JSON data.

    A hand-written answers.yaml may look like the following:

    q1:
        - stdin
        - stdout
        - stderr
    
    q2:   "yes"
    
    q3:
        - "*"
    
    q4:
        - "ls"
    
    q5:
        - beastie
    
    q6:
        - beastie
    
    q7:
        - beastie
    
    q8:
        - "800"
    
    q9:
        - "b"
    

    The equivalent answers.json generated using the online form may look like the following:

    {
        "q1": [
            "stdin",
            "stdout",
            "stderr"
        ],
        "q2": "yes",
        "q3": [
            "*"
        ],
        "q4": [
            "ls"
        ],
        "q5": [
            "beastie"
        ],
        "q6": [
            "beastie"
        ],
        "q7": [
            "beastie"
        ],
        "q8": [
            "800"
        ]
        "q9": [
            "b"
        ],
    }
    

    You may use either format. To determine which symbols correspond to which response, take a look at the Reading 01 Quiz file.

    To check your answers, you can use the provided .scripts/submit.py script:

    $ cd reading01                        # Go into reading01 folder
    
    $ $EDITOR answers.json                # Edit your answers.json file
    
    $ ../.scripts/submit.py               # Check reading01 quiz
    Submitting reading01 assignment ...
    Submitting reading01 quiz ...
        Q1 0.90
        Q2 0.10
        Q3 0.50
        Q4 0.50
        Q5 0.20
        Q6 0.20
        Q7 0.20
        Q8 0.60
        Q9 0.80
     Score 4.00
    

    This script will submit your reading01/answers.json file to dredd, which is the automated grading system. dredd will take your answers and return to you a score as shown above. Each reading is worth 4.0 points.

    Note: You may submit your quiz answers as many times as you want; dredd does not keep track of who submits what or how many times. It simply returns a score.

  3. Once you have your answers file, you need to add, commit the file, and push your commits to GitLab:

    $ git add answers.json                # Add answers.json to staging area
    
    $ git commit -m "Reading 01: Done"    # Commit work
    
    $ git push -u origin reading01        # Push branch to GitLab
    

    Note: You may edit and commit changes to your branch as many times as you wish. Just make sure all of your work goes in the appropriate branch and then perform a git push when you are done.

  4. When you are ready for your final submission, you need to create a merge request via the GitLab interface:

    • First, go to your repository's Branches page and then press the Merge Request button for the appropriate branch:

    • Next, click on the "Change branches" link so you can set the Target branch to your own repository (rather than the class repository).

      Failure to select your own repository will lead to you unintentionally sharing your answers to the class, so please make sure you select your repository and not the class one.

    • Finally, assign the merge request to the appropriate TA (reference the Reading 01 TA List) and submit the merge request.

Every commit on GitLab will automatically submit your quiz or code to dredd and the results of each run is displayed in the merge request as a Pipeline task. To view the results of the submission, click on the Pipeline number and then the test button. You should then be able to see the results of the automated test, which should look something like this:

Once you have made the merge request, the TA can verify your work and provide feedback via the discussion form inside the merge request. If necessary, you can update your submission by simply commit and pushing to the appropriate branch; the merge request will automatically be updated to match your latest work.

When all work is complete, the TA will merge your branch and close the merge request.