23. Check that hello.txt now contains (substitute your info for mine): hello rcwhaley: Dr. Whaley

Size: px
Start display at page:

Download "23. Check that hello.txt now contains (substitute your info for mine): hello rcwhaley: Dr. Whaley"

Transcription

1 Assignment 0: Basic Unix Exploration Due: Monday 01/14/2018 (before class) In this assignment, you will become familiar with a few tools required to work in the Unix environment. Take your time, and try to understand each step as fully as possible, since its purpose is for you to learn how to use the programming environment used in the class. There is no need to finish it one sitting. To do this work, you will need to log into the Linux machines at burrow.soic.indiana.edu. All common OSes have methods of getting remote terminal access: Linux/OS X: use ssh. Open up a terminal window, and type: ssh -X username@burrow.soic.indiana.edu Windows: install and use PuTTY from the course website. In doing the following, I will tell you what to do and the command to do it. You need to understand what you are doing and remember the command since I will only tell you once. I also suggest that you read about these commands in your book, or on the web (via the main page links and/or googling them), or by reading the Unix man page via the man command. The man page gives relatively complete information, and are written in a bit intimidating style, which you will become used to over time. Directory heirarchy operations: 1. Log in as outlined above 2. After logging in, check what your current directory is by using pwd (print working directory). After login, your working directory should be your home directory, which in my case is: /nfs/nfs6/home/rcwhaley. The output of pwd is the full path to your home directory. 3. Create a subdirectory (AKA a folder) under your home directory with the command mkdir courses 4. Read about the mkdir command with man mkdir 5. Create a subdirectory called oops. 6. Look at all the files/directories in your current directory with the command ls -CF. Do you see the courses & oops subdirectories that you created above? Execute ls -l to see more information on the files/directories in your home directory. Read a little of the man page to see what information this command is telling you. 7. Delete the directory oops using the command rmdir oops. Read the man page for rmdir. 8. Change directories to your courses subdirectory with the command cd courses. Note that if you type the first several letters of a file or directory, and then hit tab, your shell can auto-type the rest of the filename for you! 9. Make the directory ISE under your courses directory. 10. Change directories to your ISE directory. 11. Make the directory 111 under your ISE directory. 12. Change directories to your 111 directory. 1

2 13. Change to your home directory using cd. Notice that a cd with no arguments changes to your home directory. The tilde (~) is shorthand for your home directory, so instead of referring to my courses directory as /nsf/nsf6/home/rcwhaley/courses I can use ~/courses. 14. Make an alias, cd111, to change directories to your newly created 111 directory with the command: alias cd111="cd ~/courses/ise/111" Thus, when you type cd111 it will be replaced by the shell with the cd command on the right. Notice that this only works in the shell in which the alias was executed (i.e., if you open up a second terminal window, or log out of this one, then you must create the alias again to be able to use it). 15. Change to your 111 directory with cd111, verify that you are there with pwd. 16. Create a subdirectory of 111 called asg Change to your home directory and make a subdirectory tmp where you can play with stuff that you will delete later. 18. Change directories back to your cd asg0 19. Create a file containing the word hello using the echo command along with redirection: echo "hello" > hello.txt 20. Display the contents of the created textfile one line at a time using the cat command: cat hello.txt 21. Read the man page on cat. 22. Now, let s add a line to hello.txt that maps your user name to your real name. Issue: echo "login: my_name" >> hello.txt Make sure you replace login with your login name (as shown in your path), and my name with your actual name. For instance, I would put: echo "rcwhaley: Dr. Whaley" >> hello.txt 23. Check that hello.txt now contains (substitute your info for mine): hello rcwhaley: Dr. Whaley 24. Change back to your home directory, and create a tarfile (like a zip file) of all directories and files you have created using: tar cvf courses.tar courses 25. If you are masochistic, horrify yourself by attempting to understand the man page on tar. 26. Move this file into your asg0 subdirectory: mv courses.tar courses/ise/111/asg0/.. When doing file operations, your shell (the program running in the terminal taking things you type and executing them for you) interprets the period in this statement to mean use the same filename it had in the other directory. 27. Change to your asg0 subdirectory. 28. Scope the size of the files using ls -l 29. Compress the tarfile using: bzip2 courses.tar 30. Scope the bzip2 manpage 31. Scope the size of the files now: courses.tar will now be smaller and be called courses.tar.bz2 32. Change directory to the tmp subdirectory under your home. 2

