Lab 0 (Jan 9_12) - COMP-1001-001_002_003_056 (Intro to Programming & Laboratory)

.pdf

School

Memorial University of Newfoundland *

*We aren’t endorsed by this school

Course

1001

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

9

Uploaded by rami_h

4/1/24, 8:26 AM Computer Science 1001 - Lab 0 https://online.mun.ca/d2l/le/content/567611/viewContent/5087542/View 1/9 Computer Science 1001 - Lab 0 Chapter 1 Basic Information for Linux Users This lab discusses: logging on to the system the Linux operating system organizing your work on your computer downloading the files for the lab using the programming environment preparing for the next lab logging off In order to answer each online multiple choice question, click on the down arrow of the box containing the possible answers and click on the one you think is correct. When you have answered the questions, click on the Check My Answers button to determine how many questions you have answered correctly. The Dismiss Results button closes the results window. The Reset button sets all the answers back to the default values. If the question is a fill-in-the-blank instead of a multiple choice, you simply have to click in the blank box and type your answer; then click on Check My Answers . If you think an answer to an electronically tested question is incorrect or you are having trouble with a particular topic, please contact one of the lab assistants for help. When checking your answers online, you may click on the Check My Answers button after you answer each question or when you have finished answering all the questions for that section. It does not matter if you get answers wrong or send your answers many times; the results are not recorded. Readings Objectives Notes Lab Exercises 1. Lab setup. Each lab contains exercises to be completed prior to or during the lab period. You should read and study these exercises and any code provided for them before the lab session. Also write out as much as you can of your solutions before the lab; then lab time can be devoted to completing your solutions and making any necessary fine tuning adjustments.
4/1/24, 8:26 AM Computer Science 1001 - Lab 0 https://online.mun.ca/d2l/le/content/567611/viewContent/5087542/View 2/9 The PCs in the lab room on campus are configured to run with the Linux operating system. For the COMP1001 labs, Linux , a free implementation of UNIX for personal computers, is the system of choice. Linux allows multiple windows in operation at the same time, each running a different application. The labs for COMP1001 use three principal applications: the Google Chrome web browser, a shell (terminal) window, and the Python Integrated DeveLopment Environment (IDLE). All of these applications are run on top of a window management system. The window management system presents a desktop environment for the launching of applications and for the display of the user files. Quick access to the applications is provided by the panel to the left on the screen, which is accessible by clicking on Activities in the top left. This environment can also be set up to provide different workspaces. A shell window (often referred to as the command prompt ) may be used to manage directories and files on your disk space and to run Python or IDLE . In order to start a shell window, click on the Activities button in the top left- hand corner of the screen, then start typing "terminal" in the search box. Click on Terminal (probably the first option on the left, or one of the other terminal options). The terminal may also be available from the panel on the left. Alternatively, simultaneously touch the Alt and F2 keys on your keyboard, then, when the Enter a command dialog box appears, type gnome- terminal and touch the Enter key to select the default choice --no mouse required! In order to start Google Chrome , click on the Activities button in the top left-hand corner of the screen, then start typing chrome and click on Google Chrome . (You may need to cancel a pop-up window for the login keyring, several times.) Note: If you have any problems during any of these steps, please feel free to ask one of the lab assistants for help. 2. (Optional) Installing Python 3 at home. You may also want to install Python on your home computer so that you can work on programs offline. Follow the instructions for Installing Python 3 to install Python (including IDLE) at home. 3. (Optional) Remote access to your files. You can also connect to departmental servers remotely to access files from your MUN account. Follow the instructions for Remote Access to Linux from Off Campus to install software on your home machine to connect to a server on campus. 4. Linux commands.
4/1/24, 8:26 AM Computer Science 1001 - Lab 0 https://online.mun.ca/d2l/le/content/567611/viewContent/5087542/View 3/9 A shell window gives you complete access to all the Linux commands. A command line interpreter is running in the shell window, waiting to carry out your commands. If you need to connect to our servers remotely, knowing some Linux commands may become useful. A few common commands which are useful for COMP1001 are shown in the following table. Use those commands to do the exercises below: Some Linux Commands Command Action mkdir dir creates directory dir cd dir makes dir the current directory pwd shows full path to current directory rmdir dir removes directory dir , provided it is empty ls lists contents of current directory command --help displays some info about command cp file1 file2 copies file1 to file2 mv file1 file2 renames file1 as file2 rm file (irreversibly) removes file ; use the -i option, e.g. rm -i file , to get a displayed prompt confirming removal python3 or sometimes just python invokes the Python 3 interpreter (just using "python" may invoke version 2 - or earlier - depending on the version of Linux you are using) idle runs the Python Interactive DeveLopment Environment ( idle & runs it in the background and shows the command prompt again) ssh machinename make this a secure shell window on machinename Start a shell window and terminate it by typing exit at the command prompt. Start a shell window and terminate it by clicking its Close Button --the X in the window's title bar. Start a shell window. Your home directory has a longer name, but it is also known to Linux as ~ . Make sure your current directory is your home directory by giving the command cd ~ and checking the result with the pwd command. Try the command mkdir --help . Create a subdirectory called comp1001 in your home directory to store all of your course files. make sure you are in your home directory by typing: cd ~ type the command: mkdir comp1001 Create a subdirectory called lab00 in your comp1001 directory to store your Lab 0 files, and go into that directory. change into your comp1001 directory by typing: cd comp1001 type the command: mkdir lab00 make ~/comp1001/lab00 your current directory by typing: cd lab00 Download the source code file for this lab, available here , and save the file to your ~/comp1001/lab00 folder. If the file saves automatically to your Downloads folder, you may need to use the following command to move the file to your lab00 folder:
4/1/24, 8:26 AM Computer Science 1001 - Lab 0 https://online.mun.ca/d2l/le/content/567611/viewContent/5087542/View 4/9 type: mv ~/Downloads/FirstTurtle.py ~/comp1001/lab00/FirstTurtle.py In addition to ~ , some other useful abbreviations in pathnames are . and .. . represents the current working directory .. represents the parent directory of the current working directory move back to the parent directory of your current directory by using the command: cd .. 5. Understanding some of the common Linux commands. Given the directory structure below, answer the following questions (ask the lab assistants for help if you need it!): 5.1 Choose the single Linux command to remove the file called file1 if your current directory is ~/cs2700 . ! 1. rm ~/cs2700/assign2/part1/file1 2. rm assign2/part1/file1 3. rm file1 4. rm ~/part1/file1 5. either 1 or 2 5.2 Choose the single Linux command to change into the directory lab2 if your current directory is ~/ . ! 1. cd ~/notes/lab2 2. cd cs2700/lab2 3. cd cs2700/notes/lab2 4. cd ~/lab2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help