Compunet Corporation Introduction to Unix (CA263) Your Environment By Tariq Ibn Aziz Dammam Community College.

Slides:



Advertisements
Similar presentations
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Advertisements

CS 497C – Introduction to UNIX Lecture 11: - The File System Chin-Chih Chang
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
More about Shells1-1 More about Shell  Shells (sh, csh, ksh) are m Command interpreters Process the commands you enter m High-level programming languages.
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.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
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.
Compunet Corporation Introduction to Unix (CA263) More on Parameters By Tariq Ibn Aziz Dammam Community College.
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.
CS 497C – Introduction to UNIX Lecture 4: Understanding the UNIX Command Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Using Linux Commands 2 Lab#5
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.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Lecture 3  Shell Variables  Shell Command History  Job / Process Control  Directory Control.
The file structure and related utilities CS240 Computer Science II.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
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.
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.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
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.
Introduction to Linux OS (IV) AUBG ICoSCIS Team Prof. Volin Karagiozov March, 09 – 10, 2013 SWU, Blagoevgrad.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Keyword Shell Variables The shell sets keyword shell variables. You can use (and change) them. HOME The path to your home directory PATH Directories where.
Shell Programming Any command or a sequence of UNIX commands stored in a text file is called a shell program. It is common to call this file a command.
1 Logging in to a UNIX System init ( Process ID 1 created by the kernel at bootstrap ) spawns getty for every terminal device invokes our login shell terminal.
CS465 - UNIX The Bourne Shell.
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
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.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Files and Directories Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction to Unix (CA263) Passing Arguments By Tariq Ibn Aziz Dammam Community College.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
User Environments Objectives –to provide appropriate environments for different types of users Contents –different login programs –user profiles –restricted.
Λειτουργικά Συστήματα - Lab1 Γιάννης Πετράκης. The Operating System  Unix is a layered operating system  The innermost layer is the hardware that provides.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
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?
Shell Programming Features “Full” programming language “Full” programming language Conditional statements Conditional statements Arithmetic, String, File,
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.
Shell Control Statements and More
Linux Commands C151 Multi-User Operating Systems.
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.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
Introduction to Unix (CA263) Command File By Tariq Ibn Aziz.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Compunet Corporation Introduction to Unix (CA263) Round and Round By Tariq Ibn Aziz Dammam Community College.
Configuration your environment Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration.
Compunet Corporation Introduction to Unix (CA263) Reading Data By Tariq Ibn Aziz Dammam Community College.
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.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
CAP652 Lecture - Shell Programming
UNIX and Shell Programming (06CS36)
John Carelli, Instructor Kutztown University
CSCI The UNIX System Shell Startup and Variables
Linux Shell Script Programming
Chapter 3 The UNIX Shells
Introduction to Bash Programming, part 3
Introduction to Unix (CA263) Passing Arguments
Presentation transcript:

Compunet Corporation Introduction to Unix (CA263) Your Environment By Tariq Ibn Aziz Dammam Community College

Compunet Corporation Objectives In this lecture you will learn –Local variable –Subshells –Exported Variables –PS1 and PS2 –Your PATH

Compunet Corporation Objectives In this lecture you will learn –Your Current Directory –More on Subshells –Your.profile File –The TERM Variable

Compunet Corporation Local Variables[1] The vartest consists of echo command that display value of x, surrounded by colons $ cat vartest echo :$x: $ x=100 $vartest :: $ vartest doesn’t know about the value of x. Therefore its value is null.

Compunet Corporation Local Variables[2] $ cat vartest2 x=50 echo :$x: $ x=100 $vartest2 :50: $ Now question is what is the value of x ? $ echo $x 100 $

Compunet Corporation Subshells The behavior exhibited by vartest and vartest2 is due to the fact that these two program are run as subshells by your login shell. When you ask your login shell to execute the vartest, it startup a new shell to execute the program. Whenever new shell runs it runs in its own environment with its own set of local variables. A subshells has no knowledge of local variables that were assigned values by the login shell. A subshell cannot change the value of a variable in the parent shell.

Compunet Corporation Exported Variables There is a way to make the value of a variable known to a subshell, and that’s by exporting it with the export command. Here is a program vartest3 $ cat vartest3 echo x = $x echo y = $y $ $ x=100 $ y=10 $ vartest3 x = y = $ export y $ vartest3 x = y = 10 $