3 33. Untar your entire courses tree structure under /tmp using: bunzip2 -c ~/courses/ise/111/asg0/courses.tar.bz2 tar xvf Verify your courses directories and files are duplicated under tmp. 35. Delete only your hello.txt from tmp by issuing: rm courses/ise/111/asg0/hello.txt 36. Verify that that hello.txt is no longer there. 37. Delete everything in tmp, and all subdirectories under it, by using (the very dangerous!) recursive rm command: rm -rf ~/tmp 38. Scope the rm manpage. If you add the -rf argument, it will recursively delete all subdirectories without verifying that that is what you meant to do, so uh, be careful with that. 39. Submit your tarfile using canvas. The easist way is to copy the file from the remote machine (burrow) down to your local machine (your laptop or the lab computer), assuming you are logged into canvas on the local machine. If you are using Windows, the lab machines have a program called WinSCP which move files between networked computers. Search for it by going to start menu, and start typing winscp until it is shown on app list, then click it. Typically, you ll see your remote files on the right, and local files on left. Navigate to the file you want to transfer, and drag it to the filesystem and location where you will submit it to canvas. You can simply drag in other direction to copy from local to remote If you are running OS X (Apple), then you should know that Linux is an open source operating system that is a special variant of a family of OSes sometimes (not quite accurately) called Unix. OS X is actually a propriatary UI built mostly atop FreeBSD, another open source Unix. This means many things work almost the same on OS X as on burrow: If you install Xtools, you will get access to a compiler called gcc. Note, however, that this compiler isn t really gcc, but is instead Apple s version of another compiler, called clang, which is not standard compliant. Therefore, it allows you do things that are illegal in this class where real gcc on burrow will not. So if you use xtools to write some of your code, be sure to test it on burrow before submission, since all grading will be done on burrow, not OS X. Here s two examples of copying a file from burrow to my local machine that do the same thing: scp rcwhaley@burrow.sice.indiana.edu:tmp/makefile ~/tmp/makefile scp rcwhaley@burrow.sice.indiana.edu:tmp/makefile ~/tmp/. Note that scp assumes any argument with a : in it means it should contact the remote machine on the left of the :. The machine name goes from to the :, and left of in this argument is the user name. If your user name is the same on all machines given in arguments (in our example, local and remote machines), then you can omit both the user name and symbol. Note that you should understand the paths and filenames from prior work with files. If you can t fully understand the rest of this command, look back at prior steps you have done. To copy in other direction just reverse which argument has the :, i.e: scp ~/tmp/makefile rcwhaley@burrow.sice.indiana.edu:tmp/. scp works very similar to the cp command, but between networked machines. Read the man page for scp for more details. 3

4 Editing with vim If you work in systems, you will spend a huge amount of time editing various text files. Because of this, all Unix/Linux systems come with a variety of editors. Noobs will use simple editors like pico, which are easy to run, and have almost no power (like wordpad). When you edit files for a living, however, it is much better to use a much more powerful text editor. Historically, this has meant you either learn EMACS or vi. EMACS is for people who want to get a foot pedal to run control the key, or who are hoping to get carpal tunnel early. EMACS is what you get if your design philosophy is basically: swiss army knives really need features like a toupee comb, microwave, sat phone, and clothes washer/dryer added to them. vi is for those who like a tool that punches you in the face for an entire semester, before becoming the most powerful, natural, and easy on the the typing hands editing tool ever invented. It embodies the philosophy: a knife should cut through hardened steel effortlessly, have no safety features, and that s all it should do. You may use any editor you want, but I will only answer questions on vim, which is a modern version of vi. To get started on the face-punching phase: 1. Change to the ~/tmp directory, execute vimtutor and follow the directions in order to get an introduction to the vi editor (vim is one of the fanciest modern variants of Unix s original vi editor). 4

5 Compiling, executing, and debugging C programs: 1. Back in your asg0 subdirectory, type in the following C program into the file sumfile.c (vim sumfile.c if your face is holding up): Comments (started with and ended with ) are optional, and can be changed or ommitted without changing the program. * Typed in by <YOUR NAME> for asg0 E111 #include <stdio.h> #include <stdlib.h> #include <assert.h> int main(int argc, char *argv[]) all C programs must have main char *inf; variable FILE *fpin;... int tot; declarations char *GetFlags(int argc, char **argv); function int sumfile(file *fpin); protoypes inf = GetFlags(argc, argv); fpin = fopen(inf, "r"); assert(fpin); tot = sumfile(fpin); fclose(fpin); printf("total = %d\n", tot); return(0); 0 means normal (non-error) exit * Print usage and help info when commandline args are malformed, then exit void PrintUsage(char *name, int ierr, char *flag) if (ierr > 0) fprintf(stderr, "Bad argument #%d: %s \n", ierr, flag?flag:"out-of-arguments"); else if (ierr < 0) fprintf(stderr, "ERROR: %s\n", flag); fprintf(stderr, "USAGE: %s [flags]:\n", name); fprintf(stderr, " -i <input file>\n"); * Signal abnormal termination if (ierr!= 0) exit(ierr); else exit(-1); * This routine parses the commandline arguments provided to the routine 5

