Tutorial 0A Programming on the command line



Similar documents
Fred Hantelmann LINUX. Start-up Guide. A self-contained introduction. With 57 Figures. Springer

Command Line - Part 1

Command Line Crash Course For Unix

Introduction to Mac OS X

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

Linux command line. An introduction to the Linux command line for genomics. Susan Fairley

Birmingham Environment for Academic Research. Introduction to Linux Quick Reference Guide. Research Computing Team V1.0

Kernel. What is an Operating System? Systems Software and Application Software. The core of an OS is called kernel, which. Module 9: Operating Systems

CS 103 Lab Linux and Virtual Machines

Unix Guide. Logo Reproduction. School of Computing & Information Systems. Colours red and black on white backgroun

Open Source Computational Fluid Dynamics

Command-Line Operations : The Shell. Don't fear the command line...

Linux System Administration on Red Hat

Training Day : Linux

Programming for GCSE Topic H: Operating Systems

A UNIX/Linux in a nutshell

Unix Sampler. PEOPLE whoami id who

Agenda. Using HPC Wales 2

Introduction to Linux and Cluster Basics for the CCR General Computing Cluster

ICS 351: Today's plan

Software. Programming Language. Software. Instructor Özgür ZEYDAN. Bülent Ecevit University Department of Environmental Engineering

An A-Z Index of the Apple OS X command line (TERMINAL) The tcsh command shell of Darwin (the open source core of OSX)

Lab 1: Introduction to the network lab

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

Java Software Development Kit (JDK 5.0 Update 14) Installation Step by Step Instructions

Installing Java. Table of contents

Upon completion of this chapter, you will able to answer the following questions:

LSN 10 Linux Overview

A Crash Course on UNIX

USEFUL UNIX COMMANDS

CSIL MiniCourses. Introduction To Unix (I) John Lekberg Sean Hogan Cannon Matthews Graham Smith. Updated on:

LECTURE-7. Introduction to DOS. Introduction to UNIX/LINUX OS. Introduction to Windows. Topics:

OPERATING SYSTEM SERVICES

Introduction to the UNIX Operating System and Open Windows Desktop Environment

Tutorial Guide to the IS Unix Service

Introduction to Running Hadoop on the High Performance Clusters at the Center for Computational Research

Introduction to Shell Programming

Linux Overview. Local facilities. Linux commands. The vi (gvim) editor

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

Thirty Useful Unix Commands

Operating System Today s Operating Systems File Basics File Management Application Software

Fall Lecture 1. Operating Systems: Configuration & Use CIS345. Introduction to Operating Systems. Mostafa Z. Ali. mzali@just.edu.

University of Toronto

An Introduction to Using the Command Line Interface (CLI) to Work with Files and Directories

HP-UX Essentials and Shell Programming Course Summary

UNIX Basics. Ian Darwin TCP Informatics January, Presented from a Mac using Apple s Keynote presentation software

Spectrum Spatial Analyst Version 4.0. Installation Guide for Linux. Contents:

L01 Introduction to the Unix OS

Linux Labs: mini survival guide

An Introduction to the Linux Command Shell For Beginners

New Lab Intro to KDE Terminal Konsole

Extreme computing lab exercises Session one

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

SOFTWARE TECHNOLOGIES

Parallels Desktop for Mac

Basic Linux & Package Management. Original slides from GTFO Security

Tour of the Terminal: Using Unix or Mac OS X Command-Line

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

CE 504 Computational Hydrology Computational Environments and Tools Fritz R. Fiedler

Faronics Products SYSTEM REQUIREMENTS Last modified: October 2014

Cygwin command line windows. Get that Linux feeling - on Windows

Attix5 Pro Server Edition

CS3600 SYSTEMS AND NETWORKS

After studying this lesson, you will have a clear understanding of, what an Operating System is. functions of an Operating System

Lesson 06: Basics of Software Development (W02D2

CS420: Operating Systems OS Services & System Calls

Getting Started with VMware Fusion. VMware Fusion for Mac OS X

Syntax: cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS)

INASP: Effective Network Management Workshops

CMSC 216 UNIX tutorial Fall 2010

