Getting Started Guide: 1 CS Undergraduate Environment
Getting Started Guide: 1 CS Undergraduate Environment
1 CS Undergraduate Environment
• To log into the CS Undergrad Environment, you need to set up a password that is separate from your WatIAM/Quest
password.
– Go to https://www.student.cs.uwaterloo.ca/password/ to set up your password.
Read the instructions for choosing a password, then type your password in the first box. When you are finished
typing in the box, read the message to the right of the box to determine if your password is acceptable according
to the requirements.
If it is not, you must try again until you get “Looks OK!” Retype your new password in the second box. When
you get “Looks OK!" you can save your password by clicking the “Save" button.
• Connecting to the Undergrad Environment requires Internet access (and can sometimes be a little slow) but it has
several benefits:
– Regular (hourly, nightly, weekly) backups of your files.
– Required software is pre-installed.
– Exact replica of the environment in which our testing system (Marmoset) works. If your submission works in the
undergrad environment, it will work on Marmoset.
2.2 Mac
• Every Mac has a Terminal application that runs a text interface for Unix. Open the Terminal application and then use
the ssh command discussed above.
You should be prompted to enter your password. Enter your password that you just set up previously and press enter.
You will not see the characters entered, and your cursor will not move as a security feature.
2.3 Windows
You only need to use one of the following options but you could try a few to see which one you like.
1. Using Command Prompt
• Every Windows installation comes with the Command Prompt application. Open this application and then use the
ssh command discussed above.
1
• Note that this Command Prompt is not running bash. While a few bash commands might work, it is not a
substitute for bash.
2. Putty (Recommended as it is the oldest and most stable way.)
• This is an ssh client that can be downloaded for free here: https://putty.org/
• Open PuTTY.
• In the Host Name field enter linux.student.cs.uwaterloo.ca (press Save to save this session for later use).
• In the sidebar under SSH, click X11.
• Click the box that says “Enable X11 forwarding”.
• Press Open.
• Enter your CS username and password.
• Again, it may appear that nothing is happening when you type your password but your keystrokes are being
hidden for privacy.
3. Linux bash shell on Windows 10.
• The 64-bit install of Windows 10 now supports a Linux subsystem. While there have been some stability issues,
it has now become sturdy enough to gain a recommendation.
• You would need to enable the "Windows subsystem for Linux" and then install the Ubuntu app from the Microsoft
Store.
• The following link provides useful step by step instructions
https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
4 Text Editors
There are several different command line text editors that you can use.
• We recommend vi/vim.
– vi/vim has a pretty steep learning curve. However, once you master it, it greatly increases productivity.
– We highly recommend looking up a "vi cheat sheet" and even printing it out.
– Enter the command vimtutor on the command prompt to start the vim learning tutorial (Press Esc :q to quit).
– To start vi, enter the command vim file on the command prompt to create or edit an existing file named file.
• Other options are emacs, pico, nano. Nano is relatively easy to use if you find vi/vim too difficult to learn.
• In addition, there are graphical text editors that are handy (e.g. gvim, gedit). These are likely to run slowly if run on
a remote machine like the student Linux accounts.
• Do NOT use software like Microsoft Word and other Rich Text Editing software since they often embed characters not
recognized by compilers.
2
4.1 A very short nano tutorial
3. Press Ctrl + O to save your code. (Notice the prompts displayed at the bottom of Terminal; “^" means the Ctrl key.)
4. Press Ctrl + X to Exit.
5. Press Y to save.
6. Press the Enter key.
• However, you can create your own repositories on the UW git server that will allow you to push and pull to your heart’s
desire. See git.uwaterloo.ca for additional information.
• If you wish to make a repository on the UW git server, it must be set to private. Failure to do so can lead to severe
academic integrity violations including course mark deduction, suspension or expulsion.
3
6 Copying files
If you are working in the Linux environment provided by the School, there might be times when you want to copy files from
this remote machine to your local machine. How you do it will depend on which computer/OS you are using and how you
chose to connect to the Linux environment:
• Open a terminal and run the command man scp. This gives you the manual entry for the scp command. Read it.
This will copy the file(s) from the source location to the destination location. Each of source and destination can
be of the form [[user@]host1:]file1. Some examples follow:
– scp hello.c linux.student.cs.uwaterloo.ca:cs246/. copies file hello.c from the current directory of the local
machine (on which this command is being executed) to the cs246 directory on the linux.student.cs.uwaterloo.ca
remote location. It assumes that the userid on both the local and remote machines is the same.
– scp [email protected]:cs246/1205/a0/a0.pdf . will copy the file cs246/1205/a0/a0.pdf
from jsmith’s student account to the current directory (note the . to indicate the current directory) on the com-
puter this command was executed.
4
Explanation: The first command creates a folder where your account will be mounted. Your files will show up in
these folders. The -p means "do nothing if the folders already exist." This only needs to be done once, unless you’re
working in the Mac labs where your environment is temporary.
The second command mounts your own account to the folder ∼/yourQuestID. After connecting, an icon may appear
on your desktop with the name yourQuestID-ssh that you can double-click upon to see your own files.
2. Your account should show up as drives on the Desktop. If not, they should show up in your home folder (go to the
Finder menu bar, click Go then Home). You can disconnect from the account by right-clicking the drive/folder, and
choosing Eject.
3. (optional): To save time, you can copy-paste the 3 commands into a file such as sshfs.sh (if you’ve set up an SSH key,
you’ll only need the first 2 commands). Then run the commands by typing:
bash sshfs.sh
This way, you won’t have to type the commands each time you log back in to a lab Mac. If you’re not using the Mac
lab, it’s probably easier to just set up the second command as an alias.
1. git checkout
This applies to materials provided to you via the repository. If you are missing filename then you can recover the file
using git checkout filename in the directory that the file is suppose to be located within.
This also works for entire directories, and will recursively recover the whole directory. This method does not work for
files you’ve created, as it only works on files we upload to the repository.
2. .snapshot
This method is for files that you’ve created, but it only applies if you’ve done your work in the CS student environment.
You can go into the snapshot folder using cd .snapshot in the folder where the file was, and then using ls, you can
see weekly, daily, and hourly backups of that directory. Note that the .snapshot directory will not be listed if you use
the ls -a command.
You can then cd into those backups, to see a read-only copy of the directory at the time the snapshot is made. From
there, you can cp the past version of the file back to your original folder.
Since the most frequent update is hourly, you may lose up to an hour of work.
You can use a version control to make more frequent, on demand backups. If you choose to do so, we strongly recommend
UW Gitlab. If you use version control, you must set your repositories to private, or risk violating academic integrity.
This is especially important if your code is hosted on external servers such as GitHub.
Note that submitting to Marmoset also acts a a backup system, since you can download your submissions from there.
8 Zipping files
If you are submitting more than one files, you can use the command zip to create a ZIP file. ZIP is a compression and file
packaging utility for Unix. Each file is stored in single zip file with the extension .zip. zip compresses the files to reduce
5
file size and is also used as file package utility. zip is available in many operating systems like Unix, Linux, Windows etc.
See man zip for the manual page on how to use it.
Be careful how you create the ZIP file; Marmoset generally doesn’t want the entire directory structure to be zipped, just
the files, and you will fail the Marmoset tests. The best way to ensure that you’ve done it correctly is to copy your ZIP file
to a clean directory and unzip it. Also, ZIP by default adds files to an already existing ZIP file, so if your ZIP file contains
files it shouldn’t, you will need to delete it and create it again.
Syntax :
9 Valgrind usage
9.1 Valgrind Basics
https://www.youtube.com/watch?v=D4G2JcA0UXE
10 Miscellaneous
• Press on the up arrow to see previous commands