CS 246 Winter 2015 - Tutorial 1 January 11, 2016 1 Summary General Administration Stuff CS Undergraduate Environment Useful Software Basic Commands.profile Text Editors 2 General Administration Stuff Course E-mail: cs246@uwaterloo.ca Use Piazza for most questions Questions containing potential solutions should be private or asked in office hours If your question is made private by an instructor - keep it that way E-mail the course account or post on Piazza about topics you would like to see in upcoming tutorials This course uses git as a mechanism for distribution of assignments, lecture material, and tutorial material. Instruction on how to setup git are part of A0. 1
3 CS Undergraduate Environment Create a Password Logging into the CS Undergrad Environment requires a password that is separate from your uwaterloo password. https://www.student.cs.uwaterloo.ca/password/ Although you require the Internet to interact with the environment it also has a number of benefits including: regular back-ups, pre-installed required software and most importantly there are no compatibility issues with marmoset. 4 Useful Software 4.1 Linux Terminal: 1. Open a Terminal. 2. Execute the command ssh userid@linux.student.cs.uwaterloo.ca 3. Enter your CS environment password when prompted. 4. Done. Most Linux distributions also come pre-installed with most of the tools you will use in this course (e.g. vim, ssh, scp) Note: You may need to separately install git if you want to checkout a local version of the repository. 4.2 Mac Terminal: Every Mac has a Terminal which runs a text interface for Unix. Follow the same steps as for a Linux Terminal. Note however, you will need to install XQuartz for later assignments which can be downloaded here: http://xquartz.macosforge.org/landing Note: You may need to separately install git if you want to checkout a local version of the repository. 2
4.3 Windows You only need to use one of the following options: PuTTY (Recommended) An ssh client which can be downloaded for free Requires Internet access For convenience use the host name userid@linux.student.cs.uwaterloo.ca and save this session. You will likely want to install Xming (http://sourceforge.net/projects/xming) onto your local machine; it will be used later in the course for some assignments. WinSCP (http://winscp.net/eng/index.php) is used to copy files (like assignments) from your Linux account to your local machine. machine. Cygwin Provides a Unix-like environment and command-line interface for Windows. Can work without Internet access When installing Cygwin, you will need to install a number of packages including: x11, vim, g++, gdb, make, git, and ssh. Different OS Virtual Machine Dual Boot Go to one of the labs on campus http://www.apple.com/ca/mac/ **this link is included for completion and humor and does not represent an endorsement nor condemnation of the product. Humorous complaints about the above link may be directed to mathnews@gmail.com*** 5 Basic Commands Shell Commands vs System Commands Basics: Shell commands are executed by the shell System commands are called by shell (versus executed by shell). exit: terminates shell 3
echo: write arguments, separated by spaces and terminated with newline. cat: prints files. pwd: Displays absolute path to your current working directory. ls: Lists contents of your current working directory The -l option can be taken in as an argument to ls to print a detailed list of content in your current working directory. This is particularly useful since it allows you to determine what is a file and what is a directory. With the -a option both hidden and non-hidden files are displayed. cd: Changes your current directory to the one indicated by the path. example: cd cs246/1161 Relative vs Absolute Path Relative Path: The path from your current directory to another file or directory. example: cs246/1161 Absolute Path: A path from the root of the file system to a particular file or directory. example: /bin Hidden Files Hidden files are denoted with a dot at the start of the file name. To view hidden files you will need to use the -a option with the ls command. 6.profile When you log into the CS environment there are a number of files that get executed. One of these such files is.profile which sets up what your prompt looks like and executes any additional code that you add to it. For convenience modify.profile to execute the command source /u/cs246/setup every time you log in (read A0 to find why this is useful) 1. vim.profile 2. Add the command source /u/cs246/setup to the bottom of the file 3. Save the file What would happen if a friend added the following two lines to your.profile alias ls= echo troll/space.bash alias cd= echo LOL! Nice try 4
7 Text Editors Why not use Notepad? Functionality is the set of operations provided by an editor to display and affect change. The more powerful the functions and the more they can interact, the faster a user can perform required tasks. An interface (i.e. text-based, graphical, etc.) is the mechanism used to invoke the functionality of the text editor and is largely (but not wholly) independent of the functionality You should choose a text editor with a high degree of functionality and integration that has an interface that suits you. Both Emacs and Sublime Text have a high degree of functionality and integration but with drastically different interfaces. Recommended: Emacs (https://www.student.cs.uwaterloo.ca/ cssystem/emacstutorial.pdf), Sublime Text 3, Vim Incomplete list of desirable features: Multiple Undo, Multiple Windows, Auto Indentation, Searching, Layouts, Backup Files, Syntax Highlighting and Integration with other software (i.e. compilers, command line, debuggers) 8 Misc. If you are using a terminal on your local machine to access the undergraduate environment you can you the command scp to transfer files between the two systems. The following is an example of how to copy a file from your local machine into your home directory on the undergraduate environment scp path/file.txt userid@linux.student.cs.uwaterloo.ca: /file copy.txt 5