Cincom Smalltalk. Installation Guide P SIMPLIFICATION THROUGH INNOVATION

INTEGRAL OFF-LINE SCIENTIFIC ANALYSIS

AN INTRODUCTION TO UNIX

SEO - Access Logs After Excel Fails...

Chapter Contents. Operating System Activities. Operating System Basics. Operating System Activities. Operating System Activities 25/03/2014

File management Editing X Window KDE. Debian/GNU Linux. Introduction II. Károly Erdei. November 21, Károly Erdei Debian/GNU Linux 1/45

1001ICT Introduction To Programming Lecture Notes

Introduction to Operating Systems

Chapter 4. Operating Systems and File Management

Chapter 2 System Structures

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

Installing Sun's VirtualBox on Windows XP and setting up an Ubuntu VM

Hadoop Installation MapReduce Examples Jake Karnes

Online Backup Client User Manual

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Example of Standard API

Discovering Computers

Introduction to the UNIX Operating System on IT Systems

Lab 1 Beginning C Program

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

Ubuntu, FEAP, and Virtualiza3on. Jonathan Wong Lab Mee3ng 11/08/10

WA1826 Designing Cloud Computing Solutions. Classroom Setup Guide. Web Age Solutions Inc. Copyright Web Age Solutions Inc. 1

Introduction to Linux operating system. module Basic Bioinformatics PBF

IN STA LLIN G A VA LA N C HE REMOTE C O N TROL 4. 1

Installing FEAR on Windows, Linux, and Mac Systems

Network Probe User Guide

Operating Systems compatible with GigasoftOBM / GigasoftACB (Supported Operation System List):

Addonics T E C H N O L O G I E S. NAS Adapter. Model: NASU Key Features

SPSS. Resolve common problems when installing SPSS. Document Purpose. IT Services.

Outline: Operating Systems

Transcription:

Tutorial 0A Programming on the command line

Operating systems User Software Program 1 Program 2 Program n Operating System Hardware CPU Memory Disk Screen Keyboard Mouse 2

Operating systems Microsoft Apple Unix Windows 98 Mac OS X Leopard BSD 4.3 Windows XP Windows Vista Windows 8 Windows 10 Mac OS X Snow Leopard Mac OS X Mountain Lion Mac OS X Mavericks Mac OS X Yosemite HP-UX Linux AT&T Unix Solaris 3

Operating systems Microsoft Apple Unix Windows 98 Mac OS X Leopard BSD 4.3 Windows XP Windows Vista Windows 8 Windows 10 Mac OS X Snow Leopard Mac OS X Mountain Lion Mac OS X Mavericks Mac OS X Yosemite HP-UX Linux AT&T Unix Solaris 4

Operating systems Microsoft Apple Unix Windows 98 Windows XP Windows Vista Windows 8 Mac OS X Leopard BSD 4.3 Mac OS X Snow Leopard HP-UX Different from the others: the GUI (graphical user interface) Mac OS is X independent Mountain Lion of the OS Linux (operating system). There Mac OS are X many Mavericks choices. AT&T Unix Windows 10 Mac OS X Yosemite Solaris 5

The terminal & shell Shell Terminal Display manager Linux Hardware 6

Files In UNIX there are three basic types of files 1.Ordinary Files: An ordinary file is a file on the system that contains data, text, or program instructions. In this tutorial, we look at working with ordinary files. 2.Directories: Directories store special and ordinary files, and other directories. For users familiar with Windows or Mac OS, UNIX directories are equivalent to folders. In particular, directories are organized in a hierarchy, starting at the root directory. 3.Special Files: Some special files provide access to hardware such as hard drives, CD-ROM drives, modems, and Ethernet adapters. Other special files are similar to aliases or shortcuts and enable you to access a single file using different names. 7

Shell commands Command ls ls l ls a ls *.java ls ~ pwd cd Progs cd.. cd ~ Description List the files in the current directory Give a long listing of the files in the current directory List all the files in the current directory (including hidden files = filenames that start with a. ) Use * as a wildcard = list all files that end in.java List all files in the user s home directory Display the current working directory Change current working directory to Progs ( go into ) Change current working directory to parent directory Change current working directory to user s home directory cd /users/jaco/progs 8

