Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:

Slides:



Advertisements
Similar presentations
Introduction to UNIX. 2 Multitasking zForeground yCurrent Task yThe Command Running at the `$` Prompt zBackground yCommand Running Behind the Scenes yNot.
Advertisements

Bash startup files Linux/Unix files stty 1.  midterms  bash startup files  stty 2.
Chapter 9: The TC Shell Everything you thought you knew is now wrong.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
CS465 – Unix The Korn Shell (ksh).
2000 Copyrigths Danielle S. Lahmani UNIX Tools G , Fall 2000 Danielle S. Lahmani Lecture 3.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
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.
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Using Linux Commands 2 Lab#5
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 Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – Shell Programming The activities of.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Introduction to Shell Script Programming
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Chapter 6: Shell Programming
Unix Shells: C, Bourne, Bourne Again, Korn, and Tenex Shells Presentation by: Katie Harris Andrew Murray.
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.
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.
U NIX C OMP -145 L ECTURE 6: C USTOMIZING THE S HELL E NVIRONMENT T EXT : S. D AS, “Y OUR U NIX : T HE ULTIMATE G UIDE ”, 2 ND E DITION, M C G RAW H ILL,
Workbook 6 – Part 1 The Bash Shell
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
1 Homework / Exam HW7 is due next class Starting Glass chapter 4 and parts of 7 Exam 3 – Class 26 –Open Book / Open Notes –Up through End of K&R Chapter.
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.
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Workbook 6 – Part 2 The Bash Shell
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.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
UNIX/LINUX Shells Glass & Ables ch. 5 A picture of the relationship between UNIX shells Common Core Bourne Shell Korn Shell Common Core C Shell T Shell.
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.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Environment After log in into the system, a copy of the shell is given to the user Shell maintains an environment which is distinct from one user to another.
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.
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.
Comp 145 – Introduction to UNIX $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 $200 $400 $600 $800 $1000 UNIX Processes.
Agenda Customizing a Unix/Linux account Environment Introduction to Start-up Files (.bash_profile,.bashrc,.profile,.kshrc) Safe Methods for Changing Start-up.
Shells.
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Andy Wang Object Oriented Programming in C++ COP 3330
CAP652 Lecture - Shell Programming
Shell Environments.
Writing Shell Scripts ─ part 3
UNIX and Shell Programming (06CS36)
John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
Andy Wang Object Oriented Programming in C++ COP 3330
Shell Programming.
Linux Shell Script Programming
Unix Shell Environments
Chapter 3 The UNIX Shells
Presentation transcript:

Customizing the Shell Environment

UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive: programmable shell scripts Choices of shells –Bourne- good programming features, weak interactions –C (Bill Joy at Berkeley)- good interactions, weak programming –Korn- best of both shells –Bash (GNU)- conforms to POSIX shell specification User’s shell specified in /etc/passwd. Use echo $SHELL Shell features are customizable.

Review: Exporting and Environment Variables A local variable is not visible in child processes: $ x=5 ; sh Create a child process $ echo $x No value in child! An exported variable is visible in all child processes: $ x=5 ; export x x is now environmental $ sh ; echo $x Create a child process 5 Changes made in child are not available in parent: $ x=7 Value set in child $ exit Child dies; back to parent $ echo $x 5 Original value in parent

Some Important Environment Variables SHELL – user’s login shell HOME – user’s home directory LOGNAME, USER – user’s login name PATH – list of directories to search for commands TERM – type of terminal MAIL – user’s mailbox file PS1, PS2 – primary and secondary prompt strings The set command (without parameters) displays the values of all variables (both local and environment). The env command displays the values of only the environment variables.

Aliases alias command assigns shorthand names to commands General Form: alias commandname=“command [options]” Examples: alias..=“cd..” alias search=grep alias rm="rm -i” No whitespace around “=“ Use unalias commandname to unset an assignment alias without parameters displays all assigned aliases Aliases are not supported in Bourne Shell

Aliases continued Too much aliasing can be confusing. Useful command: whence cmdname  Checks whether an alias "took”  returns the path when cmdname is the name of a script or executable program, or the command executed when it's an alias.

Login Scripts Profiles are scripts that are executed when a user logins. Profile is located in a file named.profile (.login for C Shell) In the user’s home directory. A typical.profile : export PATH=$PATH:$HOME/bin export TERM=vt100 stty intr ^C alias rm=“rm –i” set –o ignoreeof echo “Today is `date`” C shell also provides a logout script (.logout ) feature.

Other Shell-Specific Features Command History (not Bourne) – lets you recall previous commands and edit/ re-execute them. Example: $ history 2 display the last 2 commands 39 cp *.c../backup 40 history 2 $ !39 re-execute event 39 (C/ Bash) Whole set of history commands available for editing /repeating commands Command set is different for Korn shell (e.g., r39 re-executes event 39)

Other Shell-Specific Features Continued In-Line Command Editing (Bash only) – lets you perform vi/ emacs-like editing of commands. Use a setting like: $ set –o vi Tilde Substitution (not Bourne) – use ~ as shorthand substitution for your home directory. Examples: $ cd ~rick goes to rick’s home directory $ cd ~ also goes to rick’s home directory! $ cd ~~ goes to the directory you last cd ’d to

Other Shell-Specific Features Continued set Command (not Bourne) : set displays the values of all shell variables set -o vi set editor to vi for command line editing set –o noclobber prevent file overwriting using > and >> set –o ignoreeof prevent termination of session with ctl-d set –o notify notify immediately when a background job is done unset –o removes the option setting or set +o

Summary of Shell Features FeatureBourneCKornBash Command shcshkshbash Environment Variables exportsetenvexport AliasesN/AYes Login Files.profile.login.profile Command HistoryN/A !r! In-Line Command EditingN/A set –o vi Tilde SubstitutionN/AYes Set optionsN/AYes