CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

Similar documents
Unix Shells and Other Basic Concepts

CSCI 2132 Software Development. Lecture 4: Files and Directories

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

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

CSCI 2132 Software Development. Lecture 2: Introduction to UNIX and Unix-like Operating Systems

CSCI 2132 Software Development. Lecture 5: File Permissions

Part I. UNIX Workshop Series: Quick-Start

5/20/2007. Touring Essential Programs

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

Files and Directories

CSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions

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

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Introduction: What is Unix?

Introduction to Linux

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

COSC UNIX. Textbook. Grading Scheme

Introduction to Linux

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

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

CSCI2467: Systems Programming Concepts

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

UNIX Kernel. UNIX History

Operating Systems, Unix Files and Commands SEEM

CSCI 4152/6509 Natural Language Processing. Lab 1: FCS Computing Environment

Introduction to UNIX I: Command Line 1 / 21

CS246 Spring14 Programming Paradigm Notes on Linux

EECS2301. Lab 1 Winter 2016

Introduction to Linux. Fundamentals of Computer Science

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Short Read Sequencing Analysis Workshop

Perl and R Scripting for Biologists

Unix Shell Environments. February 23rd, 2004 Class Meeting 6

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Mills HPC Tutorial Series. Linux Basics I

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

What is UNIX? A Little Bit about UNIX and User Interfaces. Adapted from Practical Unix and Programming Hunter College

Linux Command Line Interface. December 27, 2017

C++ Programming on Linux

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Linux Systems Administration Getting Started with Linux

Session 1: Accessing MUGrid and Command Line Basics

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Introduction to Linux

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

CISC 220 fall 2011, set 1: Linux basics

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

Lec 1 add-on: Linux Intro

Introduction to Linux

Unix basics exercise MBV-INFX410

Introduction to the Shell

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

Command-line interpreters

Introduction to UNIX Part II

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.

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

CS 246 Winter Tutorial 1

Unix/Linux: History and Philosophy

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Linux for Beginners. Windows users should download putty or bitvise:

Unix. Examples: OS X and Ubuntu

Chapter 9. Shell and Kernel

We first learn one useful option of gcc. Copy the following C source file to your

Dalhousie University CSCI 2132 Software Development Winter 2018 Lab 2, January 25

The Unix Shell & Shell Scripts

Getting started with Hugs on Linux

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

The Online Unix Manual

Introduction to the Linux Command Line

CPS221 Lecture: Operating System Functions

Operating systems fundamentals - B02

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

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

About shells and command lines

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

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

CS Fundamentals of Programming II Fall Very Basic UNIX

Linux/Cygwin Practice Computer Architecture

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

User Guide Version 2.0

Linux Command Line Primer. By: Scott Marshall

LAB #5 Intro to Linux and Python on ENGR

Lecture # 2 Introduction to UNIX (Part 2)

Getting started with Hugs on Linux

CSE 391 Lecture 1. introduction to Linux/Unix environment

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

commandname flags arguments

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

System Programming. Unix Shells

System Programming. Introduction to Unix

Chapter-3. Introduction to Unix: Fundamental Commands

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

CSE 390a Lecture 1. introduction to Linux/Unix environment

ACS Unix (Winter Term, ) Page 21

CPS221 Lecture: Operating System Functions

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Transcription:

CSCI 2132 Software Development Lecture 3: Unix Shells and Other Basic Concepts Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 10-Sep-2018 (3) CSCI 2132 1

Introduction to UNIX Previous Lecture Reading: Chapter 1 of the UNIX book Operating System overview Onion skin model OS functionalities UNIX history UNIX philosophy and main features 10-Sep-2018 (3) CSCI 2132 2

Some Hardware Concepts Central Processing Unit (CPU) Random-Access Memory (RAM) Read-Only Memory (ROM) Disk Memory (Hard Disk Drive, CD-ROM, etc.) Graphics card Network card (Ethernet card) Peripherals: keyboard, monitor, mouse, etc. 10-Sep-2018 (3) CSCI 2132 3

