Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.

Slides:



Advertisements
Similar presentations
Bash startup files Linux/Unix files stty 1.  midterms  bash startup files  stty 2.
Advertisements

CSE4251 The Unix Programming Environment
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
Chapter 9: The TC Shell Everything you thought you knew is now wrong.
''Unix is user friendly -- It's just picky about who it's friends are...'' -- Unknown, seen in.sigs around the world.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Using the Bash Shell. Linux Shell Options Linux provides a range of options for shells. bash –The GNU Bourne Again Shell (bash) bsh – The Bourne Shell.
Shell - Introduction & Commands Chapter III / Part II.
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.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
CENT 305 Information Systems Security Linux Introduction.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
Shell Features CSCI N321 – System and Network Administration Copyright © 2000, 2005 by Scott Orr and the Trustees of Indiana University.
CS 2061 Shells Also known as: Unix Command Interpreter.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Workbook 6 – Part 1 The Bash Shell
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.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
LINUX System : Lecture 6 Shell Programming
Linux+ Guide to Linux Certification, Third Edition
Workbook 6 – Part 2 The Bash Shell
UNIX/LINUX SHELLS.  “A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and.
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.
1 Applied CyberInfrastructure Concepts ISTA 420/520 Fall Nirav Merchant Bio Computing & iPlant Collaborative Eric Lyons.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
June 1, 1999Customizing the UNIX Environment1 Introduction to UNIX G. Customizing the UNIX Environment.
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
User Environments Objectives –to provide appropriate environments for different types of users Contents –different login programs –user profiles –restricted.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
UNIX Shell Dr. Tran, Van Hoai
Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
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.
Unix Advanced Shells Chapter 10. Unix Shells u Command Line Interpreter –once logged in, login gives control to a shell –it prompts for input, then parses,
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
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.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
MaSH – Miniature Shell ● Brief introduction to shell. – What is a shell? ● A program that reads inputs from the keyboard and executes the commands. ● Basic.
1 Applied CyberInfrastructure Concepts 1 Nirav Merchant Bio Computing & iPlant Collaborative Eric Lyons
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
California State University Fresno
CAP652 Lecture - Shell Programming
LINUX System : Lecture 5 (English-Only Lecture)
Shell Environments.
UNIX and Shell Programming (06CS36)
John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
Shells, Help, and Paths.
Shells jbliao.
Linux Shell Script Programming
Unix Shell Environments
Introduction to Unix Shell & Scripting with csh/tcsh
Chapter 3 The UNIX Shells
CMPSC 60: Week 5 Discussion
Presentation transcript:

Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts

Unix Architecture

What is Shell?  Shell is Command Interpreter that turns text that you type (at the command line) in to actions: Command Interpreter that turns text that you type (at the command line) in to actions: User Interface: take the command from user User Interface: take the command from user  Programming Shell can do Customization of a Unix session Customization of a Unix session Scripting Scripting

Types of Shells  Interactive vs. Non-interactive; login or not  Interactive login shell started after login  Non-interactive shell Present when shell script is running Present when shell script is running Just inherits parent’s environment Just inherits parent’s environment  Interactive non-login shell started Started from a command line Started from a command line Copies parent environment then invokes ~/.bash_rc (or ~/.cshrc or ~/.tcshrc) Copies parent environment then invokes ~/.bash_rc (or ~/.cshrc or ~/.tcshrc)

Popular Shells  sh Bourne Shell  ksh Korn Shell  csh,tcsh C Shell (for this course)  bash Bourne-Again Shell

Flavors of Unix Shells  Two main flavors of Unix Shells Bourne (or Standard Shell): sh, ksh, bash, zsh Bourne (or Standard Shell): sh, ksh, bash, zsh FastFast $ for command prompt$ for command prompt C shell : csh, tcsh C shell : csh, tcsh better for user customization and scriptingbetter for user customization and scripting %, > for command prompt%, > for command prompt  To check shell: % echo $SHELL (shell is a pre-defined variable) % echo $SHELL (shell is a pre-defined variable)  To switch shell: % exec shellname (e.g., % exec bash) % exec shellname (e.g., % exec bash)

