Lab 1 Introduction to UNIX and C

Similar documents
Lab 1 Introduction to UNIX and C

Intermediate Programming, Spring Misha Kazhdan

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

CS CS Tutorial 2 2 Winter 2018

CSC111 Computer Science II

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Lab 1: Introduction to C, ASCII ART & the Linux Command Line

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

p1: Fortune 1. Overview 2. Learning Goals 3. Logistics 4. Linux commands

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

You should see something like this, called the prompt :

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Tutorial 1: Unix Basics

Unix Basics. Systems Programming Concepts

CS 261 Recitation 1 Compiling C on UNIX

AMS 200: Working on Linux/Unix Machines

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Lab 2 Building on Linux

CMSC 201 Spring 2018 Lab 01 Hello World

CS Operating Systems, Fall 2018 Project #0 Description

Introduction: What is Unix?

Parallel Programming Pre-Assignment. Setting up the Software Environment

CS 460 Linux Tutorial

Exercise 1: Basic Tools

Getting started with UNIX/Linux for G51PRG and G51CSA

CMSC 201 Spring 2017 Lab 01 Hello World

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

C++ Programming on Linux

9 and 11-Jan CSCI 4152/6509 Natural Language Processing Lab 1: FCS Computing Environment, SVN Tutorial. FCS Computing Environment, SVN Tutorial

Session 1: Accessing MUGrid and Command Line Basics

Intro to HPC Exercise

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Temple University Computer Science Programming Under the Linux Operating System January 2017

CS Fundamentals of Programming II Fall Very Basic UNIX

CS1600 Lab Assignment 1 Spring 2016 Due: Feb. 2, 2016 POINTS: 10

Helpful Tips for Labs. CS140, Spring 2015

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

COMP s1 Lecture 1

LAB #5 Intro to Linux and Python on ENGR

15-122: Principles of Imperative Computation

User Guide Version 2.0

Introduction to Linux

CENG393 Computer Networks Labwork 1

COSC UNIX. Textbook. Grading Scheme

Laboratory 1 Semester 1 11/12

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

CSE 351. Introduction & Course Tools

Recitation #1 Boot Camp. August 30th, 2016

Introduction. File System. Note. Achtung!

Lab 1 1 Due Wed., 2 Sept. 2015

Introduction to Linux Environment. Yun-Wen Chen

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

Short Read Sequencing Analysis Workshop

Linux Tutorial #1. Introduction. Login to a remote Linux machine. Using vim to create and edit C++ programs

Lecture # 2 Introduction to UNIX (Part 2)

Practical Session 0 Introduction to Linux

Part I. Introduction to Linux

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Getting Started With UNIX Lab Exercises

1. The Mac Environment in Sierra Hall 1242

Linux File System and Basic Commands

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

last time in cs recitations. computer commands. today s topics.

Lab: Supplying Inputs to Programs

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

1. The Mac Environment in SIE 1222

Linux Introduction Martin Dahlö

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

Introduction to Linux

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Lab 1: Introduction to Linux Networking

Assignment 1: Build Environment

Spring 2017 Gabriel Kuri

Unit 10. Linux Operating System

Programming and Data Structure Laboratory (CS13002)

Recitation #1 Unix Boot Camp. August 29th, 2017

Introduction to Algorithms and Programming I Lab. Exercises #1 Solution

Setting up my Dev Environment ECS 030

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

New User Tutorial. OSU High Performance Computing Center

Introduction to the Linux Command Line

bwunicluster Tutorial Access, Data Transfer, Compiling, Modulefiles, Batch Jobs

Mills HPC Tutorial Series. Linux Basics I

Introduction to Linux. Fundamentals of Computer Science

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

bwunicluster Tutorial Access, Data Transfer, Compiling, Modulefiles, Batch Jobs

Problem Set 1: Unix Commands 1

Using WestGrid from the desktop Oct on Access Grid