6 * in order to find out what file to read in. If no file is provided, take * the default name "num.dat" * RETURNS: file name to read numbers from char *GetFlags(int argc, char *argv[]) char *infile = "num.dat"; int i; * Loop over all commandline arguments, and parse those that make sense. If * a flag is unknown or badly formed, print usage information and abort * program execution while returning an error code. * NOTE: we don t parse argv[0] since that is the name of the program, * not a flag! for (i=1; i < argc; i++) * All flags must begin with -, or they are malformed. Notice we don t * have to prototype PrintUsage, since we put PrintUsage in the file first, * and so the routine definition serves as the prototype for following * invocations. This is more fragile than prototyping, since it depends * on routines appearing in a fixed order in the source. * NOTE: PrintUsage is never returned from since it calls exit() if (argv[i][0]!= - ) PrintUsage(argv[0], i, argv[i]); switch(argv[i][1]) only i legal value for this prog! case i : -i <input file name> if (++i >= argc) do we have required following arg? PrintUsage(argv[0], i-1, NULL); infile = argv[i]; break; default: any other flag is unknown! PrintUsage(argv[0], i, argv[i]); return(infile); * This routine reads all available integers from the open file fpin, * and returns the sum of all read-in integers int sumfile(file *fpin) int num, sum=0; while ( fscanf(fpin, "%d", &num) == 1 ) sum += num; return(sum); 6

7 2. Compile the program in sumfile.c calling the executable xsum, using the command: gcc -Wall -Wpedantic -ansi -g -o xsum sumfile.c This will compile the C file, create an object file and then link this object code to the C libraries all in one step to create the executable. The object code file will not be written to the user s directory in this case. Note that we could separate the compile and link steps by: (a) gcc -Wall -Wpedantic -ansi -g -c sumfile.c (compile sumfile.c to object file, stored as sumfile.o). (b) gcc -ansi -g -o xsum sumfile.o (link object file with system libs to create executable). In this case, sumfile.o will persist in user s directory until deleted manually. If our program is spread over multiple files, just repeat step-a for each file, and then list all files during step-b. 3. Create the file num.dat with numbers totalling 30 using the command: echo -e "1 2 3\n7 8 9" > num.dat 4. Check the contents of the file by: cat num.dat 5. Have your program add up the numbers by:./xsum -i num.dat 6. Run program on invalid data with:./xsum -i noexist.dat 7. Understand what assert is doing from this response, putting additional print statements in to aid understanding if necessary. 8. Understand why this works:./xsum -i noexist.dat -i num.dat 9. valgrind is an extremely useful program that looks for memory allocation errors. You should run valgrind on all your codes that do any kind of memory allocation. To do this, simply: valgrind --leak-check=yes --malloc-fill=0x88 --track-origins=yes./xsum -i num.dat 10. To avoid typing all that, use an alias like: alias vg=valgrind --leak-check=yes --malloc-fill=0x88 --track-origins=yes 11. Here is an step that will only work if you log in from OS X/Linux using ssh -X, if you are running Linux locally, or if you use PuTTY and Xming on Windows: Compile the program and follow its execution in the debugger: (a) The -g flag tells the compiler to include debugging info in the resulting object or executable file. If you are not debugging, you can substitute the -O (Optimize) flag for -g. (b) Start running under the graphical debugger using the command: ddd./xsum (c) You will see the ddd screen and in the source windows you will see your program. You can set a breakpoint (a place to stop execution) anywhere in the program by simply right clicking its line and choosing the break button. You can also issue this command manually in the command window by typing break <routine name> (eg., break main). (d) Begin execution by typing run followed by the arguments in the command window (eg., run -i num.dat). (e) Once you reach your breakpoint, use the next and step buttons/commands to watch the program execute. Notice you can see the value of variables by hovering over them with the mouse, or using the print command. 7

