Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Similar documents
Command-line interpreters

Lab 2: Linux/Unix shell

Linux Command Line Interface. December 27, 2017

Perl and R Scripting for Biologists

Introduction: What is Unix?

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

Useful Unix Commands Cheat Sheet

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

System Administration

Introduction To. Barry Grant

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

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

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Recap From Last Time:

BGGN 213 Working with UNIX Barry Grant

CST Algonquin College 2

EECS2301. Lab 1 Winter 2016

5/20/2007. Touring Essential Programs

CSCI 2132 Software Development. Lecture 4: Files and Directories

The Unix Shell. Pipes and Filters

UNIX Essentials Featuring Solaris 10 Op System

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

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Part 1: Basic Commands/U3li3es

Computer Systems and Architecture

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

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

Introduction to Linux Organizing Files

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.

Computer Systems and Architecture

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

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

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Introduction to UNIX Shell Exercises

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Chap2: Operating-System Structures

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

Shells and Shell Programming

Unix basics exercise MBV-INFX410

11/10/2011. Directory Structures (continued)

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Introduction to Linux

Linux shell programming for Raspberry Pi Users - 2

CS246 Spring14 Programming Paradigm Notes on Linux

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

The Unix Shell & Shell Scripts

Chapter 1 - Introduction. September 8, 2016

Introduction to Linux Basics Part II. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Linux shell scripting Getting started *

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Mills HPC Tutorial Series. Linux Basics I

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

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

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

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

Introduction to Linux

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

Essential Linux Shell Commands

Advanced Linux Commands & Shell Scripting

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

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

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

SBGrid RELION Workshop 2017

Week 2 Lecture 3. Unix

Introduction to Linux

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Shells and Shell Programming

Introduction to UNIX Command Line

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Linux Shell Script. J. K. Mandal

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

Filesystem and common commands

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

Std: XI CHAPTER-3 LINUX

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

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

CSE 15L Winter Midterm :) Review

Basic Linux (Bash) Commands

CS370 Operating Systems

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 2

Recap From Last Time: Setup Checklist BGGN 213. Todays Menu. Introduction to UNIX.

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

Introduction to Unix

Introduction to Linux. Fundamentals of Computer Science

Files and Directories

Chapter 9. Shell and Kernel

Basic Linux Command Line Interface Guide

ACS Unix (Winter Term, ) Page 92

Introduction to Linux Environment. Yun-Wen Chen

Introduc)on to Linux Session 2 Files/Filesystems/Data. Pete Ruprecht Research Compu)ng Group University of Colorado Boulder

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

CSE 391 Lecture 1. introduction to Linux/Unix environment

Transcription:

Processes The Operating System, Shells, and Python Shell Commands a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: - Command prompt - Shell - CLI Shell commands are good for: - managing computer resources - automating tedious, repetitious, and long-running tasks 1

Some Available Shells bash - the default in most Linux installations sh - the original Unix shell; less capable than bash dash, csh, zsh, tsh, tcsh, other alternatives COMMAND.COM - the original DOS "command prompt" CMD.EXE - Command prompt for Windows NT installations Windows PowerShell - Fully programmable option for Windows XP and later Basic Computer Management Linux File and Directory Operations ls display listing of files in current directory pwd (print working directory) show the current directory's name cd, chdir (change directory) choose a new "current directory" md, mkdir make a new directory rd, rmdir remove a directory (if empty) ln -s make a symbolic link to a directory - similar to a DOS/Windows "shortcut" 2

Basic Computer Management File Operations rm remove a file entry from a directory - DOS: del or erase mv move a file entry to a different name or location - DOS: move, rename cp copy a file - DOS: copy, xcopy chmod change a file's usage permissions - DOS: attrib ln (link) create a new directory entry to an existing disk file Basic Computer Management Process-Control Operations Program execution Input / Output redirection - <, >, Process monitoring - ps, jobs - time Process prioritization - fg, bg, & - nice Process termination - kill 3

Program Execution A program is a set of computer instructions and commands that perform some actions - Programs are kept in disk files Running, or executing, a program places it into the computer's memory as a process - One program can lead to many processes - The collection of a running process or group of processes, and the files (and other resources) that are used, is often called a job Running a process requires finding the disk file in its directory - The Executable Path is the default set of directories Some Features of Shells Environment variables - set - declare - unset - echo Customizing the prompt Paths to executables aliases Command history Name completion 4

Input Redirection Processes get input from stdin - Defaults to the keyboard Redirect stdin to get input from a disk file - use < Example: - myprog < data.txt Output Redirection Processes send output to stdout and stderr - Both default to the screen ( console display ) Redirect stdout to send output to a disk file - use > Redirect stderr to send alternate output - use 2> - bash shell: &> also works Examples - myprog > results.txt - myprog 2> errorlog.txt 5

Appending Output The > operator creates or overwrites the destination file - Any previous contents are lost Existing output files can be added to: - myprog >> outputs.log - myprog 2>> errors.log This opens an existing file, or creates a new one, and adds the output to the end Redirecting Input and Output Redirecting can be combined: - myprog < in.txt > out.txt &> errors.txt stdout and stderr can be combined via >& : - myprog > all-output.txt 2>&1» First, redirect stdout to a file» Second, redirect stderr (2) to stdout (1)» Order of redirects is important - Also works with appending, via >>& : myprog >> history.log 2>>&1 6

Connecting Programs Standard output from one program can be sent directly to the standard input of another program - This is called piping output to the next program the pair (or more) of programs is called a pipeline Use the pipe operator Examples - prog1 prog2 - prog1 prog2 prog3 - prog1 < input.txt prog2 > output.txt a big example Try this: - time find /usr -regex '.*\(share\ lib\).*py' tee py-report.out wc -l & What this does: - time reports how long this pipeline takes to run - find looks for files that match a regular expression - tee copies its standard input both to standard output and to the provided file - wc -l counts the number of lines in its standard input - the & makes this pipeline run in the background 7

Linux Shell Scripts Shell scripts are collections of commands, saved in a text file Text file begins with "magic" comment: - #!/bin/sh or maybe #!/bin/bash (Comparable DOS batch files and command scripts are recognized by their name extensions, rather than by their contents.) Scripts include comments as lines starting with a # character - the first line is the "magic" comment shown above Simple Shell Script This is the "big example", scripted for easy reuse - The backslash "\" at the end of line 4 is a line continuation escape 8

Not-As-Simple Shell Script 9