Jozef Goetz, 2007 1 expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.

Slides:



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

Chapter 9: The TC Shell Everything you thought you knew is now wrong.
1 Introduction to UNIX Ke Liu
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
UNIX chapter 04 UNIX Shells Mr. Mohammad Smirat. Introduction The shell is the software that listens to commands typed in at the terminal and translates.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
The UNIX Shells 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell.
More Shell Programming Learning Objectives: 1. To learn the usage of environment (shell) variables in shell programming 2. To understand the handling of.
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
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.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Introduction to Linux Operating System Tutorial 1
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 System --- Cosc513 Presentation n Instructor: Morteza Anvari n Author: Yonghong Pan n ID#: n Date: Jan.29, 2001.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
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.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
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.
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
Linux Operations and Administration
Basic Shell Scripting - Part 1 Objective - Learn to: Read Start-up Files Edit Start-up Files Modify Your User Environment Communicate with Users Write.
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.
Workbook 6 – Part 2 The Bash Shell
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.
Chapter 0 A “Quick-Start” into the UNIX Operating System.
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.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Customizing Linux Environment Tutorial 4 ENGR 3950U / CSCI 3020U Operating Systems Instructor: Dr. Kamran Sartipi.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
Chapter 4 LINUX Shells. Table 4.1 Shell Locations and Program Names.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Using UNIX Shell Scripts Michael Griffiths Corporate Information and Computing Services The University of Sheffield
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:
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
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.
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 SHELL SCRIPTING By Byamukama Frank
CS 350 Lecture 3 UNIX/Linux Shells by İlker Korkmaz and Kaya Oğuz.
A “Quick-Start” into the UNIX Operating System
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
System Programming and administration CS 308
Shell Environments.
UNIX and Shell Programming (06CS36)
CSC 140: Introduction to IT
John Carelli, Instructor Kutztown University
Shells jbliao.
Shells.
Linux Shell Script Programming
Unix Shell Environments
Chapter 3 The UNIX Shells
Introduction to Bash Programming, part 3
Presentation transcript:

Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert Koretsky, Syed A. Sarwar

Jozef Goetz, Objectives To describe what a UNIX/LINUX shell is To describe briefly some commonly used shells

Jozef Goetz, what a UNIX/LINUX shell acts as an interface between the user and the UNIX/LINUX kernel goal: interpret the user’s cmds Shell = Command Interpreter Shell command can be internal - built-in cmd (part of the shell process - bg, cd, continue, echo, exec) or external cmd (grep, more,cat, mkdir, rmdir, ls) a file in the form of a binary executable program file or a shell script to terminate a shell press

Jozef Goetz, how it works after reading the user’s cmd, it determines whether cmd is internal own code is executed or external cmd search for a file that has the name of the cmd by searching several directories the search path is determine in the shell variables PATH (or path in the TC shell) You can view the search path by using echo $PATH

Jozef Goetz, PATH and path variables search PATH variable defined in a hidden file called.profile or.login in a system start-up file or start-up file (ha dot file -.bashrc for Bash and.cshrc file for TC shell) in your home directory. in TC shell (separated by “ “ ) in Bourne, Korn, and Bash shell (separated by “:” ) // set path, the search starts with ~/bin and then with. // ~ represents a home directory

Jozef Goetz, PATH and path variables To change the search path temporary - change the value of PATH PATH=~/bin:$PATH:. - The search path has been modified by 2 directories, ~/bin and. (current directory) To change the search path permanently you need to change it in the corresponding “.” dot file

Jozef Goetz, Intro to UNIX Shell The UNIX/LINUX shell is a program that starts running when you log on and interprets the commands that you type.

Jozef Goetz, Which Shell Suits Your Needs? reach common-level interface good programming language good features of sh and csh and is a superset of sh more adv programming features than tcsh equally powerful in their interactive use

Jozef Goetz, Table 4.1 Shell Locations and Program Names chsh – change the default shell chsh –l available shells with a path [jgoetz jgoetz]$ chsh -l /bin/bash /bin/sh /bin/bash2 /bin/tcsh /bin/csh /bin/badsh

Jozef Goetz, Shell Similarities exec /bin/csh - the same as issuing command csh

Jozef Goetz, Table 4.2 Shell Similarities and Dissimilarities

Jozef Goetz, Table 4.2 Shell Similarities and Dissimilarities

Jozef Goetz, Table 4.3 Some Useful Shell Built-In Commands

Jozef Goetz, Ways to Change Your Shell When you 1 st logon your default shell will be shown by typing: $ echo $SHELL /bin/csh $ chsh –l // gives you a list of all shells available You can change your shell one of 2 ways: 1. You can change to a new default for every subsequent login session on your system Changing the default shell: $ chsh // may not working on your system ask you for your login password then type complete path shell: e.g. /bin/tcsh 2.You can create additional shell sessions running on top of, or concurrently with, the default shell Create or run additional shells on top of your default shell $ echo $ SHELL /usr/bin/sh $ csh // new one % // use ps to test it or exec /bin/csh

