IWS (Instructional Work Servers)

Slides:



Advertisements
Similar presentations
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Advertisements

Utilizing the GDB debugger to analyze programs Background and application.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Working with Files How to create, view, copy, rename and print files.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
IWS (Instructional Work Servers) There are 4 instructional Unix servers: –ceylon, fiji, sumatra, and tahiti Accessing the servers: –Terminal Programs:
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Just like DOS or Windows.
IWS (Instructional Work Servers) There are 4 instructional Unix servers: –ceylon, fiji, sumatra, and tahiti Accessing the servers: –Terminal Programs:
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Looks like DOS…but more powerful.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
CSN08101 Digital Forensics Lecture 1B: Essential Linux and Caine Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Unix Basics Chapter 4.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
TAMU CSCE 313 (the basics). Basic Unix/Linux programming Accessing CS systems  PuTTY (putty.exe) – a Telnet and SSH client  Common hosts: unix.cs.tamu.edu.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
Introduction to Programming Using C An Introduction to Operating Systems.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
What is Unix? A multi-user networked operating system –“Operating System” Handles files, running other programs, input/output Just like DOS or Windows.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
Editing and Debugging Mumps with VistA and the Eclipse IDE Joel L. Ivey, Ph.D. Dept. of Veteran Affairs OI&T, Veterans Health IT Infrastructure & Security.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Review Why do we use protection levels? Why do we use constructors?
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
CS1010: Intro Workshop.
Chapter 2: The Visual Studio .NET Development Environment
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Web Programming Essentials:
UNIX The Basics Source:
Andy Wang Object Oriented Programming in C++ COP 3330
CSE 374 Programming Concepts & Tools
Some Linux Commands.
The Command Prompt Commands are the way to “do things” in Unix
Editor, Compiler, Linker, Debugger, Makefiles
Assignment Preliminaries
CSE 374 Programming Concepts & Tools
Important terms Black-box testing White-box testing Regression testing
Intro to UNIX System and Homework 1
Important terms Black-box testing White-box testing Regression testing
IWS (Instructional Work Servers)
Web Programming Essentials:
Getting Started: Developing Code with Cloud9
Introduction Paul Flynn
Andy Wang Object Oriented Programming in C++ COP 3330
TA: Maya Rodrig Our C++ guru: Nic Bone
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
CSE 303 Concepts and Tools for Software Development
Module 6 Working with Files and Directories
What is Unix? A multi-user networked operating system
Video Notes.
Review of Previous Lesson
Makefiles, GDB, Valgrind
SPL – PS1 Introduction to C++.
Presentation transcript:

IWS (Instructional Work Servers) There are 4 instructional Unix servers: ceylon, fiji, sumatra, and tahiti Accessing the servers: Terminal Programs: telnet (insecure; cannot be used) ssh (via the Secure Telnet, TeraTerm or Putty programs from Windows) Start -> Program Files -> Desktop Tools -> TeraTerm File Transfer Programs ftp (insecure; cannot be used) \\<server name>\<username> from Start -> Run menu e.g -- \\fiji\zanfur Secure file transfer (available from C&C) Xwindows Run xgo from the command prompt Come to the ACM tutorial! This tutorial provided by UW ACM http://www.cs.washington.edu/orgs/acm/ Questions to hctang@cs, zanfur@cs, awong@cs

Logging In Which server you use (almost) doesn’t matter – all four allow access to your files Although your Windows and Unix usernames (and passwords) are the same, they are two separate accounts Your z: drive is not your Unix account Connecting: We’ll connect to the Unix machines via ssh After connection, you are presented with a login prompt After logging in, you’re placed in your home directory (where your personal files are located)

The Command Prompt Commands are the way to “do things” in Unix A command consists of a command name and options called “flags” Commands are typed at the command prompt In Unix, everything (including commands) is case-sensitive [prompt]$ <command> <flags> <args> fiji:/u15/awong$ ls –l -a unix-tutorial Command (Optional) arguments Command Prompt (Optional) flags Note: In Unix, you’re expected to know what you’re doing. Many commands will print a message only if something went wrong.

Two Essential Commands The most useful commands you’ll ever learn: man (short for “manual”) info They help you find information about other commands man <cmd> or info <cmd> retrieves detailed information about <cmd> man –k <keyword> searches the man page summaries (faster, and will probably give better results) man –K <keyword> searches the full text of the man pages fiji:/u15/awong$ man –k password passwd (5) - password file xlock (1) - Locks the local X display until a password is entered fiji:/u15/awong$ passwd

Directories In Unix, files are grouped together in other files called directories, which are analogous to folders in Windows Directory paths are separated by a forward slash: / Example: /u10/hctang/classes/cse326 The hierarchical structure of directories (the directory tree) begins at a special directory called the root, or / Absolute paths start at / Relative paths start in the current directory Example: classes/cse326 (if you’re currently in /u10/hctang) Your home directory is where your personal files are located, and where you start when you log in. Example: /u10/hctang

Directories (cont’d) Handy directories to know ls pwd ~ Your home directory .. The parent directory . The current directory ls LiSts the contents of a specified files or directories (or the current directory if no files are specified) Syntax: ls [<file> … ] Example: ls backups pwd Print Working Directory