Some Important Unix Concepts File: collection of data (sequence of bytes) stored on disk (or other external storage) Program: a file containing machine code and data that can be loaded into memory and run Process: Program that is loaded in memory and running Owner of a File or Process: Processes and files have owners and may be protected against unauthorized access Hierarchical directory structure is suppored in Unix file system Location of a file or process: Files and processes have a location within the directory hierarchy. A process may change its location and the location of a file System Calls: Unix provides services (system calls) for creation, modification, and destruction of files and processes 10-Sep-2018 (3) CSCI 2132 4

Directory Hierarchy / (Root directory) home bin glass tim who sort myfile.txt sort afile.txt Denotes a file Denotes a process 10-Sep-2018 (3) CSCI 2132 5

Shells a program used by the user to interact with the system used to run other programs in the system built-in commands and utilities (external commands) used to automate many tasks A UNIX characteristic is existence of multiple shells (even Window managers); e.g.: Bourne Shell: sh, bash (Bourne-Again Shell); we will focus on this one Korn Shell: ksh C Shell: csh, tcsh Z Shell: zsh 10-Sep-2018 (3) CSCI 2132 6

Covered in the lab Getting Started in Unix Mandatory exercise: login to your bluenose account using ssh Options: putty, MobaXterm, Mac terminal, Linux terminal More options: use of VirtualBox Main learning objective: be able to open one or more Terminals with ssh login to your bluenose account in each of them ask TAs, use Learning Center if there are any issues 10-Sep-2018 (3) CSCI 2132 7

Logging In You can choose Windows or Mac environment in some labs Windows: you can use the putty program On Mac: open a Terminal and type: ssh CSID@bluenose.cs.dal.ca Instead of CSID use your CS userid (CSID) On Linux: similarly to Mac, you open the terminal and type the same command: ssh CSID@bluenose.cs.dal.ca 10-Sep-2018 (3) CSCI 2132 8

Shell Prompt After login, we communicate with a shell program, which responds with a prompt string; e.g.: CSID@bluenose: $ or, some shells respond with % or # User can change the prompt string We type commands, followed by enter key, and the shell will respond We can edit the command line before pressing Enter 10-Sep-2018 (3) CSCI 2132 9

Running a Utility Enter a command, which can be a utility or a built-in command A utility is a program with the same name: shell finds it and runs it Example: date Output: Tue Sep 10 22:35:49 ADT 2013 More examples: clear passwd 10-Sep-2018 (3) CSCI 2132 10

Command-line Arguments Utilities can accept arguments For example, date utility allows us to choose format of the output, as in: date +%Y-%m-%d-%H-%M-%S Output: 2013-09-10-22-35-49 To explore usage of date, type: man date (use q to exit) 10-Sep-2018 (3) CSCI 2132 11

The man Utility man comes from manual pages the command man is the standard way of providing usage descriptions for various commands in Unix examples: man man to read about the command man man -k directory to search commands using keyword directory man 2 rmdir to specify the section number of the man page in case of an ambiguity 10-Sep-2018 (3) CSCI 2132 12

Special Shell Characters (Metacharacters) Characters which are interpreted in a special way when typed in a Unix terminal They are usually control characters obtained by pressing Ctrl key and then typing another key while Ctrl is pressed, e.g., Ctrl-C We will learn two of them: Control-C (ˆC) is used to terminate a process Control-D (ˆD) is used to signal end of file The command stty -a can be used to show many special characters 10-Sep-2018 (3) CSCI 2132 13

Input, Output, and Error Channels Remember that there are three default I/O channels for each UNIX program, i.e., three standard I/O streams: stdin (standard input) stdout (standard output) stderr (standard error) Commands so far mostly used stdout only Command cat frequently uses stdin and stdout 10-Sep-2018 (3) CSCI 2132 14

cat example Consider the following example (ˆD is Control-D): $ cat > hamlet.txt To be or not to be that is the question ˆD $ cat hamlet.txt 10-Sep-2018 (3) CSCI 2132 15

Editors The cat example was a way to create a textual file A more convenient way is to use a textual editor Unix offers several editors, for example: emacs to be used as main editor in this course, vi or vim also a major Unix editor, pico, nano, and some others Editors are covered more in the labs 10-Sep-2018 (3) CSCI 2132 16

Logging Out On some shells typing Control-D is sufficient to log us out Sometimes it is disabled since a user can easily type it by mistake Commands logout and exit are available 10-Sep-2018 (3) CSCI 2132 17