This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 1 Lab Assignment I I. INTRODUCTION In this assignment you will learn basic Unix commands and work through the steps involved in writing and compiling a simple C program. For the benefit of those of you who have earlier programmed in C++, we highlight the differences between C and C++ at various points in the handout. Familiarity with the tasks in this handout is a bare minimum requirement to tackle future programming assignments in the course. Note that the lab machines are installed with CentOS-6.0 linux distributions. All programming assignments sumbitted by you should run on CentOS-6.0. II. GETTING STARTED You will need to get a user account ( login name and password ) on the Unix/Linux machine designated for lab work. Once you have the login and password you can access your home on the machine by logging into it via telnet or ssh (preffered). You may access the machine from your local desktop using ssh clients like TeraTerm and PuTTy 1 . A successful login will take you to a command prompt, typically # or $ or , and as is true with most things Unix, easily configurable to a prompt of your own choice. III. COMMONLY USED UNIX COMMANDS Having successfully logged in to the lab machine you are now ready to get your hands dirty with commands you will find very useful when using any unix based operating system. We will work with the following in this assignment. A longer list can be found at http://mally.stanford. edu/ ∼ sr/computing/basic-unix.html. man Probably the best way to learn about any Unix command. Usage: $man <command name> Examples: 1 A list of ssh clients for various operating systems can be found at http://static.msi.umn.edu/user support/ssh/sshclients.html. September 5, 2011 DRAFT 2 $man man $man ls You can also find them on the web, for example, at http://unixhelp.ed.ac.uk/CGI/man-cgi. passwd To change your account password. pwd Displays your present working directory. ls Lists all the files and directories in your current directory. cd The change directory command. touch Create a new file or update the timestamp of a file to current. cp Copy a file. rm Remove a file. With additional options remove a directory and all files in it. mv Move a file. mkdir Create a new directory. rmdir Remove a directory. chmod Change read, write and execute permissions on a file. wc Returns number of characters, words and lines in a file. grep Search a file for a pattern. find Find a file. tar Create an archive. Extract files from an archive. IV. WRITING AND RUNNING A C PROGRAM Many of the future assignments will involve writing parts or whole of a C program. In its simplest form a C program consists of a main function. Just as in C++, a C program must have one main function. Other functions may be invoked from within the main function. Next, we will go through the steps of creating a very simple C program....
View Full Document
This document was uploaded on 10/20/2011.
- Fall '09