Shell commands Command Description mkdir Tut0A Create a new directory rmdir Tut0A Remove a directory (only if it is empty) cd - Change back to the previous working directory echo abc Display a string on the screen cat Greet.java Display the contents of a file cp A.java B.java Make a copy of a file mv B.java C.java Change the name of a file mv A.txt ~ Move one file to another directory mv B.txt ~/C.txt Move one file to another directory and name 9

Shell commands View the manual page for some command: man ls More commands: cat Display File Contents cd Changes Directory to dirname chgrp Change file group chmod Changing Permissions cp Copy source file into destination file Determine file type find Find files grep Search files for regular expressions head Display first few lines of a file ln Create softlink on oldname ls Display information about file type mkdir Create a new directory more Display data in paginated form mv Move/rename a file pwd Print current working directory rm Remove/delete filename rmdir Delete an existing directory if empty tail Prints last few lines in a file touch Update access and modification time of a file 10

More commands! awk Pattern processing language cmp Compare contents of two files comm Compare sorted data cut Cut out selected fields of file diff Differential file comparator expand Expand tabs to spaces join Join files on some common field perl Data manipulation language sed Stream text editor sort Sort file data split Split file into smaller files tr Translate characters uniq Report repeated lines in a file wc Count words/lines/characters vi Visual text editor vim vi improved fmt Simple text formatter spell Spell checker ispell Interactive spell checker ex Simple line editor emacs GNU project Emacs compress Compress files gzip GNU file compression tar Archiver man Manual pages apropos Keyword lookup of commands 11

Redirection and pipes The shell is very, very powerful. One important feature is redirection : Read input from a file $ sort < mydata.txt Write output to a file $ sort mydata.txt > sorted.txt Append output to a file $ sort moredata.txt >> sorted.txt Combine the above $ sort < somedata.txt >> sorted.txt Another feature is pipes : Write output to another program $ find. name *.java sort 12

Java compiler and execution javac Greet.java Greet.java Java compiler Greet.class java Greet Hello, world! Greet.class Java virtual machine 13

Java compilation & execution step-by-step Make a new directory for your programs $ mkdir RW114 $ cd RW114 Use an editor (such as gedit) to write the following program public class Greet { public static void main(string[] args) { System.out.println("Hello, world!"); } } Save it in a file called Greet.java 14

Java compilation & execution step-by-step Compile the program $ javac Greet.java $ ls Greet.java Greet.class Check the java version (just for interest s sake) $ java version java version "1.7.0_45 Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08) Execute our program $ java Greet Hello, world! 15

Java compilation & execution step-by-step Change the work public to pubic $ javac Greet.java Greet.java:1: error: class, interface, or enum expected pubic class Greet { ^ 1 error Switch on line numbers to find the errors Correct the previous mistake. Now delete the last } in the program. $ javac Greet.java Greet.java:4: error: reached end of file while parsing } ^ 1 error 16

Java compilation & execution step-by-step Correct the previous mistake. Replace Hello, world! with 2/0. $ javac Greet.java $ java Greet Exception in thread "main java.lang.arithmeticexception: at Greet.main(Greet.java:3) / by zero The first kind of error is a compile-time error. Java does not even produce.class file. The second kind of error (above) is a run-time error. These are more difficult to fix. Always read the error messages carefully. 17

Which computer must I buy? It does not really matter! If possible, wait and determine your needs. How are other students using their computers? Does it work for them? Do they bring it to class, or mostly leave it at home? The CPU and harddrive specs are not too important. 500 GB harddrive space is enough for most people. The most important spec is memory! Buy as much as possible. At the very least 4GB, but aim for 8GB. http://www.sun.ac.za/infoteg IT Service Catalogue (left menu under IT LINKS) Purchasing Hardware Desktops & laptops 18

How do I install Ubuntu In this course, we are using Ubuntu Ubuntu = Linux + other bundled software You can buy an installation CD from Ed Burger (NARGA A) for R20 (?) Installation should be easy, but if you have trouble, bring your PC to the second tutorial and ask a demi to help you. 19