Compunet Corporation Exported Variables Change the value of x and y in vartest4. $ cat vartest4 x=50 y=5 $vartest4 $echo $x $y $

Compunet Corporation Exported Variables $ cat vartest4 x=50 y=5 z=1 export z Vartest5 $ $cat vartest5 echo x = $x echo y = $y echo z = $z $ $ vartest4 x= y=10 z=1 $ When vartest4 get executed, the exported variable y will be copied into the subshell’s environment. vartest4 set the value of x, y and z. The it export z. This makes the value of z accessible to any subshell.

Compunet Corporation Exported Variables Example $ cat vartest4 x=50 y=5 z=1 export y z vartest5 $ $cat vartest5 echo x = $x echo y = $y echo z = $z $ If you change the vartest4 to explicitly export the value of y, then changed value of y will get exported down to vartest5. $ vartest5 x= y=5 z=1 $

Compunet Corporation export with No argument If you just type export, not followed by any argument, you will get a list of the exported variables that are exported by your shell. export LOGNAME export PATH export TIMEOUT export TZ export y

Compunet Corporation PS1 and PS2 The characters that the shell display as your command prompt are stored in the variable PS1. You can change this variable to be anything you like. $ echo :$PS1: :$ : $ PS1="==>“ ==>

Compunet Corporation PS1 and PS2 Your secondary command prompt, normally > is kept in the variable PS2, where you can change it as you like. $ echo :$PS2: :> : $ PS2="=====>” $ $ for x in =====> do =====> echo $x =====> done $

Compunet Corporation HOME variable Your home directory is where you are placed whenever you log onto the system. A special variable HOME is also automatically set to this directory when you log on. $ echo $HOME /usr/steve $ HOME=/usr/steve/book $ pwd /usr/steve $ cd $ pwd /usr/steve/book

Compunet Corporation Your PATH Whenever you type in the name of a program to be executed, the shell searches a list of directories until it find the program. The list of directories is contained in a special variable called PATH $ echo $PATH /bin:/usr/bin: You can always override the path variable by specifying the path to the file to be executed.

Compunet Corporation Example PATH The shell will go directly to /bin to execute date. $ /bin/date Or./rolo You can execute rolo without specifying path if the directory of rolo is specified in PATH variable.

Compunet Corporation Your Current Directory $ cat cdtest cd /usr/steve/bin pwd $ pwd /usr/steve $ cdtest usr/steve/bin $ pwd /usr/steve Why we are in /usr/steve where as we changed the directory in cdtest program?

Compunet Corporation CDPATH Variable The CDPATH variable works like the PATH variable. It specifies a list of directories to be searched by the shell whenever you execute the cd command. This search is done only if the specified directory is not given by a full path name and if CDPATH is not null.

Compunet Corporation CDPATH Variable Example If you type cd /usr/steve then the shell changes your directory directly to /usr/steve But if you type cd memos, then shell will look at your CDPATH variable to find the memo directoy. And if the CDPATH looks like this $ echo $CDPATH :/usr/steve:/usr/steve/docs $ cd /usr/steve $ cd memos /usr/steve/docs/memos $ cd bin /usr/steve/bin

Compunet Corporation More on Subshells $ cat vars BOOK=/usr/steve/book UUPUB=/usr/spool/uucppublic DOCS=/usr/steve/docs/memos DB=/usr2/data $ $ vars $ echo $BOOK $

Compunet Corporation The. Command There is a shell built-in command called. (dot). file Whose purpose is to execute the content of file in the current shell. $. vars $ echo $BOOK /usr/steve/BOOK $

Compunet Corporation The.profile Command Your login shell executes two special files on the system. The first is /etc/profile. This file is set up by the two system administrator and usually does things like checking to see if you have mail. The second file that get automatically executed is.profile in your home directory. Your system administrator may have given you a default.profile file when you got your account.

Compunet Corporation The.profile Command $ cat $HOME/.profile PATH="/bin:/usr/bin:/usr/lbin::" export PATH $

Compunet Corporation The TERM Variable If you tend to use more than one type of terminal, then the.profile is a good place to put some code to prompt for the terminal type and then set the TERM variable accordingly. A sample code from.profile file on next slide.

Compunet Corporation The TERM Variable echo "what terminal are you using(hp-2621 is default ?\c" read TERM if [ -z "$TERM" ] then TERM=2621 fi export TERM