Directories (cont’d further) cd Change Directory (or your home directory if unspecified) Syntax: cd <directory> Examples: cd backups/unix-tutorial cd ../class-notes mkdir MaKe DIRectory Syntax: mkdir <directories> Example: mkdir backups class-notes rmdir ReMove DIRectory, which must be empty Syntax: rmdir <directories> Example: rmdir backups class-notes

Files Unlike Windows, in Unix file types (e.g. “executable files, ” “data files,” “text files”) are not determined by file extension (e.g. “foo.exe”, “foo.dat”, “foo.txt”) Thus, the file-manipulation commands are few and simple … rm ReMoves a file, without a possibility of “undelete!” Syntax: rm <file(s)> Example: rm tutorial.txt backups/old.txt

Files (cont’d) cp mv CoPies a file, preserving the original Syntax: cp <sources> <destination> Example: cp tutorial.txt tutorial.txt.bak mv MoVes or renames a file, destroying the original Syntax: mv <sources> <destination> Examples: mv tutorial.txt tutorial.txt.bak mv tutorial.txt tutorial-slides.ppt backups/ Note: Both of these commands will over-write existing files without warning you!

Shell Shortcuts Tab completion Command history Wildcards Type part of a file/directory name, hit <tab>, and the shell will finish as much of the name as it can Works if you’re running tcsh or bash Command history Don’t re-type previous commands – use the up-arrow to access them Wildcards Special character(s) which can be expanded to match other file/directory names * Zero or more characters ? Zero or one character Examples: ls *.txt rm may-?-notes.txt

Text - editing Get familiar with one as soon as possible! Which text editor is “the best” is a holy war. Pick one and get comfortable with it. Three text editors you should be aware of: pico – Comes with pine (Dante’s email program) emacs/xemacs – A heavily-featured editor commonly used in programming vim/vi – A lighter editor, also used in programming Get familiar with one as soon as possible!

Text - printing Printing: Use lpr to print Use –h (no header) and –Zduplex (double-sided) to save paper Check the print queue (including Windows print jobs!) with lpq lprm to remove print jobs (including Windows print jobs) For the above commands, you’ll need to specify the printer with –P<printer name> Check out enscript (quizlet: how do you find information about commands?) to print text files nicely! WARNING: Do NOT use enscript with postscript files!

The Unix Philosophy A large set of primitive tools, which can be put together in an infinite number of powerful ways An example: Three separate tools are necessary to develop software: Text editor Compiler Debugger (You will need this, unless “j00 R l33t”) MSVC is an “IDE” (“Integrated Development Environment”) All three tools are found in one shrink-wrapped box Although there are IDE’s for Unix, for this course, you will most likely use (mostly) separate tools: Text editor: emacs/xemacs or vi/vim Compiler: g++ or javac Debugger: gdb or jdb This tutorial provided by UW ACM http://www.cs.washington.edu/orgs/acm/ Questions to hctang@cs

What is “Compilation”? Compilation is The process of translating a program written in a “high level” programming language from source code into “low level” object code Note that the definitions of “high level” and “low level” are arbitrary! “Low level” can mean several things: In many older models of compilation (think C or Fortran), “low level” meant architecture-specific object code. Each file would then be linked together (aka “built”) to create one executable file that can be run directly. In Java, “low level” means object code written for a specific architecture - the Java Virtual Machine. When you want to run a Java program, another (architecture-specific) program must be executed. This program simulates the JVM so you can run your “compiled” code.

Compilation - C++ To compile a C++ program: What’s an “executable”? g++ <options> <source files> Recommended: g++ -Wall –ansi –o <executable_name> *.cpp -Wall – Warnings: ALL -ansi – Stricter ANSI compliance Quizlet: what does *.cpp mean? What’s an “executable”? In Windows, double-clicking on an icon runs a program E.g. double-click on C:\Windows\notepad.exe In Unix, you can run your executable from the command line! Type the executable name at the prompt, just like a command In fact, commands are actually executables However, you may need to specify the path to your executables ./<program> runs <program> in the current directory Example: ceylon:ehsu% g++ -Wall –ansi –o hello hello.cpp ceylon:ehsu% ./hello

“Compilation” or “The Big Lie” Does this picture look familiar? These are the discrete steps to program “compilation” Hitting the ‘!’ button in MSVC or typing a “g++ *.cpp” to build (not “compile”) your program hides all these separate steps. Question: would you want to do this entire process (ie, pre-process and compile every file) every time you wanted to generate a new executable? .h .h .cpp .cpp Pre-proc Pre-proc compiler compiler ANSI lib linker other libs .exe file

Selective Recompilation and Makefiles Answer: No. You only want to compile those files which were changed (or were affected by a change in another file [quizlet: when might this happen?]). We can reuse the .o/.obj files for files which weren’t modified. You could do this yourself… g++ <options> <changed files> g++ *.o But you could also use the make command and a Makefile! Create a Makefile to keep track of file dependancies and build options The make command will read the Makefile and compile (and build) those files which have dependancies on modified files!

