IT244 - Introduction to Linux / Unix Instructor: Bo Sheng

Slides:



Advertisements
Similar presentations
UNIX Chapter 12 Redirection and Piping Mr. Mohammad Smirat.
Advertisements

Lecture 4 Shell environment III: - command alias & history; - job control; - editor (vim) CSE4251 The Unix Programming Environment 1.
CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
A Practical Guide to Fedora and Red Hat Enterprise Linux Unit 4: More Command Line Interface (CLI) Chapter 7: The Linux Shell By Fred R. McClurg Linux.
Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
LINUX System : Lecture 3 (English-Only Lecture) Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Acknowledgement.
Unix. Outline Commands Environment Variables Basic Commands CommandMeaning lslist files and directories ls -alist all files and directories mkdirmake.
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
The UNIX Shell Software Tools. Slide 2 Basic Shell Syntax command [-[options]] [arg] [arg] … l The name of the command is first l Options are normally.
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
CS 497C – Introduction to UNIX Lecture 21: - The Shell Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
Prime View, Inc.1. 2 Chapter Objectives · In this chapter, you will learn about: · Command history · Output redirection and pipes · Filename metacharacters.
Command Line Variations Selected Readings in Chapters 3, 5, 6 u Project 1 kickoff u Streams & Redirection: Sections 5.2, 5.3 u Pipes and Tees: Sections.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
1 UNIX essentials (hands-on) the directory tree running programs the shell → command line processing → special characters → command types → shell variables.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Adv. UNIX: Shell/21 Advanced UNIX v Objectives –to supplement the “Introduction to UNIX” slides with extra information about the Shell
I/O and Redirection. Standard I/O u Standard Output (stdout) –default place to which programs write u Standard Input (stdin) –default place from which.
1 Unix Seminar #1 T.J. Borrelli Lecturer for CS and NSSA February 6th, 2009.
Week 9 - Nov 7, Week 9 Agenda I/O redirection I/O redirection pipe pipe tee tee.
CSCI The UNIX System Shell Data Handling: Redirection and Piping
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
Chapter 5: The Shell The Man in the Middle. In this chapter … The command line Input, output, and redirection Process management Wildcards and expansion.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
1 UNIX Operating Systems II Part 2: Shell Scripting Instructor: Stan Isaacs.
Learning Unix/Linux Based on slides from: Eric Bishop.
Foreground and background processes
Introduction to Shells
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
The UNIX Shell Learning Objectives:
Part 1: Basic Commands/Utilities
Some Linux Commands.
C151 Multi-User Operating Systems
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Chapter 6 Filters.
Shell Programming (ch 10)
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Basic UNIX OLC Training.
Introduction to UNIX.
The Linux Command Line Chapter 6
CS 60 Discussion Review.
CSE 303 Concepts and Tools for Software Development
Chapter 3 The UNIX Shells
CSC 4630 Meeting 4 January 29, 2007.
Introduction to Linux Commands
LPI Linux Certification
Presentation transcript:

IT244 - Introduction to Linux / Unix Instructor: Bo Sheng Shell (ch 5) IT244 - Introduction to Linux / Unix Instructor: Bo Sheng

Outline Command line syntax and processing Standard I/O and device files Redirection and pipes

Command Line Syntax Arguments command [arg1] [arg2] … [argn] RETURN Separated by space Could be optional ls ls -l cp hello hello.copy command [arg1] [arg2] … [argn] RETURN

Command Line Syntax Arguments (options) ls –l, rm –i Combining options ls -l -r = ls –lr Option arguments gcc -o hello hello.c

Command Line Syntax Non-option arguments starting with ‘-’ Create a file ‘-l’ and then list it ls –l ls ./-l, ls -- -l Create a file ‘-i’ and then delete it rm –i rm ./-i, rm -- -i

Command Line Processing e.g., /bin/ls Arguments are processed by programs, NOT the shell

Standard I/O

Standard I/O

Device Files The screen and keyboard as a file who, w cat CTRL+D (EOF) to terminate

Device Files The screen and keyboard as a file An example with two terminals Use “who” to find out their device files, e.g., /dev/pts/1 and /dev/pts/2 In terminal 2, type in echo hello > /dev/pts/1 cat /dev/pts/1 Then type in terminal 1

Redirection Redirecting standard output ( > ) command [arguments] > filename

Redirection Redirecting standard output ( > ) Examples echo hello world > hello cat > sample cat hello > sample cat days months > sample

Redirection Redirecting standard output ( > ) Examples ls > filelist Append (>>) echo append >> hello

Redirection Redirecting standard input ( < ) command [arguments] < filename

Pipes and Redirection command1 [arguments] | command2 [arguments] command1 [arguments] > temp command2[arguments] < temp rm temp

Some New Utilities Translate (tr) tr abc ABC tr hld xyz < hello tr “[A-Z]” “[a-z]” linux Examples cat month colors.1|tr “[A-Z]” “[a-z]” | sort

Some New Utilities Split directions (tee) tee filename ls –l | tee filelist cat colors.1 | tee file1 > file2 grep e colors.1 | tee /dev/pts/1 | sort

More Examples Use tr to replace or delete characters echo “this is a test” > test wc -c test tr -d “ ” < test | wc –c

More Examples Redirection echo “***” >> hello Insert a line before the first line echo “***” > temp cat temp hello > hello.new mv hello.new hello cat hello >> temp mv temp hello cat temp hello > hello ?

Filename Generation/Wildcards “*” and “?” “?” : single character “*” : any number of characters (including 0) ls colors.? echo col* ls hello*

Filename Generation/Wildcards Examples echo ????? echo ~/.* cat hello*

Filename Generation/Wildcards “[]” for range echo [aeiou]* cat colors.[135] echo [a-z]* echo *[a-l] “^” for “not” echo *[^a-z] echo [^a-o]*

Execute Commands Foreground and background jobs cp ~shengbo/it244/exetest . ./exetest (CTRL+C to terminate) ./exetest & (running in background) jobs

Execute Commands Foreground and background jobs Multitasking One foreground in a terminal Only foreground gets input from keyboard Multitasking

Execute Commands Job number / PID number Job number Process ID

Execute Commands Job number / PID number Job number Process ID

Execute Commands Suspend a foreground job ./exetest CTRL+Z jobs Different from a running background job

Execute Commands Resume a suspended job In the background bg [%job_number] In the foreground fg [%job_number] Bring background job to foreground

Execute Commands Abort a job Foreground Background CTRL+C kill process_ID kill %job_number tail –f hello &