Transcription:

Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. NOTE: Text in UNIX is case-sensitive. CS449 is different from cs449 is different from Cs449. All filenames of concern in this lab are lowercase. Please follow the instructions as listed in this document. Here are a few common UNIX commands: cd change directory ls list all files in current directory pwd display the current directory mv move or rename a file cp - copy a file gcc compile a c file nano edit a text file Part I 1) To login to the computers, you will need to use an SSH client. The SSH client that we will be using is Putty (at home, download from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ) We will connect to the machine (host) thoth.cs.pitt.edu 1) When you login first, you are placed in your home directory. The command ls will LiSt all of the files and directories there. The one we are most concerned with is the private directory. It is special in that only you can access files inside this directory. It will keep your work safe from other people. 3) Let s move into the private directory so we can work there: cd private

Changes Directory to the private directory 4) For this class, we ll keep all of our files organized into a cs449 directory. Make it by typing: mkdir cs449 If you want to double check that it worked, type ls to list. 5) We now want to move into the cs449 directory to do our actual work. cd cs449 Part II. 1) While still in the cs449 directory type: mkdir lab1 cd lab1 to make a directory for today s lab. Now type: nano lab1.c nano is a very simple text editor, a lot like Notepad on windows. It is one option for creating and editing code under UNIX/Linux.

2) Type the following text in exactly as it is shown: #include <stdio.h> int main() { printf( Hello World!\n ); return 0; } 3) Save the file by hitting Ctrl + O and then enter. Exit nano by typing Ctrl + X. At the bottom of the nano window, it shows what keys do special things. The ^ means to hold Ctrl while pressing the key 4) Back at the prompt type: gcc o lab1 lab1.c which will make our program. A file named lab1 will be in the directory if we type ls 5) Run it by typing:./lab1 Part III: Archives and Project Submission Whenever you turn in a project for this course, you will need to submit a copy of your code and executable to be graded. We will try this now. You are probably familiar with a ZIP file, which does two things: it archives a bunch of files into a single file, and also compresses it to save space. In UNIX, we do this in two steps, we create a Tape Archive (tar) and then compress it (gzip). First, let us go back up to our cs449 directory: cd.. Now, let us first make the archive. Type your username for the USERNAME part of the filename: tar cvf USERNAME_lab1.tar lab1 And then we can compress it: gzip USERNAME_lab1.tar

Which will produce a USERNAME_lab1.tar.gz file. We will then copy that file to the submission directory: cp USERNAME_lab1.tar.gz ~wahn/submit/449 Once a file is copied into that directory, you cannot change it, rename it, or delete it. If you make a mistake, resubmit a new file with a new name, being sure to include your username. Part IV: Manual Pages If you ever want to see how a command works or you forget the various options you could use, you can consult the man pages on the command by typing: man COMMAND for example: man ls This will let you scroll through the online help about the ls command. The SPACE BAR will scroll the document one screenful at a time and the ENTER key will move one line at a time. At any time you can quit by pressing q In the space below, explain the purpose of the -S switch (capital S, not lowercase.) 1.) Part V: Recording your work with script Sometimes something will go awry in your program and you may not know the source of an error message from the compiler. For us to help you, we need to see the output of the compiler. We can capture that with a program called script. Type: man script

now to read up on how it works. Now open the lab1.c file from part I by navigating to it and then opening it in nano. Remove the semicolon after the printf() statement and save. Now issue the script command. script Then compile the modified program. gcc lab1.c This should result in an error message. Type exit or hit CTRL + D to stop script from recording. If you do an ls now, you should see a file named typescript. We can use the program called more to display the contents of this file. more is also used on the man pages, and can be operated in the same way. If the file is longer than the screen, it will allow you to scroll or to quit at anytime. Type: more typescript to see the output you saw when you compiled the first lab. Helpful Hints Keep this sheet as a guide until you get comfortable in UNIX Every time you want to write a program you will do the following after logging into your account: cd private cd cs449 If you want to use vim or emacs instead of nano, that is fine. You may prefer to edit files under a GUI and use ftp to upload files, the choice is yours, however we will only officially support the steps described here. Remember: Case matters!