Unix Shell Environments. February 23rd, 2004 Class Meeting 6

Similar documents
Chapter 9. Shell and Kernel

5/20/2007. Touring Essential Programs

K.I.S.S. Keep It Simple, Stupid! Outline. Unix System Programming. UNIX History. UNIX History (cont) UNIX Today. What Unix Gets Wrong (Raymond)

System Programming. Unix Shells

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

Introduction to Linux

Work Effectively on the Command Line

Linux Command Line Interface. December 27, 2017

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Unix Shells and Other Basic Concepts

EECS2301. Lab 1 Winter 2016

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

CS2204: Introduction to Unix

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009

Introduction to UNIX Part II

Vi & Shell Scripting

5/8/2012. Specifying Instructions to the Shell Chapter 8

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Standard. Shells. tcsh. A shell script is a file that contains shell commands that perform a useful function. It is also known as shell program.

Environment Variables

CS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Lecture #10 - Interactive Korn Shell (Chapter 11)

Assignment clarifications

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

CS395T: Introduction to Scientific and Technical Computing

Unix. Examples: OS X and Ubuntu

Introduction to Shell Scripting

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

CS246 Spring14 Programming Paradigm Notes on Linux

Log into Linux Reminders: Homework 1 due today; Homework 2 due on Thursday Questions?

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

CST Algonquin College 2

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Environment Variables

Introduction to the Shell

Lab 2: Linux/Unix shell

UNIX shell scripting

UNIX System Programming Lecture 3: BASH Programming

Introduction: What is Unix?

Answers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R

Introduction to UNIX Shell Exercises

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Linux shell scripting intro/review

UNIX Shell Programming

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Using bash. Administrative Shell Scripting COMP2101 Fall 2017

Linux 系统介绍 (III) 袁华

CHAPTER 3 SHELL PROGRAMS: SCRIPTS

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

Command Line Interface Techniques

Shells and Shell Programming

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

UNIX Kernel. UNIX History

Software I: Utilities and Internals. What isbash?

Lecture 8. Introduction to Shell Programming. COP 3353 Introduction to UNIX

ACS Unix (Winter Term, ) Page 21

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala

Part III. Shell Config. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

The Command Line. Matthew Bender. Friday 18 th September, CMSC Command Line Workshop

Creating a Shell or Command Interperter Program CSCI411 Lab

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

COMP 4/6262: Programming UNIX

Review of Fundamentals

Fun with XMMS (and friends)

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Operating Systems. Copyleft 2005, Binnur Kurt

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Shells and Shell Programming

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Bash Programming. Student Workbook

Perl and R Scripting for Biologists

The Online Unix Manual

EECS 470 Lab 5. Linux Shell Scripting. Friday, 1 st February, 2018

CSCI2467: Systems Programming Concepts

Basic Linux. Advanced NDC Training Course

Shell Scripting. Xiaoxu Guan High Performance Computing, LSU February 17, 2016

Sub-Topic 1: Quoting. Topic 2: More Shell Skills. Sub-Topic 2: Shell Variables. Referring to Shell Variables: More

About shells and command lines

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

UNIX Basics. UNIX Basics CIS 218 Oakton Community College

85321, Systems Administration Chapter 6: The shell

CHE3935. Lecture 1. Introduction to Linux

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Unix/Linux: History and Philosophy

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Topic 2: More Shell Skills

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Linux shell scripting Getting started *

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02

Transcription:

Unix Shell Environments February 23rd, 2004 Class Meeting 6

Shell Characteristics Command-line interface between the user and the system Automatically starts when you log in, waits for user to type in commands A Unix shell is both a command interpreter, which provides the user interface to the rich set of utilities, and a programming language, allowing these utilities to be combined.

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

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 http://www.faqs.org/faqs/unix-faq/shell/shell-differences/

Bourne Again SHell We will be using bash as the standard shells for this class Superset of the Bourne shell (sh) Borrows features from sh, csh, tcsh, and ksh Created by the Free Software Foundation

Changing Your Shell On most Unix machines (including the lab)... which bash chsh On some machines... Ypchsh

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 $<var_name>

Environment Variable Examples Some interesting environment variables: $HOME /home/grads/callgood $PATH /usr/local/bin:/bin:/usr/bin:/us r/x11r6/bin $PS1 \u@\h:\w\$ $USER callgood $HOSTNAME mango.cslab.vt.edu $PWD /home/grads/callgood/cs2204

Setting Environment Variables Set a variable with <name>=<value> Examples: PS1=myprompt> PS1=$USER@$HOSTNAME: PS1= multiple word prompt> PATH=$PATH:$HOME/bin PATH=$PATH:~ DATE=`date`

Aliases Aliases are used as shorthand for frequently-used commands Syntax: alias <shortcut>=<command> Examples: alias ll= ls lf alias la= ls la alias m=more alias up= cd.. alias prompt= echo $PS1

Repeating Commands Use history command to list previously entered commands Use fc l <m> <n> to list previously typed commands from m through n

Editing on the Command Line bash provides a number of line editing commands; many are the same as emacs editing commands M-b Move back one word M-f Move forward one word C-a Move to beginning of line C-e Move to end of line C-k Kill text from cursor to end of line

Login Scripts You don t want to enter aliases, set environment variables, 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

Login Scripts (cont) For bash, order is... /etc/profile ~/.bash_profile ~/.bash_login (if no.bash_profile) ~/.profile (if neither are present) ~/.bashrc After logout... ~/.bash_logout

Example.bash_profile (partial) #.bash_profile # include.bashrc if it exists if [ -f ~/.bashrc ]; then. ~/.bashrc fi # Set variables for a warm fuzzy environment export CVSROOT=~/.cvsroot export EDITOR=/usr/local/bin/emacs export PAGER=/usr/local/bin/less

Example.bashrc (partial) #.bashrc # abbreviations for some common commands alias f=finger alias h=history alias j=jobs alias l='ls -lf' alias la='ls -alf' alias lo=logout alias ls='ls -F'

Login Shell /etc/profile ~/.bash_profile ~/.bashrc interactive shell ~/.bashrc login shell interactive shell ~/.bashrc interactive shell ~/.bashrc

Background Processing Allows you to run your programs in the background callgood@mango:~/$ emacs textfile& callgood@mango:~/$

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 Programs use these three files when reading (e.g. cin), writing (e.g. cout), or reporting errors/diagnostics