8 (f) Now set a breakpoint on the line: sum += num; in the loop by clicking on the line and then the break button. You should see a little red stop sign appear to the left of the line. (g) Any time that ddd has control (at a breakpoint, etc.), you can look at any of the variable values. So to see the current value of num, click on the variable in the program window, anywhere in the code, and then click the print button (or type print num in the command window). You will see the value printed in the command window. Look at the value of total: is it what you expected? (h) Click on the Cont button and execution will continue until the next loop iteration. Again look at num and total and ask if they have the expected values. Continue until program exit. (i) Now clear the break point inside the loop by clicking on the line and then clicking the Clear button. (j) To look at variable values, we need to pause and specifically print them out. It is simpler if we can just watch them change (assuming their aren t many variables). We can do this in the following way: i. Click on the dropdown menu, View, this shows various subwindows that are currently displayed. Click on Data Window. You will see a new subwindow on the top of your ddd display. ii. Type break sumfile to stop execution in the sumfile function. iii. type run (or hit the Run button) iv. Click on num in the code and then click the display tool button. num will appear in the data window with its present value, which is currently garbage since num has not yet been initialized. Do the same for total, make sure the data window is large enough for both to be seen (you an drag them to be side-by-side if you want). v. Now watch values change as you use Step to step through the execution.? When ddd stops at a break point, has the statement at the break point already executed or is it the next statement to be executed? play with debugger until you can use it well, setup your defaults to suit your style, etc. 12. Submit your sumfile.c using canvas. It is OK if it has no comments, except your name at top. 8

23. Check that hello.txt now contains (substitute your info for mine): hello rcwhaley: Dr. Whaley

23. Check that hello.txt now contains (substitute your info for mine): hello rcwhaley: Dr. Whaley Assignment 0: Basic Unix Exploration Due: Wednesday 01/15/2018 (before class) In this assignment, you will become familiar with a few tools required to work in the Unix environment. Take your time, and

More information

CSC111 Computer Science II

CSC111 Computer Science II CSC111 Computer Science II Lab 1 Getting to know Linux Introduction The purpose of this lab is to introduce you to the command line interface in Linux. Getting started In our labs If you are in one of

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C 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

More information

CMPT 300. Operating Systems. Brief Intro to UNIX and C

CMPT 300. Operating Systems. Brief Intro to UNIX and C CMPT 300 Operating Systems Brief Intro to UNIX and C Outline Welcome Review Questions UNIX basics and Vi editor Using SSH to remote access Lab2(4214) Compiling a C Program Makefile Basic C/C++ programming

More information

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

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry Intro to Linux and C CSCI 2400/ ECE 3217: Computer Architecture Instructors: David Ferry 1 Overview Linux C Hello program in C Compiling 2 History of Linux Way back in the day: Bell Labs Unix Widely available

More information

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

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016 Linux Boot Camp Jack, Matthew, Nishad, Stanley 6 Sep 2016 1 Connecting SSH Windows users: MobaXterm, PuTTY, SSH Tectia Mac & Linux users: Terminal (Just type ssh) andrewid@shark.ics.cs.cmu.edu 2 Let s

More information

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

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4 Beyond this course Readings: CP:AMA 2.1, 15.4 CS 136 Spring 2018 13: Beyond 1 Machine code In Section 04 we briefly discussed compiling: converting source code into machine code so it can be run or executed.

More information

Problem Set 1: Unix Commands 1

Problem Set 1: Unix Commands 1 Problem Set 1: Unix Commands 1 WARNING: IF YOU DO NOT FIND THIS PROBLEM SET TRIVIAL, I WOULD NOT RECOMMEND YOU TAKE THIS OFFERING OF 300 AS YOU DO NOT POSSESS THE REQUISITE BACKGROUND TO PASS THE COURSE.

More information

Laboratory 1 Semester 1 11/12

Laboratory 1 Semester 1 11/12 CS2106 National University of Singapore School of Computing Laboratory 1 Semester 1 11/12 MATRICULATION NUMBER: In this lab exercise, you will get familiarize with some basic UNIX commands, editing and

More information

COMP s1 Lecture 1

COMP s1 Lecture 1 COMP1511 18s1 Lecture 1 1 Numbers In, Numbers Out Andrew Bennett more printf variables scanf 2 Before we begin introduce yourself to the person sitting next to you why did

More information

Exercise 1: Basic Tools

Exercise 1: Basic Tools Exercise 1: Basic Tools This exercise is created so everybody can learn the basic tools we will use during this course. It is really more like a tutorial than an exercise and, you are not required to submit

More information

COMS 6100 Class Notes 3

COMS 6100 Class Notes 3 COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C 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. The doc is

More information

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

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

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

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C Welcome! Welcome to your CpSc 111 lab! For each lab this semester, you will be provided a document like this to guide you. This material, as

More information

Introduction to Supercomputing

Introduction to Supercomputing Introduction to Supercomputing TMA4280 Introduction to UNIX environment and tools 0.1 Getting started with the environment and the bash shell interpreter Desktop computers are usually operated from a graphical

More information

Development Environment & Linux Guide