Startup files  sh,ksh: /etc/profile (out-of-the-box login shell settings) /etc/profile.local (addtnl. local system settings) ~/.profile (addtnl. user customized settings) ~/.kcshrc(non-login shell user customization)  bash: /etc/profile (out-of-the-box login shell settings) /etc/bash.bashrc (out-of-box non-login settings) /etc/bash.bashrc.local (global non-login settings) ~/.bash_profile (login shell user customization) ~/.bashrc(non-login shell user customization) ~/.bash_logout (user exits from interactive login shell) ~/.bash_logout (user exits from interactive login shell)  csh/tcsh: /etc/login (out-of-the-box login shell settings) /etc/csh.login (non-login shell customizations) /etc/csh.login.local (global non-login settings) ~/.login: (login shell user customizations) ~/.cshrc: (non-login shell user customizations) ~/.cshrc.logout: (non-login shells at logout) ~/.logout: (read by login shells at logout)

Some Special Keys Under tcsh  Ctrl-U = Delete everything on the command-line  Ctrl-A = Move cursor to the front  Ctrl-E = Move cursor to the end  Ctrl-P = Set the current command-line to the previous command  Ctrl-N = Set the current command-line to the next command  TAB = Filename completion

What shell am I running? Use the echo command to learn the value of SHELL environment variable Issue a ps command to see all the processes in your current login session

What about my default shell? Use the echo command to learn the value of your default shell To change the your default shell, the systems administrator (e.g., and specify the name of the shell that you Use the finger command to learn anyone’s default shell View the /etc/passwd file to learn login shells and more Use the grep command to search for a string in a file

Its Not Too Late to Change Your Current Shell Use exec to switch to a different shell Issue a ps command to see all the processes in your current login session

More with processes Issue a ps command to see all the processes in your current login session Issue a ps –u $USER command to see all your processes, across all login sessions Use kill to terminate processes that have gone “rogue”

More with processes Issue a ps -aef command to everyone’s processes Pipe ps out put to more command to view page at a time

Environment Variables Use the env command to see all environment variables set to see all shell variables Set or change environment variables from the command-line: new values last only for current login session. sh/bash/ksh set: NEW_VARIABLE=newvalue append:OLD_VARIABLE=$OLD_VARIABLEnewvalue prepend: OLD_VARIABLE=newvalue$OLD_VARIABLE csh/tcsh set: set NEW_VAR=newvalue append: set OLD_VAR=($OLD_VAR newvalue) prepend: set OLD_VAR=(newvalue $OLD_VAR) set: setenv OLD_VAR newvalue append: setenv OLD_VAR ${OLD_VAR}newvalue prepend: setenv OLD_VAR newvalue${OLD_VAR}

Practice Setting Env. Variables Update the PATH environment variable to include your numbered subdirectory Change the PROMPT environment variable

Aliases Use the alias command to create shorthand for longer commands

Command History Your most recent commands are logged in one or more hidden files, which you may browse to keep from having to retype commands. You can set environment variables to configure how many commands are remembered in the current login session (history), how many commands are remembered after you logout (savehist), and the name of the file where these commands are stored (.history). You can browse history commands from the command line.

Customization of a Session  Each shell supports some customization. User prompt User prompt Where to find mail Where to find mail Shortcuts (alias) Shortcuts (alias)  The customization takes place in startup files Startup files are read by the shell when it starts up Startup files are read by the shell when it starts up The Startup files can differ for different shell The Startup files can differ for different shell

Examine Startup files  sh,ksh: /etc/profile (out-of-the-box login shell settings) /etc/profile.local (addtnl. local system settings) ~/.profile (addtnl. user customized settings) ~/.kcshrc(non-login shell user customization)  bash: /etc/profile (out-of-the-box login shell settings) /etc/bash.bashrc (out-of-box non-login settings) /etc/bash.bashrc.local (global non-login settings) ~/.bash_profile (login shell user customization) ~/.bashrc(non-login shell user customization) ~/.bash_logout (user exits from interactive login shell) ~/.bash_logout (user exits from interactive login shell)  csh/tcsh: /etc/login (out-of-the-box login shell settings) /etc/csh.login (non-login shell customizations) /etc/csh.login.local (global non-login settings) ~/.login: (login shell user customizations) ~/.cshrc: (non-login shell user customizations) ~/.cshrc.logout: (non-login shells at logout) ~/.logout: (read by login shells at logout)