The Unix Shell. Job Control

Similar documents
The Unix Shell. Job Control

The Unix Shell. Pipes and Filters

The Unix Shell. Permissions

Unix Processes. What is a Process?

File system Security (Access Rights)

5/8/2012. Controlling User Processes Chapter 10

ACS Unix (Winter Term, ) Page 92

Exploring UNIX: Session 5 (optional)

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

UNIX Tutorial Five

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic

Sperimentazioni I LINUX commands tutorial - Part II

Most of the work is done in the context of the process rather than handled separately by the kernel

Bamuengine.com. Chapter 7. The Process

Advanced Unix Concepts. Satyajit Rai

Lecture 5: Jobs and Processes

Automated Builds. Rules

Wollongong of University School of Computer Science and Software Engineering. CSCI212/MCS9212 Interacting Systems Autumn 2015

Process Management forks, bombs, zombies, and daemons! Lecture 5, Hands-On Unix System Administration DeCal

Shells and Processes. Bryce Boe 2012/08/08 CS32, Summer 2012 B

Chapter 9: Process management. Chapter 9 Process management

File system links. Week Overview. Hard and symbolic links Process management

Removing files and directories, finding files and directories, controlling programs

Linux System Administration

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Simplest version of DayOfYear

Introduction to Linux

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

Study Guide Processes & Job Control

Multitasking. In this chapter: Running a Command in the Backg round Checking on a Process Cancelling a Process

The Unix Shell. Files and Directories

Processes. System tasks Campus-Booster ID : **XXXXX. Copyright SUPINFO. All rights reserved

Introduction to UNIX Shell Exercises

Computer Systems and Architecture

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3

Operating Systems Lab 1 (Users, Groups, and Security)

I/O and Shell Scripting

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

How to Implement a Web-based Terminal with Docker

Binghamton University. CS-220 Spring Sharing Resources. Computer Systems Chapter 8.2, 8.4

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

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

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

bash, part 3 Chris GauthierDickey

9 Notes on selecting processes in proc.mem and proc.num items

CRUK cluster practical sessions (SLURM) Part I processes & scripts

CSC UNIX System, Spring 2015

Lecture 24: Multitasking and Signals

Systems Programming/ C and UNIX

System Programming. Signals II

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Computer Systems and Architecture

S E C T I O N O V E R V I E W

Managing Processes Process: A running program

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Lab 2: Linux/Unix shell

CS Unix Tools. Fall 2010 Lecture 10. Hussam Abu-Libdeh based on slides by David Slater. September 29th, 2010

CMU MSP 36602: Intro to UNIX and Scripting: Part 1

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science

Processes & Signals. System Runs Many Processes Concurrently. State consists of memory image + register values + program counter

Linux Command Line Interface. December 27, 2017

Exceptional Control Flow Part II Nov. 2, 2009"

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

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

07 - Processes and Jobs

Unix Basics. Systems Programming Concepts

UNIX Command Cheat Sheets

Chap2: Operating-System Structures

File permission u owner of file/directory (user) g group of the file/directory o other a all

Sets and Dictionaries

UNIX Command Cheat Sheets

Signals: Management and Implementation. Sanjiv K. Bhatia Univ. of Missouri St. Louis

User Commands ps ( 1 )

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.

Advanced Bash Scripting

CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS]

CS Operating Systems Lab 3: UNIX Processes

Each terminal window has a process group associated with it this defines the current foreground process group. Keyboard-generated signals are sent to

Advanced Unix/Linux System Program. Instructor: William W.Y. Hsu

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Getting started with Hugs on Linux

Operating Systems and Protection CS 217

CS631 - Advanced Programming in the UNIX Environment. Process Groups, Sessions, Signals

Automated Builds. Macros

Introduction to Linux

Advanced UNIX. 2. The Shell (Ch.5, Sobell) Objectives. to supplement the Introduction to UNIX slides with extra information about the Shell

Shell and Signals. Computer Organization 3/17/2015. CSC252 - Spring The World of Multiprogramming or Multitasking. Unix Process Hierarchy

Introduction to UNIX/Linux

INSE Lab 1 Introduction to UNIX Fall 2017

Classes and Objects. Inheritance

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process

Exceptions, Processes and Signals

Configuring the Router ASCII Interface

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

Part 1: Basic Commands/U3li3es

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

Getting started with Hugs on Linux

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Transcription:

The Unix Shell Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.

shell

shell $ wc l *.pdb sort head -1

shell $ wc l *.pdb sort head -1 wc sort head

shell $ wc l *.pdb sort head -1 wc sort head Control programs while they run

shell $ wc l *.pdb sort head -1 wc sort head processes Control programs while they run

A process is a running program

A process is a running program Some are yours

A process is a running program Some are yours Most belong to the operating system (or other users)

A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ Process ID (unique at any moment)

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ Parent process ID

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ Parent process ID What process created this one?

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ Process group ID

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ What terminal (TTY) is it running in?

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ What terminal (TTY) is it running in? '?' indicates a system service (no TTY)

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ The user ID of the process's owner

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ The user ID of the process's owner Controls what the process can read, write, execute,

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ When the process was started

$ ps A process is a running program Some are yours Most belong to the operating system (or other users) Use ps to get a list PID PPID PGID TTY UID STIME COMMAND 2152 1 2152 con 1000 13:19:07 /usr/bin/bash 2276 2152 2276 con 1000 14:53:48 /usr/bin/ps $ The program the process is executing

Can stop, pause, and resume running processes

Can stop, pause, and resume running processes $./analyze results*.dat

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass...

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C Stop the running program $

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ Run in the background

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ Run in the background Shell returns right away instead of waiting for the program to finish

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ Can run other programs in the foreground while waiting for background process(es) to finish

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs [1]./analyze results01.dat results02.dat results03.dat $

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs Show background processes [1]./analyze results01.dat results02.dat results03.dat $

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs [1]./analyze results01.dat results02.dat results03.dat $ fg

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs [1]./analyze results01.dat results02.dat results03.dat $ fg Bring background job to foreground

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs [1]./analyze results01.dat results02.dat results03.dat $ fg Bring background job to foreground Use fg %1, fg %2, etc. if there are several background jobs

Can stop, pause, and resume running processes $./analyze results*.dat...a few minutes pass... ^C $./analyze results*.dat & $ fbcmd events $ jobs [1]./analyze results01.dat results02.dat results03.dat $ fg...a few minutes pass... $ And finally it's done

Use ^Z to pause a program that's already running

Use ^Z to pause a program that's already running fg to resume it in the foreground

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job $./analyze results01.dat

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job $./analyze results01.dat ^Z [1] Stopped./analyze results01.dat $

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job $./analyze results01.dat ^Z [1] Stopped./analyze results01.dat $ bg %1 $

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job $./analyze results01.dat ^Z [1] Stopped./analyze results01.dat $ bg %1 $ jobs [1]./analyze results01.dat $

Use ^Z to pause a program that's already running fg to resume it in the foreground Or bg to resume it as a background job $./analyze results01.dat ^Z [1] Stopped./analyze results01.dat $ bg %1 $ jobs [1]./analyze results01.dat $ kill %1 $

Job control mattered a lot when users only had one terminal window

Job control mattered a lot when users only had one terminal window Less important now: just open another window

Job control mattered a lot when users only had one terminal window Less important now: just open another window Still useful when running programs remotely

created by Greg Wilson August 2010 Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.