Development Environment & Linux Guide Development Environment & Linux Guide Juwon Lee(jwlee@archi.snu.ac.kr) School of Computer Science and Engineering Seoul National University Development Environment MobaXterm Provide Linux-like environment

More information

Introduction to the Linux Command Line

Introduction to the Linux Command Line Introduction to the Linux Command Line May, 2015 How to Connect (securely) ssh sftp scp Basic Unix or Linux Commands Files & directories Environment variables Not necessarily in this order.? Getting Connected

More information

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX This handout very briefly describes how to use Unix and how to use the Linux server and client machines in the EECS labs that dual boot

More information

Session 1: Accessing MUGrid and Command Line Basics

Session 1: Accessing MUGrid and Command Line Basics Session 1: Accessing MUGrid and Command Line Basics Craig A. Struble, Ph.D. July 14, 2010 1 Introduction The Marquette University Grid (MUGrid) is a collection of dedicated and opportunistic resources

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

Intermediate Programming, Spring Misha Kazhdan

Intermediate Programming, Spring Misha Kazhdan 600.120 Intermediate Programming, Spring 2017 Misha Kazhdan Outline Unix/Linux command line Basics of the Emacs editor Compiling and running a simple C program Cloning a repository Connecting to ugrad

More information

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring 2019 https://passlab.github.io/csce212/ Department of Computer Science and Engineering Yonghong Yan yanyh@cse.sc.edu

More information

Unix and C Program Development SEEM

Unix and C Program Development SEEM Unix and C Program Development SEEM 3460 1 Operating Systems A computer system cannot function without an operating system (OS). There are many different operating systems available for PCs, minicomputers,

More information

Recitation #1 Boot Camp. August 30th, 2016

Recitation #1 Boot Camp. August 30th, 2016 18-600 Recitation #1 Boot Camp August 30th, 2016 Welcome to 18-600! Purpose of recitation Useful tools, information pertaining to the labs Hands-on activities Problem solving and exam prep Last ~30 mins

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

Lecture 7: file I/O, more Unix

Lecture 7: file I/O, more Unix CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 7: file

More information

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview Computer Science 322 Operating Systems Mount Holyoke College Spring 2010 Topic Notes: C and Unix Overview This course is about operating systems, but since most of our upcoming programming is in C on a

More information

Introduction to Linux. Fundamentals of Computer Science

Introduction to Linux. Fundamentals of Computer Science Introduction to Linux Fundamentals of Computer Science Outline Operating Systems Linux History Linux Architecture Logging in to Linux Command Format Linux Filesystem Directory and File Commands Wildcard

More information

You should see something like this, called the prompt :

You should see something like this, called the prompt : CSE 1030 Lab 1 Basic Use of the Command Line PLEASE NOTE this lab will not be graded and does not count towards your final grade. However, all of these techniques are considered testable in a labtest.

More information

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

Recitation #1 Unix Boot Camp. August 29th, 2017 18-600 Recitation #1 Unix Boot Camp August 29th, 2017 Welcome to 18-600! Purpose of recitation Useful tools, information pertaining to the labs Hands-on activities Problem solving and exam prep Last ~30

More information

Projects and Environment Introduction

Projects and Environment Introduction Projects and Environment Introduction A lot to go over today History of Linux Projects Overview Project partners Programming environment Programming language Useful Tools History of Linux The Beginning:

More information

Introduction: The Unix shell and C programming

Introduction: The Unix shell and C programming Introduction: The Unix shell and C programming 1DT048: Programming for Beginners Uppsala University June 11, 2014 You ll be working with the assignments in the Unix labs. If you are new to Unix or working

More information

Warm-up sheet: Programming in C

Warm-up sheet: Programming in C Warm-up sheet: Programming in C Programming for Embedded Systems Uppsala University January 20, 2015 Introduction Here are some basic exercises in the programming language C. Hopefully you already have

More information

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso A layer of software that runs between the hardware and the user. Controls how the CPU, memory and I/O devices work together to execute programs Keeps

More information

The Command Shell. Fundamentals of Computer Science

The Command Shell. Fundamentals of Computer Science The Command Shell Fundamentals of Computer Science Outline Starting the Command Shell Locally Remote Host Directory Structure Moving around the directories Displaying File Contents Compiling and Running

More information

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

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011) UoW HPC Quick Start Information Technology Services University of Wollongong ( Last updated on October 10, 2011) 1 Contents 1 Logging into the HPC Cluster 3 1.1 From within the UoW campus.......................

More information

CS CS Tutorial 2 2 Winter 2018

CS CS Tutorial 2 2 Winter 2018 CS CS 230 - Tutorial 2 2 Winter 2018 Sections 1. Unix Basics and connecting to CS environment 2. MIPS Introduction & CS230 Interface 3. Connecting Remotely If you haven t set up a CS environment password,

