Shell Features CSCI N321 – System and Network Administration

Slides:



Advertisements
Similar presentations
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
Advertisements

NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
2006-Jan-231 Shell Scripts Jacob Morzinski
Linux+ Guide to Linux Certification, Second Edition
Shell Basics CS465 - Unix. Shell Basics Shells provide: –Command interpretation –Multiple commands on a single line –Expansion of wildcard filenames –Redirection.
23-Jun-15Advanced Programming Spring 2002 bash Henning Schulzrinne Department of Computer Science Columbia University.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Shell Script Examples.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Introduction to Shell Script Programming
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
An Introduction to Unix Shell Scripting
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 8 Shell.
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.
Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University.
Hp education services education.hp.com hp education services education.hp.com 1 HP World/Interex 2002 Linux BASH Shell Programming Chris Cooper (734)
CS 2061 Shells Also known as: Unix Command Interpreter.
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.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux+ Guide to Linux Certification, Third Edition
Workbook 6 – Part 2 The Bash Shell
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
Lesson 2 1.Commands 2.Filename Substitution 3.I/O Redirection 4.Command Grouping 5.Shell Responisibilites Review of the Basics.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.
(A Very Short) Introduction to Shell Scripts CSCI N321 – System and Network Administration Copyright © 2000, 2003 by Scott Orr and the Trustees of Indiana.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Chapter Six Introduction to Shell Script Programming.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Chapter 8: The Bourne Again Shell It’s a command interpreter, it’s a programming language, and it makes a mean martini.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
Configuration your environment Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration.
1 © 2012 John Urrutia. All rights reserved. Chapter 09 The TC Shell.
Lesson 8-Specifying Instructions to the Shell. Overview An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing.
Linux Administration Working with the BASH Shell.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
Introduction to the bash Shell (Bourne-Again SHell)
ULI101 Week 10. Lesson Overview ● Shell Start-up and Configuration Files ● Shell History ● Alias Statement ● Shell Variables ● Introduction to Shell Scripting.
CIRC Summer School 2016 Baowei Liu
Implementation of a simple shell, xssh
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Implementation of a simple shell, xssh (Section 1 version)
Shell Environments.
CSE 303 Concepts and Tools for Software Development
CHAPTER 8 (skip , ) CHAPTER 10
CSC 140: Introduction to IT
John Carelli, Instructor Kutztown University
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Unix Shell Environments
Module 4 Command Line Skills
Chapter 3 The UNIX Shells
Introduction to Bash Programming, part 3
Presentation transcript:

Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University

Section Overview I/O Substitution Pathname Substitution Parameter/Variable Substitution Command Substitution

References CQU 85321 System Administration Course Textbook Lectures Chapter 7 Lectures 2002 #6

UNIX Shell Enables users to enter commands Text based Similar to MSDOS Command Prompt (but are much more powerful) Common Shells Bourne: sh, ksh, bash C: csh, tcsh

Shell Features Environment variables and aliases History of commands used Programming constructs Added features in newer shells Command line editing Command line completion Shell configuration files

Command History/Editing Most shells maintain a history of previously entered commands history: View list of commands !#: Rerun command number # Command line editing Up/down arrow keys to cycle through list Left/right arrow keys to move within listed command <ctrl><a>: move to start of command line <ctrl><e>: move to end of command line

Command Aliases Shortcut for command line Set/view using the alias command Examples: alias ls='ls --color=tty' alias rm='rm –i'

Shell Variables Customize environment Shared settings for programs Assigning Variables: var=“value” Referencing Variables: $var Viewing variables: set, printenv Variables are case sensitive

Special Shell Variables HOME – User’s home directory path SHELL – Current shell UID – User’s UID number PATH – Program search path PS1/PS2 – Format for command prompt (prompt for csh/tcsh) Must use “export” to set variables in shell

bash Shell Logins /bin/bash /etc/profile.d/ /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc or ~/.bash_login ~/.profile or

Parsing the Command Line Breaks the command line into components Special Characters modify operation How command runs Filename Expansion I/O redirection Quotes

Command Run Modifiers Write Space – Separate arguments Newline (<cr>) – End of line Special Characters Character Meaning ; Separate multiple command on same line & Run command in the background \ At end of line, continue on next line || && Logical operators based on exit status

Filename Expansion Special characters representing multiple filenames Also referred to as globbing Character Matches * 0 or more characters ? 1 character [ ] Matches any 1 character in [ ] (including ranges) [^ ] Matches any 1 character not in [ ]

command << label I/O Redirection Modifies how input and output is used Chain command to solve bigger tasks Characters Result command < file Use file as input for command command > file Store command output in file command >> file Append command output to file command << label Input from standard input until label `command` Execute command then replace command name with its output cmd1 | cmd2 Use output from cmd1 as input to cmd2

Standard File Descriptors Special file pointers for input and output Extension from C language Name Descriptor Default Device Standard input (stdin) Keyboard Standard output (stdout) 1 Screen Standard error (stderr) 2

Using File Descriptors Finer control over input/output redirection stdout and stderr can be redirected to same file Characters Result command 2> file stderr output stored in file cmd >& <file-descriptor> Output redirected to <file-descriptor> Cmd > file 2>&1 Stderr & stdout redirected to file

Quote Characters Prevent special characters from being interpreted by the shell Character Name Action ‘ Single Quote Shell ignores all special characters enclosed ‘ ’ “ Double Quote Shell ignores all special characters enclosed “ ” except for $ ‘ \ \ Backslash Shell ignores character immediately following \