Jozef Goetz, Start-up Files Initial system start-up file has initial settings of important variables for the shell and some other utilities /etc/profile When you start particular shell the corresponding shell start-up file found in the user’s home dir initially configured by the administrator executes:.profile // Bourne, Korn.cshrc.kshrc // Korn.bashrc.zshrc.tcshrc

Jozef Goetz, Table 4.5 Some important Shell Startup Files for Bash and TC Shells bash 4 bash 1. When you log on and your login shell is Bash, it first executes commands in the /etc/profile file, if this file exists. 2. It then searches for the ~/.bash_profile, ~/.bash_login, or ~/.profile file, in this order, and executes commands in the first of these that is found and is readable. 3. When you start an interactive Bash shell, it executes commands in the ~/.bashrc file, if this file exists and is readable. 4. When a login Bash exits, it executes commands in the ~/.bash_logout file. When started non-interactively to run a shell script (see Chapters 15 and 16), Bash looks for the environment variable BASH ENV to find out the name of the file to be executed. Numbers show possible sequence of command execution from the corresponding file

Jozef Goetz, Table 4.5 Some important Shell Startup Files for Bash and TC Shells bash 4 bash 1 for tcsh 2 for tcsh 3 for tcsh 4 for tcsh If your shell is a TC shell, it executes commands in the /etc/csh.cshrc or /etc/.cshrc file, if it exists and is readable. A login shell then executes commands in the /etc/csh.login file, if it exists. 1.Every shell (login or non-login) then executes commands in the ~/.tcshrc file (or the ~/.cshrc file if ~/.tcshrc does not exist), followed by reading the ~/.history file. 2. and 3. A login shell then executes commands in the ~/.login and ~/.cshdirs files. 4. When a login TC shell exits, it executes commands in the /etc/csh.logout and ~/.logout files, if they exist and are readable

Jozef Goetz, set | more gives you shell variables values to set a variable set history = 10 for csh (to get it do: exec /bin/csh) setenv | more or setenv variable settings Shell Start-up Files and Environment Variables

Jozef Goetz, Environment Variables seen in shell start-up files C shell are in lowercase, others are Bourne and Korn shells

Jozef Goetz, Displaying files: display all contents of f1, f2: cat f1 f2 more f1 f2 pg f1 f2 // for some shells

Jozef Goetz, Communication Commands Communication Commands: $ who // check the user name to whom you want to talk $ mesg [y|n] // permit execution write or talk $ write user [tty] $ talk user [tty] - shows 2 sections of the screen: sender and receiver $ biff [y|n] // notification on/off

Jozef Goetz, Utility Commands (Contd)

Jozef Goetz, Command Aliases p.55[3] The alias command can be used to create pseudonyms (nicknames) for commands they can be placed in ~/.profile or ~/.login executes when you log on but typically in a shell start files.bashrc (.cshrc for TC shell) every time you start Tcsh or Bash

Jozef Goetz, Command Aliases Syntax for the alias command is: alias [name [ = string ] …] // for Bourne, Korn, Bash shells alias l=‘ls –la’ alias [name [ string ] ] // C shell alias l ‘ls –la’ alias list all aliases remove it unalias ls // remove ls unalias –a // remove all

Jozef Goetz, alias Command Examples The \!* string is substituted by the actual parameter passed to the given command

Jozef Goetz, Displaying System Up Time uptime 1:16pm up 28 days, 10:44, 2 users, load average: 0.04, 0.01, 0.00 displays the duration of time the system has been running since it was last booted, # of users and some additional info

Jozef Goetz, Shell Metacharacters These are the characters other than letters and digits that have special meaning to the shell. They cannot be used in shell commands without specifying them in particular way Allow you to specify multiple files in multiple directories in one command line.

Jozef Goetz,

Jozef Goetz,

Jozef Goetz, Examples of Shell Metacharacters $ lpr -Pspr [0-9][a-zA-Z].html print on the spr printer, P specifies the printer name, then the names of all the files as follows: 2 chr file names with the first chr digit and 2 nd being an uppercase or lowercase letter $ $ ls lab[0-9]??.c lab11a.c lab1a1.c lab123.c lab4ab.c displays 6 chr long files with.c extension

Jozef Goetz, Examples of Shell Metacharacters $ lpr -Pspr [0-9][a-zA-Z].html print on the spr printer, P specifies the printer name, then the names of all the files as follows: 2 chr file names with the first chr digit and 2 nd being an uppercase or lowercase letter $ $ ls lab[0-9]??.c lab11a.c lab1a1.c lab123.c lab4ab.c displays 6 chr long files with.c extension