0% found this document useful (0 votes)
294 views3 pages

Cse 3100 Lab 0

This document provides instructions for students to complete Lab 0 for their Systems Programming course. It guides students through logging into their virtual machine, using basic shell commands, initializing and using git to manage their code repository, editing and compiling a simple "Hello World" C program, and modifying it to include their name. The lab must be completed and submitted via git before the deadline.

Uploaded by

cjon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
294 views3 pages

Cse 3100 Lab 0

This document provides instructions for students to complete Lab 0 for their Systems Programming course. It guides students through logging into their virtual machine, using basic shell commands, initializing and using git to manage their code repository, editing and compiling a simple "Hello World" C program, and modifying it to include their name. The lab must be completed and submitted via git before the deadline.

Uploaded by

cjon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSE 3100 Systems Programming Fall 2018

Lab #0

Welcome to Lab 0! At the start of each lab, you will receive a document like this via HuskyCT detailing the task
you are to complete. Read it carefully. It should be possible to finish most labs during the lab period. However, labs
are not due after each lab period. Normally, lab assignments are due in 24 hours after the lab session starts. Lab
0, however, is due on Thur, 9/6/2018, at midnight.

This lab is intended to be interactive. Feel free to discuss the assignment with your neighbors. However, please recall
that all of your code should be your own! If you’re having trouble, feel free to raise your hand and ask your TA for
guidance!
After lab 0, you should be able to access your VM, use basic commands in shell (e.g. to copy/remove/rename
files), use git, edit text files like C source files, and compile and run simple C code.

Logging into your VM


A terminal application and ssh client are needed to access VM. On Linux, start a terminal and use ssh to gain shell
access to the VM created for you.
ssh [email protected]

For Windows and other OSs, instructions can be found on the UITS help page and the SoE help page. The domain
name of your VM is yournetid.3100.cse.uconn.edu (for example: abc11001.3100.cse.uconn.edu). Your user
name on the VM is your NetID. The password is your NetID password (the same one you use for HuskyCT). You
can only log into your own VM.
You can only access your VM from UConn network. If you would like to access it off campus, you can log into
ssh.uconn.edu first (and then ssh into your VM on ssh.uconn.edu), or use UConn VPN. See UITS help page on
VPN. You can also find other ways on UITS help pages for remote access.

The Shell
In the shell (most likely bash), try the following commands (and explore a bit!):

pwd Show the current directory (where you are).


ls List the files and directories in a directory.
ls -l The -l flag tells ls to show more details.
mkdir adir Create a directory. Try different names.
ls -l adir Lists the files in the directory ’adir’.
cd adir Move into the directory ’adir’.
ls -l .. List the files in the parent directory.
cd Go back to your home directory.
cd adir Go to ’adir’ again.
echo "hi!" Print ’hi!’ to the standard output (stdout).
echo "hi!" > file Save ’hi!’ to a new file called ’file’
cat file Print the contents of a file to stdout.
grep "hi" file Search the file for the string ’hi’.
less file View the file interactively (q to quit).
rm file Permanently deletes the file.
cat Reads from standard input (stdin) and dumps to stdout. Ctrl-D to exit.
history Show history of commands.
man ls Show the manual for the ’ls’ command.
man cat Show the manual for the ’cat’ command.
man scanf Show the manual for the ’scanf’ function.
exit Log out of the VM (or Ctrl-D).

1
Git
This course will make heavy use of Git for managing assignments. You will receive your assignments via Git, and
you will submit all of your assignments via Git. You will receive feedback via Git as well. The full reference manual
can be found on the Git official site.

Initial git repository setup on the virtual machine. Start by telling git who you are by running
git config --global user.email "<yourname>@uconn.edu"
git config --global user.name "<Your Name>"

Then clone, i.e. get a copy of, the git repository we’ve set up for you by running the following command in the
home directory of your virtual machine:
git clone [email protected]:cse3100f18.<yournetid>

Git will dutifully create a directory called cse3100f18.<yournetid> that over the course of the semester will ac-
cumulate your labs and assignments in subdirectories like lab0, lab1, hw1, etc. You only need to perform these
initialization steps once.

Checking out assignments. Once you have cloned the repository, at the start of each lab or homework you will
need to checkout the provided template code. To do that you need to log into the virtual machine, change the
working directory to the git repository with:
cd cse3100f18.<yournetid>

then issue
git pull

This command “pulls” from the git server any updates that are pending for you. As soon as the command terminates
you should see new directories or files when you run the ls command. For instance, if you are about to start working
on assignment #1, running the pull command will create a new directory called “hw1” with all the files we share
with you. The updates will also include TA’s feedback on previous labs and assignments. You should run git pull
every time you log in to the VM. This will help prevent merge conflicts between commits. If you have any issues,
please notify your TA immediately!

Doing your work. After pulling the assignment you need to go to the corresponding directory using cd commands
and modify existing files and/or create new files (.c files, .h files, readme’s, make files, etc.) as required. Once done
you will need to 1) tell git about your changes; 2) commit the changes; and 3) push the changes to the master git
repository.

1) Staging the changes. If you’ve changed some files, created new ones, or deleted some files, you have to first add, or
stage, these changes for a commit. You can add single files by running
git add file_changed_or_created_or_deleted

You can include all modified files in a directory by using the following command in that directory
git add --all

To delete a file from your repository, do


git rm file_to_delete

You can check what files have been changed (and maybe should be committed) by doing
git status

2
2) Committing the changes. To commit the staged changes run a command like
git commit -m "I made some changes lab0!"
Make the message after -m as informative as possible. You can view all previous commits by doing
git log

3) Pushing the changes. Once you’ve committed some changes, you must run
git push
to have the changes ‘submitted’ to the server maintaining the master copy of your repository so we can access them.
If you do not add, commit, and push your work from the VM, we cannot grade it!

Text editors & your first C program!


You will use the VM to do all the work for this course. That includes editing text files. There are three primary
options for text editors: vim, emacs, and nano. Try each out and pick whichever you like the most. Go to lab0
subdirectory of cse3100f18.<yournetid> using cd commands and create a new file called myprogram.c. With the
text editor of your choice, edit myprogram.c to read as:
#include <stdio.h>

int main()
{
printf("Hello world!\n");
}
This is your first C program! Before your C code can be run, it must first be compiled. You can do so by running
cc myprogram.c
This will compile C code in a file called myprogram.c and will create an executable called a.out. You can optionally
specify the name of the executable
cc -o myexe myprogram.c
To run your program, do
./myexe
Please add, commit, and push your changes to myprogram.c so that we can see that you’ve successfully completed
this step!

Your second C program


Copy myprogram.c to myname.c. Then make necessary changes to myname.c so that compiling and executing it
generates the following output (replace Firstname Lastname with your first name and last name):
Hello world!
This is the 2nd C program written by Firstname Lastname.
Please add, commit, and push your changes to myname.c so that we can see that you’ve successfully completed the
lab!

Enjoy!

Please remember to add, commit, and push your changes! If you need assistance, ask your neighbor or your TA. If
myprogram.c or myname.c is listed when you do git status, or you see any commits waiting to be pushed, we don’t
have your code!

You might also like