Lab 02 Pre Lab

Prior Assignments

Before going to Lab 02, you should have completed and understood both Lab 1 and Homework 0. You should have already created directories for your 201 files, including the main 201 folder, directories called Labs and Homeworks, and directories inside those with appropriate names (e.g., hw0, lab1, etc.).

Commands in GL

You should already know a number of commands that you can use in GL's command line (the "terminal") from the previous assignments. We will briefly cover those, and will introduce a few other useful commands as well. You are not expected to master all of these, or to do so immediately — we are simply reminding you that these tools exist.

Command Purpose and Example Usage
cd Change your current directory
Usage: cd lab2 to move to the lab2 directory
(Use cd .. to move up one directory; use cd alone to go back to your home directory)
ls List the contents of the current directory
mkdir Create a new directory
Usage: mkdir lab2 to make a new lab2 directory if it doesn't already exist
mv Rename a file (i.e., "move" the file to a new name)
Usage: mv will rename the file from to
pwd Print the full path of the "working" (current) directory
submit Allows you to submit assignments over GL
Usage: submit cs201 HW1 hw1.txt submits the file hw1.txt to the HW1 assignment for the cs201 class

All of the commands above you've seen before. Here are some new commands that you might not have used yet, but that can be very helpful.

Command Purpose and Example Usage
cp Create a copy of an existing file
Usage: cp existingFile.txt newFileName.txt will create a copy of the existing file, and name the copy "newFileName.txt"
clear "Clears" your screen by shifting your previous commands and output upward; you can still scroll up using the mouse or scrollbar
"TAB" Hitting the tab key will autocomplete based on the available file or directory names. For example, typing "emacs la" and hitting tab will autocomplete "la" to "" if the file exists
"up arrow" Hitting the up arrow will recall your previous command to the terminal. Hitting it again will pull up the command before that one; repeat as necessary.

There are many more useful commands that you can use in GL, and we'll mention them as they come up during the semester. If you see your TA or instructor using a command or shortcut that you don't know and would like to be able to use, ask them to explain it to you!

Shortcuts for emacs

Finally, let's cover some basic emacs shortcuts. Again, you will already know some of these from doing previous assignments, but some of them will also be new to you. You do not "need" to know any of them beyond the first two (how to save your file and how to exit emacs), but mastering a few more will make your programming experience more enjoyable.

Command Purpose and Example Usage
CTRL+X, CTRL+S Save the file and stay in emacs
CTRL+X, CTRL+C Save the file and close emacs
CTRL+_ Undo your last edit; use it again to undo the previous one as well
(Control+Shift+"-" to create an underscore)
CTRL+K Remove everything on the line after the cursor ("kill")
CTRL+Y Paste the line cut by the CTRL+K command ("yank")
CTRL+A Move the cursor to the beginning of the current line
CTRL+E Move the cursor to the end of the current line