More information

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version... Contents Note: pay attention to where you are........................................... 1 Note: Plaintext version................................................... 1 Hello World of the Bash shell 2 Accessing

More information

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018 CMPUT 201: Practical Programming Methodology Guohui Lin guohui@ualberta.ca Department of Computing Science University of Alberta September 2018 Lecture 1: Course Outline Agenda: Course calendar description

More information

Lab: Supplying Inputs to Programs

Lab: Supplying Inputs to Programs Steven Zeil May 25, 2013 Contents 1 Running the Program 2 2 Supplying Standard Input 4 3 Command Line Parameters 4 1 In this lab, we will look at some of the different ways that basic I/O information can

More information

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

Introduction to remote command line Linux. Research Computing Team University of Birmingham Introduction to remote command line Linux Research Computing Team University of Birmingham Linux/UNIX/BSD/OSX/what? v All different v UNIX is the oldest, mostly now commercial only in large environments

More information

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

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University Unix/Linux Basics 1 Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal )

More information

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou EECS 2031 - Software Tools Lab 2 Tutorial: Introduction to UNIX/Linux Tilemachos Pechlivanoglou (tipech@eecs.yorku.ca) Sep 22 & 25, 2017 Material marked with will be in your exams Sep 22 & 25, 2017 Introduction

More information

STA 303 / 1002 Using SAS on CQUEST

STA 303 / 1002 Using SAS on CQUEST STA 303 / 1002 Using SAS on CQUEST A review of the nuts and bolts A.L. Gibbs January 2012 Some Basics of CQUEST If you don t already have a CQUEST account, go to www.cquest.utoronto.ca and request one.

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

CS Fundamentals of Programming II Fall Very Basic UNIX

CS Fundamentals of Programming II Fall Very Basic UNIX CS 215 - Fundamentals of Programming II Fall 2012 - Very Basic UNIX This handout very briefly describes how to use Unix and how to use the Linux server and client machines in the CS (Project) Lab (KC-265)

More information

CS 261 Recitation 1 Compiling C on UNIX

CS 261 Recitation 1 Compiling C on UNIX Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Compiling C on UNIX Winter 2017 Outline Secure Shell Basic UNIX commands Editing text The GNU Compiler

More information

Getting started with UNIX/Linux for G51PRG and G51CSA

Getting started with UNIX/Linux for G51PRG and G51CSA Getting started with UNIX/Linux for G51PRG and G51CSA David F. Brailsford Steven R. Bagley 1. Introduction These first exercises are very simple and are primarily to get you used to the systems we shall

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Command Line Interface The basics

Command Line Interface The basics Command Line Interface The basics Marco Berghoff, SCC, KIT Steinbuch Centre for Computing (SCC) Funding: www.bwhpc-c5.de Motivation In the Beginning was the Command Line by Neal Stephenson In contrast

More information

Tutorial 1 C Tutorial: Pointers, Strings, Exec

Tutorial 1 C Tutorial: Pointers, Strings, Exec TCSS 422: Operating Systems Institute of Technology Spring 2017 University of Washington Tacoma http://faculty.washington.edu/wlloyd/courses/tcss422 Tutorial 1 C Tutorial: Pointers, Strings, Exec The purpose

More information

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab Basic Terminal Intro to Linux ssh short for s ecure sh ell usage: ssh [host]@[computer].[otheripstuff] for lab computers: ssh [CSID]@[comp].cs.utexas.edu can get a list of active computers from the UTCS

More information

Introduction to UNIX I: Command Line 1 / 21

Introduction to UNIX I: Command Line 1 / 21 Introduction to UNIX I: Command Line 1 / 21 UNIX Command line The UNIX Shell: command line interface Navigating Directories and Files Running applications Reminder about helpful tutorial: http://korflab.ucdavis.edu/unix_and_perl/current.html

More information

Creating a Shell or Command Interperter Program CSCI411 Lab

Creating a Shell or Command Interperter Program CSCI411 Lab Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell

More information

CSE 351. Introduction & Course Tools

CSE 351. Introduction & Course Tools CSE 351 Introduction & Course Tools Meet Your TA TA Name Interesting information examples: Where you are from Year in school Hobbies Unique talents Introductions Pick an interesting (but quick) ice breaker

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi and Cyrill Stachniss

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi and Cyrill Stachniss Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi and Cyrill Stachniss Outline Course introduction Linux introduction C++ syntax Hello World! 2 What you will learn in course How to

More information

15-122: Principles of Imperative Computation

