See Gradescope
Sign up to the course’s pawtograder https://pawtograder.khoury.northeastern.edu/course/647. Then, look in your github.com account.
Submit the contents of your repository via Gradescope. See Deliverables below for what to submit.
This is an individual assignment.
The purpose of our first assignment is to make sure everyone is able to set up a working environment and to familiarize yourself with the terminal, shell, and the C compiler, as well as the process of submitting deliverables. It might be worthwhile to take a look at the Deliverables at the end of this assignment and then work through the tasks. We will also reserve some time in class to help walk you through the process and fix issues that might arise.
For this class, we need everyone to have a working Linux environment to work in. There are multiple ways to achieve this goal, but we want to make sure you are at least able to use Github Codespaces.
If you are working on a Windows machine and you want to work standalone on your computer, you mush set up Windows Subsystem for Linux 2 (WSL2). This will give you access to a Linux environment directly on your computer. Read more about WSL2. The rest of the description here assumes you have a working Unix-like terminal.
Everybody in this class should have an Intel x86-64 Linux environment to develop and test their code. You might already have a Linux installation on your machine or a VM. However, to make sure we all have access to a reasonably similar environment, we will use Github Codespaces. Codespaces is free for any Github user to use, but, alas, the free version has a limited number of CPU hours per month (60 for a 2-core VM) available. Applying for the Student Developer Pack allows you to extend the computation time available to you to 90 hours per month for a 2-core VM. It also comes with additional perks.
If you do not already have one, create a Github.com account.
Sign up for the Student Developer Pack. Note, unless your NUID card contains an expiration date, you might need to upload a document, e.g., a unofficial transcript, course schedule, or another document, that contains the end date for your studies.
If you have not already, sign up to the Pawtograder for this
course at: https://pawtograder.khoury.northeastern.edu/course/647
using the Northeastern Login option. Pawtograder will create your
repository, fa26-a1-setting_up-[your-github-username], when
the assignment is released.
We are only using pawtograder for repository creation. All submissions must be to Gradescope.
Open Codespaces from within the repository. Codespaces is an option under the green Code button (see green arrow in the figure below).
You will be provided with a web-based VS Code interface to edit
your files. Stop!
For this assignment, resist the
urge to use the pretty VS Code editor.
Instead, focus on the
terminal below the editor window and find the “Maximize Panel Size”
button to have the terminal take over the whole view. Complete the rest
of this assignment inside this terminal. Alternatively, you should be
able to use the Terminal on macOS or the Ubuntu terminal provided by WSL
on Windows.
Run the first 17 commands. Skim through each command’s manpage. For Assignment 1, we will ask you to copy and paste the console history of running some of these commands.
Note from instructor: We included urls to the manpages above, but it will almost always be faster for you to use the man pages within your terminal.
Meaningfully experiment with and run the first 17 of the above
commands. See the first deliverable for what
to submit. “Meaningfully” means that you do not just type the command
names one after the other, but provide a sensible use case. For example,
show a man page using man. Or use sort to sort
the lines of an actual file. Use cp to copy an actual file.
The idea is that you explore and get a basic familiarity with the
commands from the above list.
Here are some other nice things to know with the terminal.
<tab> autocompletes if it finds a
program, command, or file path.
mkdi then hit tabtab can also auto-complete filenames and filepaths,
which can be especially helpful!<Ctrl>+C sends a signal to the terminal
to terminate a program if it gets stuck.
grep . and press Enter to run it. Then press
Ctrl+C to terminate.<Ctrl>+Z sends a signal to the terminal
to suspend a program and give you back control.
sleep 10
(which puts the terminal to sleep) for 10 seconds, and see how you can
terminate this program.fg.man grep into the
terminal. Press q to quit a manual page.Calling each of these ‘commands’ (i.e. ls,
sort, cat, etc.) is not really correct. Each
of these is itself a program (typically implemented in C or some other
language).
As an example, here is the source code for ls: https://github.com/coreutils/coreutils/tree/master/src/ls.c.
Each of these commands is part of the coreutils package in
Unix. If you look through the source tree, you will additionally find
many other programs (i.e., the terminal commands in your shell) here: https://github.com/coreutils/coreutils/tree/master/src.
Compile the program hello.c using gcc to
get an executable named hello (Hint: look for the option
-o in the gcc manual). Make sure it runs and
prints what you expect.
Hint 1: For many commands/programs, you can supply a file to work on
simply by adding the filename after the command name, along with any
options. For example, to compile hello.c into an executable
called hello (instead of the default a.out),
we can use:
gcc -o hello hello.c
Hint 2: To run a program in the current directory, prefix filename
with ./, i.e., ./hello. ./
specifies that the file hello is in the current
directory.
Take a look at Deliverables 2 and 3 for what to submit.
Now open your chosen terminal editor (nano, Vim, Emacs, joe, …)
and modify hello.c such that it prints ONLY: your first
name followed by a newline and your email address followed by a
newline. Recompile the program. Confirm it runs and the output is
correct. Commit and push the file to your Github repository.
Make the program print your name and email address 20
times using a for loop. (Hint: Take a look at the
first few sections of the Learn C
tutorial.) Recompile, run, and confirm the output is correct. Commit and
push the file to your Github repository. At this point, take a
screenshot of the terminal with the editor as requested in deliverable 3.
You are not required to use the same terminal editor I use (I’m an Emacs user), but you should become comfortable using at least one terminal editor in this course. We recommend either VIM or Emacs, both powerful highly customizable editors with huge user bases. In practice, you should have a basic knowledge of VIM, since some version of it is installed by default on virtually any Unix/Unix-like system.
A little tutorial on VIM: https://www.howtoforge.com/vim-basics.
A Vim Basics in 8 Minutes video.
A tutorial for nano: https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/
output.txt (no capitalization, exactly as named.)
Ctrl (on Windows) or
Command (on macOS) and C (simultaneously) to
copy the text to the clipboard. Then open the file
output.txt in an editor (e.g.,
nano output.txt), paste the text (
Ctrl/Command + V) and save the
file.hello.c in your repository as
instructed in Part 4.
hello. If you did, remove it in an additional commit.hello.c
after you have made it print your name and e-mail 20
times.
editor.png or
editor.jpg.repo.png or repo.jpg.
Finally, go to Gradescope and submit a ZIP of your repository. The easiest way to do that is to go on Github and use the “Download ZIP” link under “Code” (see the figure below). You may also connect your Github account to Gradescope and submit directly by pulling from your Github repository. Let us know if you have trouble with any of the steps.