UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright 2001-2003.

Slides:



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

Lesson-4 The Shell as Interpreter
1 UNIX System Programming Introduction. 2 Outline UNIX History UNIX Today? UNIX Processes and the Login Process Shells: Command Processing, Running Programs.
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.
The Linux Shell The shell contains
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
Linux+ Guide to Linux Certification, Second Edition
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
Nic Shulver, Scripts and Batch files Scripting in Windows and Linux What is scripting? What is it for? DOS/Windows batch files.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
DAY 2 COP 3502 Fall term UNIX Versions NAMESupplier Based on AIXIBM AT&T System V A/UX Apple Computer AT&T System V DynixSequentBSD HP-UXHewlett-PackardBSD.
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.
An Introduction to UNIX System --- Cosc513 Presentation n Instructor: Morteza Anvari n Author: Yonghong Pan n ID#: n Date: Jan.29, 2001.
Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex Shells Presentation by: Katie Harris Andrew Murray.
An Introduction to Unix Shell Scripting
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.
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.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
Workbook 6 – Part 1 The Bash Shell
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+ Guide to Linux Certification, Third Edition
Basic Shell Scripting - Part 1 Objective - Learn to: Read Start-up Files Edit Start-up Files Modify Your User Environment Communicate with Users Write.
Linux+ Guide to Linux Certification Chapter Eight Working with 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.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
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.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
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.
Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:
Executable scripts. So far We have made scripts echo hello #for example And called it hello.sh Run it as sh hello.sh This only works from current directory?
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.
Introduction to UNIX CS 2204 Class meeting 1 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
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,
Linux+ Guide to Linux Certification, Second Edition
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.
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 SHELL SCRIPTING By Byamukama Frank
CS 350 Lecture 3 UNIX/Linux Shells by İlker Korkmaz and Kaya Oğuz.
Shells.
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
CAP652 Lecture - Shell Programming
The Linux Operating System
Shell Environments.
UNIX and Shell Programming (06CS36)
CHAPTER 8 (skip , ) CHAPTER 10
John Carelli, Instructor Kutztown University
Shell Commands Using BASH Copyright © 2017 Curt Hill.
Shell Programming.
Linux Shell Script Programming
CSE 303 Concepts and Tools for Software Development
Chapter 8 The Bourne Again Shell
Unix Shell Environments
Chapter 3 The UNIX Shells
Presentation transcript:

UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright

(C) Doug Bowman, Virginia Tech, Shell characteristics Command line interface between the user and the system Is simply a program that automatically starts when you login Waits for user to type in commands

(C) Doug Bowman, Virginia Tech, Main shell features Interactivity aliases file-name completion Scripting language Allows programming (shell scripting) within the shell environment Uses variables, loops, conditionals, etc. Next lecture

(C) Doug Bowman, Virginia Tech, Various UNIX shells sh (Bourne shell, original UNIX shell) ksh (Korn shell) csh (C shell, developed at Berkeley) tcsh bash (Bourne again SHell) … Differences mostly in level of interactivity support and scripting details

(C) Doug Bowman, Virginia Tech, The Bourne again SHell (bash) We will be using bash and ksh as the standard shells for this class This will be important for shell scripting assignments Superset of the Bourne shell (sh) Borrows features from sh, csh, tcsh & ksh Created by Free Software Foundation

(C) Doug Bowman, Virginia Tech, Changing your shell On most UNIX machines (and lab): which bash (note path) chsh On the some machines: which ksh (note path /bin/bash) ypchsh

(C) Doug Bowman, Virginia Tech, Environment variables A set of variables the shell uses for certain operations Variables have a name and a value Current list can be displayed with the env command A particular variable’s value can be displayed with echo $

(C) Doug Bowman, Virginia Tech, Some Environment variables Some interesting variables: HOME, PATH, PS1, USER, HOSTNAME, PWD $HOME /home/gradstudents/m/miali $PATH /usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin $PS1 $USER sgifford $HOSTNAME avocado.cslab.vt.edu $PWD /home/grads/sgifford

(C) Doug Bowman, Virginia Tech, Setting environment variables Set a variable with = Examples: TERM=vt100 PS1=myprompt> PS1=“multiple word prompt> “ PATH=$PATH:$HOME/bin PATH=$PATH:~ DATE=`date`

(C) Doug Bowman, Virginia Tech, Aliases Aliases are used as shorthand for frequently- used commands Syntax: alias = Examples: alias ll=“ls -lF” alias la=“ls -la” alias m=more alias up=“cd..” alias prompt=“echo $PS1”

(C) Doug Bowman, Virginia Tech, Repeating commands Use history to list the last 16 commands Use fc -l to list previously typed commands m through n

(C) Doug Bowman, Virginia Tech, Editing on the command line Some command lines can be very long and complicated - if you make a mistake you don’t want to start all over again You can interactively edit the command line in several ways if using ksh set -o vi allows you to use vi commands to edit the command line set -o vi-tabcomplete also lets you complete commands/filenames by entering a TAB

(C) Doug Bowman, Virginia Tech, Login scripts You don’t want to enter aliases, set environment variables, set up command line editing, etc. each time you log in All of these things can be done in a script that is run each time the shell is started

(C) Doug Bowman, Virginia Tech, Login scripts (continued) For bash, order of files is: /etc/profile ~/.bash_profile ~/.bash_login ~/.profile After logout ~/.bash_logout

(C) Doug Bowman, Virginia Tech, Example.bash_profile (partial) #.bash_profile: executed by bash(1) for login shells umask 022 # include.bashrc if it exists if [ -f ~/.bashrc ]; then source ~/.bashrc fi # some ls aliases alias ll='ls -l' alias la='ls -A' alias l='ls -CF'

(C) Doug Bowman, Virginia Tech, Login scripts (continued) For ksh, login shells execute: ~/.profile If ENV is set: That file is executed for each new terminal Example: ENV=$HOME/.kshrc EXPORT ENV

(C) Doug Bowman, Virginia Tech, Background processing Allows you to run your programs in the background emacs vi_practice_edited &

(C) Doug Bowman, Virginia Tech, stdin, stdout, and stderr Each shell (and in fact all programs) automatically open three “files” when they start up Standard input (stdin): Usually from the keyboard Standard output (stdout): Usually to the terminal Standard error (stderr): Usually to the terminal Program command stdin stdout Programs use these three files when reading (e.g. cin, writing (e.g. cout ), or reporting errors/diagnostics