15-122: Principles of Imperative Computation 15-122: Principles of Imperative Computation Lab 0 Navigating your account in Linux Tom Cortina, Rob Simmons Unlike typical graphical interfaces for operating systems, here you are entering commands directly

More information

Introduction. File System. Note. Achtung!

Introduction. File System. Note. Achtung! 3 Unix Shell 1: Introduction Lab Objective: Explore the basics of the Unix Shell. Understand how to navigate and manipulate file directories. Introduce the Vim text editor for easy writing and editing

More information

1 Installation (briefly)

1 Installation (briefly) Jumpstart Linux Bo Waggoner Updated: 2014-09-15 Abstract A basic, rapid tutorial on Linux and its command line for the absolute beginner. Prerequisites: a computer on which to install, a DVD and/or USB

More information

Mills HPC Tutorial Series. Linux Basics I

Mills HPC Tutorial Series. Linux Basics I Mills HPC Tutorial Series Linux Basics I Objectives Command Line Window Anatomy Command Structure Command Examples Help Files and Directories Permissions Wildcards and Home (~) Redirection and Pipe Create

More information

ch = argv[i][++j]; /* why does ++j but j++ does not? */

ch = argv[i][++j]; /* why does ++j but j++ does not? */ CMPS 12M Introduction to Data Structures Lab Lab Assignment 4 The purpose of this lab assignment is to get more practice programming in C, including the character functions in the library ctype.h, and

More information

CMSC 201 Spring 2017 Lab 01 Hello World

CMSC 201 Spring 2017 Lab 01 Hello World CMSC 201 Spring 2017 Lab 01 Hello World Assignment: Lab 01 Hello World Due Date: Sunday, February 5th by 8:59:59 PM Value: 10 points At UMBC, our General Lab (GL) system is designed to grant students the

More information

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

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011 Unix/Linux Operating System Introduction to Computational Statistics STAT 598G, Fall 2011 Sergey Kirshner Department of Statistics, Purdue University September 7, 2011 Sergey Kirshner (Purdue University)

More information

Introduction to Linux

Introduction to Linux Introduction to Linux The command-line interface A command-line interface (CLI) is a type of interface, that is, a way to interact with a computer. Window systems, punched cards or a bunch of dials, buttons

More information

Intro to Linux & Command Line

Intro to Linux & Command Line Intro to Linux & Command Line Based on slides from CSE 391 Edited by Andrew Hu slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/391/ 1 Lecture summary

More information

Parallel Programming Pre-Assignment. Setting up the Software Environment

Parallel Programming Pre-Assignment. Setting up the Software Environment Parallel Programming Pre-Assignment Setting up the Software Environment Authors: B. Wilkinson and C. Ferner. Modification date: Aug 21, 2014 (Minor correction Aug 27, 2014.) Software The purpose of this

More information

Bash command shell language interpreter

Bash command shell language interpreter Principles of Programming Languages Bash command shell language interpreter Advanced seminar topic Louis Sugy & Baptiste Thémine Presentation on December 8th, 2017 Table of contents I. General information

More information

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

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands Table Of Contents 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands Getting onto the Zoo Type ssh @node.zoo.cs.yale.edu, and enter your netid pass when prompted.

More information

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview

More information

commandname flags arguments

commandname flags arguments Unix Review, additional Unix commands CS101, Mock Introduction This handout/lecture reviews some basic UNIX commands that you should know how to use. A more detailed description of this and other commands

More information

INTRODUCTION TO BIOINFORMATICS

INTRODUCTION TO BIOINFORMATICS Introducing the LINUX Operating System BecA-ILRI INTRODUCTION TO BIOINFORMATICS Mark Wamalwa BecA- ILRI Hub, Nairobi, Kenya h"p://hub.africabiosciences.org/ h"p://www.ilri.org/ m.wamalwa@cgiar.org 1 What

More information

Recitation: C Review. TA s 20 Feb 2017

Recitation: C Review. TA s 20 Feb 2017 15-213 Recitation: C Review TA s 20 Feb 2017 Agenda Logistics Attack Lab Conclusion C Assessment C Programming Style C Exercise Cache Lab Overview Appendix: Valgrind Clang / LLVM Cache Structure Logistics

More information

Introduction to UNIX Command Line

Introduction to UNIX Command Line Introduction to UNIX Command Line Files and directories Some useful commands (echo, cat, grep, find, diff, tar) Redirection Pipes Variables Background processes Remote connections (e.g. ssh, curl) Scripts

More information

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

Temple University Computer Science Programming Under the Linux Operating System January 2017 Temple University Computer Science Programming Under the Linux Operating System January 2017 Here are the Linux commands you need to know to get started with Lab 1, and all subsequent labs as well. These

