Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
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.
Chapter 13 Processes. What is a process? A process is a program in execution A process is created whenever an external command is executed Whenever the.
CHAPTER 2 THE UNIX SHELLS by U ğ ur Halıcı. layers in a unix system 1 Users Standard utility programs (shell, editors, compilers, etc.) Standard utility.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
The Unix File System. What are the three parts of every file on a Unix filesystem? And where is each stored? Filename - stored in directories Inode -
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
CS 497C – Introduction to UNIX Lecture 22: - The Shell Chin-Chih Chang
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.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
The UNIX Shells 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
Shell Script Examples.
2 $ command Command Line Options ls –a –l hello hi Command Arguments.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Lecture 3  Shell Variables  Shell Command History  Job / Process Control  Directory Control.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Shells Based on Glass & Abels’ Book CS240 Computer Science II.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
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.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
CS465 - UNIX The Bourne Shell.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
LINUX programming 1. INDEX UNIT-III PPT SLIDES Srl. No. Module as per Session planner Lecture No. PPT Slide No. 1.Problem solving approaches in Unix,Using.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
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.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
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 ( >, >>,
Introduction to UNIX (part 2) CSE 2031 Fall March 2016.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Foreground and background processes
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Introduction to Shells
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
The UNIX Shell Learning Objectives:
Part 1: Basic Commands/Utilities
CSE 374 Programming Concepts & Tools
Basic UNIX OLC Training.
What is Bash Shell Scripting?
UNIX Reference Sheets CSE 2031 Fall 2010.
Linux Shell Script Programming
Chapter 3 The UNIX Shells
CSC 4630 Meeting 4 January 29, 2007.
Introduction to Bash Programming, part 3
Presentation transcript:

Additional UNIX Commands

222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities

333 Executing Multiple Commands  Several commands can be executed in a single line, by separating them with ' ; 's:  To run a set of commands in a sub-shell, enclose them within brackets: set a = /home ; echo $a/demo /home/demo ( set a = /home ; echo $a/demo )

444 Executing Commands in a Sub-shell – Example pwd /home/demo (set p = /etc; cd $p ; pwd ; ls -l passwd) /etc -rw-r--r-- 1 root root Dec 3 23:12 passwd pwd /home/demo echo $p p: Undefined variable.

555 The sleep Command  The sleep command just does nothing for the given number of seconds:  Can be useful for interactive scripts  We will use it to demonstrate job control sleep number

666 Job Control  A job is any command line that can be executed by the shell  Multiple jobs can be run concurrently  The shell allows you to manage jobs: Place a job in the background Move a job to the foreground Suspend a job Kill a job

777 Running Jobs in the Background  Typing any command, followed by the ' & ' symbol, will cause the job to be run in the background The job number is printed out for reference  When a job is running in the background, you may continue to type new commands  A message is displayed when the job is complete

888 Running Multiple Jobs  The jobs command will list all current job sleep 10 & [1] 3215 (sleep 5 ; pwd ; sleep 5) & [2] 3216 jobs [1] + Running sleep 10 [2] - Running ( sleep 5; pwd; sleep 5 )

999 Running Multiple Jobs  After 5 seconds, the following is printed:  After a few more seconds:  And finally: /home/demo [1] Done sleep 10 [2] Done ( sleep 5; pwd; sleep 5 )

10 Suspending or Killing the Foreground Job  Pressing Ctrl-Z while some job is running in the foreground will stop its execution The job stops, but is not dead The suspended job will show up in the jobs output, with a status of suspended  Pressing Ctrl-C will completely terminate (or 'kill') the foreground job  The kill command will kill a specific job

11 Moving Jobs Between Background and Foreground  The bg command starts running the specified job in the background The job number should be preceded by a ' % '  The fg command is used to move any background job to the foreground The job will start to run in the foreground, whether it was running or suspended

12 Jobs – Example  We type the following two commands, and press Ctrl-Z immediately after each one: sleep 10 Suspended (sleep 5 ; pwd ; sleep 5) Suspended jobs [1] + Suspended sleep 10 [2] - Suspended ( sleep 5; pwd; sleep 5 )

13 Jobs – Example  Now, we start running the second job in the background:  To move the first job to the foreground: bg %2 [2] ( sleep 5; pwd; sleep 5 ) & /home/demo fg %1 Sleep 10

14 Lecture Overview  Multiple commands and job control  More useful UNIX utilities

15 More Useful Utilities  The UNIX operating system has many other commands  We will briefly review several additional ones now, but you are encouraged to investigate and learn: More commands Additional options and uses for the commands that we have learned

16 Simple Loop – repeat  The repeat command executes any command multiple times  For example: repeat count command repeat 3 echo Hello Hello

17 Date and Time – date  The date command can be used to print the current date and time:  The format argument can be used to control the display of the current time  It may contain literal characters, or special sequences starting with ' % ' date [options] [+format]

18 date – Examples  For example, ' %A ' is the weekday, ' %Y ' is the current year, etc. date +%D 12/04/05 date +"%A, %B %d" Sunday, December 04 date +"Date: %A, %B %d, %Y; Time: %l:%M" Date: Sunday, December 04, 2005; Time: 4:26

19 Getting User Information  Several UNIX commands allow us to get information about other users currently logged-on to the system: who – Shows who is logged on w – Shows who is logged on, and also what they are doing finger – Provides various information about users currently logged-on

20 Splitting Data Streams  The tee command takes input from the standard input, and writes it both to the standard output, and to a list of files:  The following will list all files in the current directory into the file ' all.txt ', and also print a count of all '.c ' files in the directory tee [options] files ls | tee all.txt | grep '.c' | wc -l

21 The find command  The find command searches for files whose name matches a pattern  The most common use of find : Finds all files that match pattern in directory or in any of its sub-directories  find has many other options and uses find directory -name pattern

22 find – Example  find can execute any command  One common use is to execute the grep command on all files:  This will traverse the current directory and all of its sub-directories, and search for the string ' Hello ' in each simple file find. -type f -exec grep -H "Hello" '{}' \;