Makefile Syntax Makefiles consists of variables and rules. Rule Syntax: <target>: <requirements> <command> The <requirements> may be files and/or other targets There must be a tab (not spaces) before <command> The first rule in a Makefile is the default <target> for make Variable Syntax: <variable>=<string value> All variable values default to the shell variable values Example: BUILD_FLAGS = -Wall -g -ansi

Example Makefile # Example Makefile – This is a very basic Makefile. # There are automatic makefiles which generate these # rules for you. CXX=g++ CXXFLAGS=-g –Wall –DDEBUG LDFLAGS= foobar: foo.o bar.o $(CXX) $(LDFLAGS) –o foobar foo.o bar.o foo.o: foo.cpp foo.h $(CXX) $(CXXFLAGS) –c foo.cpp bar.o: bar.cpp bar.h $(CXX) $(CXXFLAGS) –c bar.cpp clean: rm foo.o bar.o foobar

Compilation - Java In Java, “compilation” means translating Java source code to JVM code (bytecode), ie.,.class files Java programs can be run on any machine which has a JVM installed. Theoretically you can even copy .class files compiled on another architecture and run them on your current machine! To compile a Java program: javac –g *.java To execute a Java program: java <classname> Where <classname>.java is a class with a public static void main(String[] args) method Note that you did not type <driver>.class! Look, ma, no Makefile!

“Main”??? The java program only knows how to simulate the JVM That is, it does not know how to run your program - which methods should it call? In what order? With what inputs? The solution is to have each programmer write a method which will “kick off” your program (eg, instantiate the appropriate classes and call their methods). This magic method is called by the java program after it has loaded the JVM, and is called main. Some restrictions The class which is passed to the java program must have a main method. The signature of this method must be public static void main(String[])

Writing Code What causes a bug? What you meant != what you wrote Coding right the first time is making “what you meant” align with “what you write” Invariants – assert() invariants to discover when your program’s state has changed unexpectedly Error handling and notification – Fix or report errors. Your program should never be in a bad state Code review Use a debugger! See next slide …

Debugging How do you remove a bug? Debugger advantages Read the code. If you don’t understand it, the bug will happen again Examine the state of the program at key points in the code Print statements in the code (suggestion: wrap debug output with #ifdef DEBUG) Use a debugger to view the state of your program with greater flexibility/control Debugger advantages Compile your code only once Monitor all the values in the code Make changes while executing the code Examine core files that are produced when a program crashes In other words, debuggers are tools which allow you to examine the state of a program in detail! In fact, debuggers can (and should) be used to understand and improve your code

Debugging Techniques Goal: Isolate the problem, then fix it Don’t try random things, looking for a solution If you don’t understand it, it’ll be back This method takes a long time You don’t learn anything from it Look for the problem, not the solution Figure out two points in code that the problem is between, and close the gap from there.

GDB - The GNU DeBugger To run gdb (a text-based debugger): Within gdb: gdb [<program file> [<core file>]] <program file> Executable program file <core file> Crashed program’s core dump You must compile with -g for debug information! Within gdb: Running gdb: run [<args>] Run program with arguments <args> quit Quit the gdb debugger help [<topic>] Access gdb’s internal help Examining program state: info [locals|args] Prints out info on [local variables|args] backtrace[<n>] Prints the top <n> frames on the stack p[rint] <expr> Print out <expr>

GDB continued Controlling program flow s[tep] Step one line, entering called functions n[ext] Step one line, skipping called functions fin[ish] Finish the current function and print the return value Controlling program flow with breakpoints c[ontinue] Continue execution (after a stop) b[reak][<where>] Set a breakpoint d[elete] [<nums>] Deletes breakpoints by number [r]watch <expr> Sets a watchpoint, which will break when <expr> is written to [or read] Modifying program state set <name> <expr> Set a variable to <expr> jump <where> Resume program execution at <where>

JDB - The Java DeBugger To run jdb (a text-based debugger): gdb [<program file> [<core file>]] <program file> Executable program file You must compile with -g for debug information! Within jdb: Running jdb: run [<class> <args>] Run program with arguments <args> quit Quit the jdb debugger Help Access gdb’s internal help Examining program state: locals Prints out the values of local variables dump Prints out info on the current class instance where Prints the call stack Print <expr> Print out <expr>

JDB continued Controlling program flow step Step one line, entering called functions next Step one line, skipping called functions step up Finish the current function and print the return value Controlling program flow with breakpoints continue Continue execution (after a stop) stop [at|in] <class>:<number> Set a breakpoint clear [<nums>] Deletes breakpoints by number watch <class>.<number> Sets a watchpoint, which will break when <class>.<number> is written to [or read] Modifying program state set <name> <expr> Set a variable to <expr>

More Information In the department On the web: Your neighbors! info and man uw-cs.lab-help newsgroup .login, .cshrc, and /uns/examples to see how other people have things set up On the web: http://www.faqs.org (comp.unix questions FAQ) http://www.google.com ACM Tutorials: http://www.cs.washington.edu/orgs/acm/tutorials/ If you’re curious, check out these topics Source control (try searching the web for “cvs”) Profiling (try searching the web for “gprof”)