More information

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them.

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them. Lab 8 Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

LAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

LAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act: LAB #8 Each lab will begin with a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is

More information

Unix Tutorial Haverford Astronomy 2014/2015

Unix Tutorial Haverford Astronomy 2014/2015 Unix Tutorial Haverford Astronomy 2014/2015 Overview of Haverford astronomy computing resources This tutorial is intended for use on computers running the Linux operating system, including those in the

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (yaseminb@kth.se) Overview Overview Roots of C Getting started with C Closer look at Hello World Programming Environment Discussion Basic Datatypes and printf Schedule Introduction to C - main part of

More information

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni

Using the Debugger. Michael Jantz Dr. Prasad Kulkarni Using the Debugger Michael Jantz Dr. Prasad Kulkarni 1 Debugger What is it a powerful tool that supports examination of your program during execution. Idea behind debugging programs. Creates additional

More information

For Dr Landau s PHYS8602 course

For Dr Landau s PHYS8602 course For Dr Landau s PHYS8602 course Shan-Ho Tsai (shtsai@uga.edu) Georgia Advanced Computing Resource Center - GACRC January 7, 2019 You will be given a student account on the GACRC s Teaching cluster. Your

More information

LAB 0: LINUX COMMAND LINE AND SVN

LAB 0: LINUX COMMAND LINE AND SVN CSE427S LAB 0: LINUX COMMAND LINE AND SVN M. Neumann Due: TUE 23 JAN 2018 1PM No group work. The submission for this lab needs to be done via SVN repository commit. The completion of this tutorial counts

More information

CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters. Introduction

CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters. Introduction Title page CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters Introduction Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Last modified: July

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois Unix/Linux Primer Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois August 25, 2017 This primer is designed to introduce basic UNIX/Linux concepts and commands. No

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: C and Unix Overview This course is about computer organization, but since most of our programming is

More information

Physics REU Unix Tutorial

Physics REU Unix Tutorial Physics REU Unix Tutorial What is unix? Unix is an operating system. In simple terms, its the set of programs that makes a computer work. It can be broken down into three parts. (1) kernel: The component

More information

Computers and Computation. The Modern Computer. The Operating System. The Operating System

Computers and Computation. The Modern Computer. The Operating System. The Operating System The Modern Computer Computers and Computation What is a computer? A machine that manipulates data according to instructions. Despite their apparent complexity, at the lowest level computers perform simple

More information

CS201 - Lecture 1 The C Programming Language

CS201 - Lecture 1 The C Programming Language CS201 - Lecture 1 The C Programming Language RAOUL RIVAS PORTLAND STATE UNIVERSITY History of the C Language The C language was invented in 1970 by Dennis Ritchie Dennis Ritchie and Ken Thompson were employees

More information

Programming Tools. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore

Programming Tools. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore Programming Tools Lecture delivered by: Venkatanatha Sarma Y Assistant Professor MSRSAS-Bangalore 1 Session Objectives To understand the process of compilation To be aware of provisions for data structuring

More information

Bash Programming. Student Workbook

Bash Programming. Student Workbook Student Workbook Bash Programming Published by ITCourseware, LLC, 7245 South Havana Street, Suite 100, Englewood, CO 80112 Contributing Authors: Julie Johnson, Rob Roselius Editor: Jeff Howell Special

More information

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

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon. Lab 1 In order to get credit for the lab, you need to be checked off by the end of lab. For nonzero labs, you can earn a maximum of 3 points for lab work completed outside of lab time, but you must finish

More information

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal. Warnings 1 First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion. Read the relevant material in Sobell! If

More information

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

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University Introduction to Linux Woo-Yeong Jeong (wooyeong@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating system of a computer What is an

More information

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang Topics What is an Operating System Overview of Linux Linux commands Shell Submit system What is an Operating System? Special type of

More information

Linux Command Line Primer. By: Scott Marshall

Linux Command Line Primer. By: Scott Marshall Linux Command Line Primer By: Scott Marshall Draft: 10/21/2007 Table of Contents Topic Page(s) Preface 1 General Filesystem Background Information 2 General Filesystem Commands 2 Working with Files and

More information

Using the Zoo Workstations

Using the Zoo Workstations Using the Zoo Workstations Version 1.86: January 16, 2014 If you ve used Linux before, you can probably skip many of these instructions, but skim just in case. Please direct corrections and suggestions

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) Please come

More information

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME Introduction to the Unix command line History Many contemporary computer operating systems, like Microsoft Windows and Mac OS X, offer primarily (but not exclusively) graphical user interfaces. The user

More information