System Programming. Unix Shells

Size: px
Start display at page:

Download "System Programming. Unix Shells"

Transcription

1 Content : Unix shells by Dr. A. Habed School of Computer Science University of Windsor adlane@cs.uwindsor.ca adlane/60-256

2 Content Content 1 Introduction 2 Interactive and non-interactive shells login and non-login shells Exiting a shell 3 Definition Environment and Shell variables The global/local variables relationship Getting and setting variables 4 5 csh startup files tcsh startup files bash startup files 6

3 Introduction What is a shell? A shell is a program that acts as an interface between a user and the operating system. A Unix shell is basically a command interpreter. A Unix shell interprets commands that are either typed-in (keyboard) or in a script-file.

4 Running shells Introduction Running shells A shell can run as: a login shell: it is the first shell that runs as you login. a non-login shell: it is a shell that the user, a script-file or a program executes after login an interactive shell: it is a shell that waits for user input through a command line. a non-interactive shell: it is responsible of executing a shell script and does not wait for user input.

5 Some existing shells Many shells exist. They differ by their syntax and by the functionalities that they offer. Some existing shells All shells are normally located in /usr/bin/ or /bin/: Bourne shell: sh is the most basic shell. C shell: csh richer than sh, syntax to C. Korn shell: ksh derived from sh with more functions. TC shell: tcsh derived from csh with more functions. Bourne Again Shell: bash compatible with sh and ksh.

6 Interactive vs. non-interactive shells Interactive and non-interactive shells login and non-login shells Exiting a shell An interactive shell An interactive shell 1 reads a special startup files that contain some initialization information. 2 displays a prompt and waits for user commands then, 3 the shell executes the user s command and returns to step 2 unless it is terminated. A non-interactive shell In general, a non-interactive shell is present to run a script-file. The first line of a script-file indicates the shell that will run the script. A script-file starting with the line: #!/usr/bin/csh will automatically run under the C shell

7 The login shell Introduction Interactive and non-interactive shells login and non-login shells Exiting a shell The login shell Your login shell it is the first shell that runs as you login to your account on the computer. This shell is interactive. The Unix system administrator chooses a shell for each user when the account is created. This is your login or default shell. The name of your login shell program can be found in the corresponding line in /etc/passwd.

8 A non-login shell Introduction Interactive and non-interactive shells login and non-login shells Exiting a shell A non-login shell can be either interactive or non-interactive: non-login non-interactive shell An example of a non-login non-interactive shell is one that executes a script-file as discussed in the previous slides. non-login interactive shell An example of a non-login interactive shell is one that is started from the command line by typing its name. For example, to run C shell, type: csh

9 Changing your login shell Interactive and non-interactive shells login and non-login shells Exiting a shell Changing your login (or default) shell You can change your login shell by: changing your entry in the passwd file (you need to be a super-user) using the chsh command (not always available). The passwd command can also be used (with appropriate options). The new shell must be a valid shell, i.e. defined in the file /etc/shells. This file must be defined by the super-user.

10 Exiting a shell Introduction Interactive and non-interactive shells login and non-login shells Exiting a shell Because the shell accepts commands from the keyboard, it terminates when the end-of-file character CTRL-D is entered. The exit command allows also to exit a shell. When the user logs out from the system When the user is logging out from the system, the shell reads and executes commands from a file (if the file exists). For example: csh and tcsh execute the file /.logout bash executes /.bash logout

11 : definition Definition Environment and Shell variables The global/local variables relationship Getting and setting variables A Unix variable allows passing information from the shell to programs. Its value is a string or a set of strings. Variable names are case sensitive. A variable name may contain up to 20 characters (numbers, letters and the underscore character). A program looks for a particular variable and uses its value. A variable can be set either by the system, the user (through a command-line), the shell, a program.

12 Environment and Shell variables Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Environment and Shell variables are, in general, used to customize the environment in which your shell runs. Most of these variables are initialized by a start-up file. Standard are split into two categories, 1 Shell variables are local variables. They apply only to the current instance of the shell and are used to set short-term working conditions. By convention, they are named in lower case characters. 2 Environment variables are global variables. They have a farther reaching significance, and those set at login are valid for the duration of the session. By convention, they are named in upper case characters.

13 Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Example of environment (global) variables OSTYPE: the name of the current operating system USER: your login name LOGNAME: the login-name of the user HOME: the path name of your home directory MAIL: the path to your mail inbox HOST: the name of the computer you are using DISPLAY: the name of the computer screen display PRINTER: the default printer EDITOR: the default text editor PATH: the directories the shell should search to find a command SHELL: the full pathname of the login shell

14 Example of shell (local) variables Definition Environment and Shell variables The global/local variables relationship Getting and setting variables argv: an array of command/program arguments cwd: the full pathname of the current directory gid: the user s real group ID history: indicates the number of history events to save. home: initialized to the home directory of the invoker. owd: the old (pr previous) working directory path: a list of directories to look for executable commands prompt: the string printed before reading a command shell: the full pathname of the running shell term: the terminal type tty: the name of the tty (TeleTYpe) terminal uid: the user s real user ID user: the user s login name

15 Definition Environment and Shell variables The global/local variables relationship Getting and setting variables The global/local variables relationship (in general) In general In general, environment and shell variables that have the same name (apart from the case) are distinct and independent. Possibly, these variables can have the same initial values.

16 Definition Environment and Shell variables The global/local variables relationship Getting and setting variables The global/local variables relationship (special cases) There are, however, some exceptions to the general case: HOME, USER and TERM PATH Every time the shell variables home, user and term are changed, the corresponding environment variables HOME, USER and TERM receive the same values. However, changing the environment variables has no effect on the corresponding shell variables. PATH and path specify directories to search for commands and programs. Both variables always represent the same directory list, and altering either automatically causes the other to be changed.

17 Getting the value of a variable Definition Environment and Shell variables The global/local variables relationship Getting and setting variables The value of an environment or shell variable is either a string or a set of strings. Regardless of which shell is running, getting the value of a variable is possible by placing the $ sign at the beginning of the variable name. e.g.: $VARIABLE Regardless of the running shell, you can also get the value of the variable by using. e.g.: ${VARIABLE} which is particularly useful if the variable name is immediately followed by other text.

18 Examples Introduction Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Example Determining your login shell The pathname of the login shell is stored in the shell variable SHELL. You get your login shell by typing echo $SHELL /bin/tcsh Example echo My shell saves $history events My shell saves 32 events echo My shell does not save ${history}00 events My shell does not save 3200 events

19 Setting a variable Introduction Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Unlike getting the value of a variable, setting a variable differs from one shell to another. For example, to define a variable COLOR: using Bourne shell (sh): COLOR=green By default, variables in this shell are local. To turn a local variable global, use: export COLOR using C shell and TC shells: setenv COLOR green setenv is used for global (environment) variables. For local (shell) variables, use: set color=green Note the difference in the syntax of setenv and set.

20 How to unset a variable Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Syntax in csh and tcsh: unset [var-name-list], for local variables Or, unsetenv [var-name-list], for environment variables

21 Listing the values of all variables Definition Environment and Shell variables The global/local variables relationship Getting and setting variables Remark Under csh and tcsh, set without arguments displays all shell variables and their values, setenv without arguments displays all environment variables and their values.

22 Example 1 Introduction Definition Environment and Shell variables The global/local variables relationship Getting and setting variables The following examples shows that an environment variable COLOR when set, is inherited by subsequent shells. This variable is initially undefined in all shells. Lines starting with # are comments for clarity. Example on our luna server with tcsh as a login shell luna: >setenv COLOR yellow #set COLOR as an environment variable luna: >echo $COLOR #display the value of the variable COLOR yellow luna: >tcsh #run a new instance of tcsh luna: >echo $COLOR #display the value of the variable COLOR yellow luna: >bash #run an instance of bash bash-3.00$ echo $COLOR #display the value of the variable COLOR yellow

23 Example 2 Introduction Definition Environment and Shell variables The global/local variables relationship Getting and setting variables The following examples shows that a shell variable color when set, is not inherited by subsequent shells. This variable is initially undefined in all shells. Lines starting with # are comments for clarity. Example on our luna server with tcsh as a login shell luna: >set color=red #set color as a shell variable luna: >echo $color #display the value of the variable color red luna: >tcsh #run a new instance of tcsh luna: >echo $color #display the value of the variable color color: Undefined variable. luna: >bash #run an instance of bash bash-3.00$ echo $color #display the value of the variable COLOR #an empty line is displayed

24 External vs. internal commands A shell command can be internal (built-in): the code to be executed is part of the shell. Running these commands does not require searching their path by the system. external: the code to be executed resides in a sperate binary file. Running these commands requires searching their path by the system.

25 External Commands PATH For an external command, the shell searches for its file in the directories whose names are stored in the variable PATH. How to define the shell variable PATH? Example: set path =./:/usr/bin: /bin the shell looks for the command in order in the current directory, called./, /usr/bin/ your-login-directory/bin/ (which is also /bin) Remark Note that after the above setting, both path and PATH contain the same string./:/usr/bin: /bin.

26 Modifying the PATH variable Modifying the PATH variable To add more directories to your current path by: set path = /usr/local/bin:$path You can view your path: echo $PATH The command which followed by the command-name allows you to find the file location of the command. Examples: which echo, which emacs Remark Note that PATH is set in a shell startup file, Example: in the file /.cshrc, where / represents the current user login directory.

27 Startup files Introduction csh startup files tcsh startup files bash startup files Most environment and shell variables are initialized by the startup files. Different shells read different startup files. Some startup files are in the directory /etc/. These are intended for system wide initialization of environment variables. You can customize your environment and shell variables by assigning different values to these variables in the startup files in your home directory (which we refer to as ).

28 C shell (csh) startup files csh startup files tcsh startup files bash startup files Whenever invoked When csh is invoked, it first executes the commands in the system-wide startup file, usually located in /etc/csh.cshrc. Then, csh reads and executes a script named /.cshrc. Invoked as a login shell In addition to the above files, tcsh reads and executes the files /etc/csh.login and /.login once only at login.

29 TC shell (csh) startup files csh startup files tcsh startup files bash startup files Whenever invoked When tcsh is invoked, it first executes the commands in the system-wide startup file, usually located in /etc/csh.cshrc. Then, tcsh reads and executes a script named /.tcshrc. If /.tcshrc is not found, then it executes /.cshrc. Invoked as a login shell In addition to the above files, tcsh reads and executes the files /etc/csh.login and /.login once only at login.

30 csh startup files tcsh startup files bash startup files Bourne Again shell (bash) startup files Invoked as a login shell bash attempts to read several initialization files: First, it reads and executes commands in /etc/profile Then, it reads and executes commands from the first one of the files /.bash profile, /.bash login and /.profile Invoked as an interactive non-login shell bash reads and executes commands from /.bashrc. Invoked as a non-interactive shell When a non-interactive bash is started, bash reads and executes commands in the file named by the variable $BASH ENV if defined.

31 Example of /.cshrc in luna csh startup files tcsh startup files bash startup files Example /11/29 SMI umask 077 set path=(/bin /usr/bin /usr/ucb /etc.) if ( $?prompt ) then set history=32 endif if ( -f /etc/system.cshrc) then source /etc/system.cshrc endif

32 ... These are special characters with special meanings: >: Output redirection E.g., ls > filename.txt <: Input redirection E.g., mailx < letter.txt >>: Output redirection, appends to a file E.g., ls >> filename.txt *: filename Wild card, matches 0 or more characters E.g., rm *ps, delete all files ending with ps.?: filename Wild card, matches 1 character. E.g., rm *.? delete files with one character after. ls?? list files/directories made up of 2 characters.

33 (cont d) command : command substitution, replaced by the command output. E.g. 1. echo The date of today is date E.g. 2. echo hello ls hello ls echo hello ls hello followed by the ls outputs. : Pipe between two commands. E.g., ls wc -w output of ls is piped to wc to get the number of files/directories. Note the utility wc displays a count of lines, words and characters in a file. ;: Used to sequence commands E.g., date ; ls; date : Executes a command if the previous one fails. E.g., cc prog1.c CC prog1.c gcc prog1.c

34 (cont d) && : Executes a command if the previous one succeeds E.g., CC prog1.c -o prog1 &&./prog1 &: Executes a command in the background E.g., netscape & #: characters after this are ignored (comment) $: Expands the value of a shell variable E.g., echo $PATH \: Prevents special interpretation of next character. E.g., echo this is \& this is & & is not a metacharacter in this case.

5/20/2007. Touring Essential Programs

5/20/2007. Touring Essential Programs Touring Essential Programs Employing fundamental utilities. Managing input and output. Using special characters in the command-line. Managing user environment. Surveying elements of a functioning system.

More information

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

5/8/2012. Specifying Instructions to the Shell Chapter 8 An overview of shell. Execution of commands in a shell. Shell command-line expansion. Customizing the functioning of the shell. Employing advanced user features. Specifying Instructions to the Shell Chapter

More information

ACS Unix (Winter Term, ) Page 21

ACS Unix (Winter Term, ) Page 21 ACS-294-001 Unix (Winter Term, 2016-2017) Page 21 The Shell From the beginning, Unix was designed so that the shell is an actual program separated from the main part of the operating system. What is a

More information

Chapter 9. Shell and Kernel

Chapter 9. Shell and Kernel Chapter 9 Linux Shell 1 Shell and Kernel Shell and desktop enviroment provide user interface 2 1 Shell Shell is a Unix term for the interactive user interface with an operating system A shell usually implies

More information

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.

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. SHELLS: The shell is the part of the UNIX that is most visible to the user. It receives and interprets the commands entered by the user. In many respects, this makes it the most important component of

More information

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.

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. 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. The shell is your interface to the operating system. It acts

More information

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

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute Shells The UNIX Shells How shell works Fetch command Analyze Execute Unix shells Shell Originator System Name Prompt Bourne Shell S. R. Bourne /bin/sh $ Csh Bill Joy /bin/csh % Tcsh Ken Greer /bin/tcsh

More information

The Online Unix Manual

The Online Unix Manual ACS-294-001 Unix (Winter Term, 2018-2019) Page 14 The Online Unix Manual Unix comes with a large, built-in manual that is accessible at any time from your terminal. The Online Manual is a collection of

More information

System Programming. Introduction to Unix

System Programming. Introduction to Unix Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 3 Introduction

More information

Assignment clarifications

Assignment clarifications Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W PROGRAM CONTROL, FILE ARCHIVING, ENVIRONMENT AND SCRIPTS S E C T I O N O V E R V I E W Continuing from last section, we are going to learn about the following concepts: controlling programs; working with

More information

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

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell: Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed performs the actions Example:

More information

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

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University Lecture 8 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control 22-Sep-2017 Location: Goldberg CS 127 Time: 14:35 15:25 Instructor:

More information

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

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing Content 3 Operating Systems The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail. How to log into (and out

More information

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems. Copyleft 2005, Binnur Kurt 3 Operating Systems Copyleft 2005, Binnur Kurt Content The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail.

More information

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

Unix Shell Environments. February 23rd, 2004 Class Meeting 6 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

More information

Unix Shells and Other Basic Concepts

Unix Shells and Other Basic Concepts CSCI 2132: Software Development Unix Shells and Other Basic Concepts Norbert Zeh Faculty of Computer Science Dalhousie University Winter 2019 Shells Shell = program used by the user to interact with the

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

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

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands)

More information

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

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 Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information

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

Lecture 8. Introduction to Shell Programming. COP 3353 Introduction to UNIX Lecture 8 Introduction to Shell Programming COP 3353 Introduction to UNIX 1 What is a shell script? An executable file containing Unix shell commands Programming control constructs (if, then, while, until,

More information

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview

More information

EECS2301. Lab 1 Winter 2016

EECS2301. Lab 1 Winter 2016 EECS2301 Lab 1 Winter 2016 Lab Objectives In this lab, you will be introduced to the Linux operating system. The basic commands will be presented in this lab. By the end of you alb, you will be asked to

More information

Operating Systems, Unix Files and Commands SEEM

Operating Systems, Unix Files and Commands SEEM Operating Systems, Unix Files and Commands SEEM 3460 1 Major Components of Operating Systems (OS) Process management Resource management CPU Memory Device File system Bootstrapping SEEM 3460 2 Programs

More information

Vi & Shell Scripting

Vi & Shell Scripting Vi & Shell Scripting Comp-206 : Introduction to Week 3 Joseph Vybihal Computer Science McGill University Announcements Sina Meraji's office hours Trottier 3rd floor open area Tuesday 1:30 2:30 PM Thursday

More information

Implementation of a simple shell, xssh

Implementation of a simple shell, xssh Implementation of a simple shell, xssh What is a shell? A process that does command line interpretation Reads a command from standard input (stdin) Executes command corresponding to input line In simple

More information

CHAPTER 2 THE UNIX SHELLS

CHAPTER 2 THE UNIX SHELLS CHAPTER 2 THE UNIX SHELLS The layers in a UNIX system is shown in the following figure. system call interface library interface user interface Users Standard utility programs (shell, editors, compilers,

More information

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

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples EECS2301 Title Unix/Linux Introduction These slides are based on slides by Prof. Wolfgang Stuerzlinger at York University Warning: These notes are not complete, it is a Skelton that will be modified/add-to

More information

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book).

Crash Course in Unix. For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix. -or- Unix in a Nutshell (an O Reilly book). Crash Course in Unix For more info check out the Unix man pages -orhttp://www.cs.rpi.edu/~hollingd/unix -or- Unix in a Nutshell (an O Reilly book). 1 Unix Accounts To access a Unix system you need to have

More information

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

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science CSCI 211 UNIX Lab Shell Programming Dr. Jiang Li Why Shell Scripting Saves a lot of typing A shell script can run many commands at once A shell script can repeatedly run commands Help avoid mistakes Once

More information

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

Bashed One Too Many Times. Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 Bashed One Too Many Times Features of the Bash Shell St. Louis Unix Users Group Jeff Muse, Jan 14, 2009 What is a Shell? The shell interprets commands and executes them It provides you with an environment

More information

Work Effectively on the Command Line

Work Effectively on the Command Line Information These notes were originally written in the year 2000 as part of a set of LPI Exam 101 training materials. The LPI training course at Bromley College was subsequently discontinued and some of

More information

Introduction to Linux

Introduction to Linux Introduction to Linux January 2011 Don Bahls User Consultant (Group Leader) bahls@arsc.edu (907) 450-8674 Overview The shell Common Commands File System Organization Permissions Environment Variables I/O

More information

85321, Systems Administration Chapter 6: The shell

85321, Systems Administration Chapter 6: The shell Chapter 6 Introduction The Shell You will hear many people complain that the UNIX operating system is hard to use. They are wrong. What they actually mean to say is that the UNIX command line interface

More information

UNIX shell scripting

UNIX shell scripting UNIX shell scripting EECS 2031 Summer 2014 Przemyslaw Pawluk June 17, 2014 What we will discuss today Introduction Control Structures User Input Homework Table of Contents Introduction Control Structures

More information

CST Algonquin College 2

CST Algonquin College 2 The Shell Kernel (briefly) Shell What happens when you hit [ENTER]? Output redirection and pipes Noclobber (not a typo) Shell prompts Aliases Filespecs History Displaying file contents CST8207 - Algonquin

More information

System Programming. Session 6 Shell Scripting

System Programming. Session 6 Shell Scripting System Programming Session 6 Shell Scripting Programming C Programming vs Shell Programming C vs Shell Programming Compilation/Direct execution C Requires compilation while shell script can be directly

More information

Introduction to UNIX Part II

Introduction to UNIX Part II T H E U N I V E R S I T Y of T E X A S H E A L T H S C I E N C E C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S Introduction to UNIX Part II For students

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming 1 Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University Unix/Linux Basics 1 Some basics to remember Everything is case sensitive Eg., you can have two different files of the same name but different case in the same folder Console-driven (same as terminal )

More information

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

More Raspian. An editor Configuration files Shell scripts Shell variables System admin More Raspian An editor Configuration files Shell scripts Shell variables System admin Nano, a simple editor Nano does not require the mouse. You must use your keyboard to move around the file and make

More information

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

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc. Appendix A GLOSSARY SYS-ED/ Computer Education Techniques, Inc. $# Number of arguments passed to a script. $@ Holds the arguments; unlike $* it has the capability for separating the arguments. $* Holds

More information

Introduction to UNIX Shell Exercises

Introduction to UNIX Shell Exercises Introduction to UNIX Shell Exercises Determining Your Shell Open a new window or use an existing window for this exercise. Observe your shell prompt - is it a $ or %? What does this tell you? Find out

More information

Computational Physics Operating systems

Computational Physics Operating systems Computational Physics numerical methods with C++ (and UNIX) 2018-19 Fernando Barao Instituto Superior Tecnico, Dep. Fisica email: fernando.barao@tecnico.ulisboa.pt Computational Physics 2018-19 (Phys Dep

More information

Shells and Shell Programming

Shells and Shell Programming Shells and Shell Programming Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed

More information

Introduction to the Shell

Introduction to the Shell [Software Development] Introduction to the Shell Davide Balzarotti Eurecom Sophia Antipolis, France What a Linux Desktop Installation looks like What you need Few Words about the Graphic Interface Unlike

More information

Linux & Shell Programming 2014

Linux & Shell Programming 2014 Unit -1: Introduction to UNIX/LINUX Operating System Practical Practice Questions: Find errors (if any) otherwise write output or interpretation of following commands. (Consider default shell is bash shell.)

More information

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze EECS 2031 Software Tools Prof. Mokhtar Aboelaze Footer Text 1 EECS 2031E Instructor: Mokhtar Aboelaze Room 2026 CSEB lastname@cse.yorku.ca x40607 Office hours TTH 12:00-3:00 or by appointment 1 Grading

More information

More on Unix Shell SEEM

More on Unix Shell SEEM More on Unix Shell SEEM 3460 1 Shell Operations When a shell is invoked automatically during a login (or manually from a keyboard or script), it follows a preset sequence: 1. It reads a special start-up

More information

Week 5 Lesson 5 02/28/18

Week 5 Lesson 5 02/28/18 Week 5 Lesson 5 02/28/18 Important Announcements Extra Credits If you haven t done so, send your pictures to risimms@cabrillo.edu for 3 points EXTRA CREDIT. Join LinkedIn for 3 points Perkins/VTEA Survey

More information

5/8/2012. Exploring Utilities Chapter 5

5/8/2012. Exploring Utilities Chapter 5 Exploring Utilities Chapter 5 Examining the contents of files. Working with the cut and paste feature. Formatting output with the column utility. Searching for lines containing a target string with grep.

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Mukesh Pund Principal Scientist, NISCAIR, New Delhi, India History In 1969, a team of developers developed a new operating system called Unix which was written using C Linus Torvalds,

More information

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

CS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010 Lecture 3 Making Bash Work For You Fall 2010 Hussam Abu-Libdeh based on slides by David Slater September 13, 2010 A little homework Homework 1 out now Due on Thursday at 11:59PM Moving around and GNU file

More information

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

Essential Unix (and Linux) for the Oracle DBA. Revision no.: PPT/2K403/02 Essential Unix (and Linux) for the Oracle DBA Revision no.: PPT/2K403/02 Architecture of UNIX Systems 2 UNIX System Structure 3 Operating system interacts directly with Hardware Provides common services

More information

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

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts CSCI 2132 Software Development Lecture 3: Unix Shells and Other Basic Concepts Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 10-Sep-2018 (3) CSCI 2132 1 Introduction to UNIX

More information

PROGRAMMAZIONE I A.A. 2015/2016

PROGRAMMAZIONE I A.A. 2015/2016 PROGRAMMAZIONE I A.A. 2015/2016 SHELL SHELL SHELL A program that interprets commands Allows a user to execute commands by typing them manually at a terminal, or automatically in programs called shell scripts.

More information

Environment Variables

Environment Variables Environment Variables 1 A shell is simply a program that supplies certain services to users. As such, a shell may take parameters whose values modify or define certain behaviors. These parameters (or shell

More information

Implementation of a simple shell, xssh

Implementation of a simple shell, xssh Implementation of a simple shell, xssh What is a shell? A process that does command line interpretation Reads a command from standard input (stdin) Executes command corresponding to input line In the simple

More information

Introduction. Let s start with the first set of slides

Introduction. Let s start with the first set of slides Tux Wars Class - 1 Table of Contents 1) Introduction to Linux and its history 2) Booting process of a linux system 3) Linux Kernel 4) What is a shell 5) Bash Shell 6) Anatomy of command 7) Let s make our

More information

Chapter-3. Introduction to Unix: Fundamental Commands

Chapter-3. Introduction to Unix: Fundamental Commands Chapter-3 Introduction to Unix: Fundamental Commands What You Will Learn The fundamental commands of the Unix operating system. Everything told for Unix here is applicable to the Linux operating system

More information

CSE II-Sem)

CSE II-Sem) 1 2 a) Login to the system b) Use the appropriate command to determine your login shell c) Use the /etc/passwd file to verify the result of step b. d) Use the who command and redirect the result to a file

More information

Last Time. on the website

Last Time. on the website Last Time on the website Lecture 6 Shell Scripting What is a shell? The user interface to the operating system Functionality: Execute other programs Manage files Manage processes Full programming language

More information

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

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved AICT High Performance Computing Workshop With Applications to HPC Edmund Sumbar research.support@ualberta.ca Copyright 2007 University of Alberta. All rights reserved High performance computing environment

More information

COMP 4/6262: Programming UNIX

COMP 4/6262: Programming UNIX COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test

More information

Practical Session 0 Introduction to Linux

Practical Session 0 Introduction to Linux School of Computer Science and Software Engineering Clayton Campus, Monash University CSE2303 and CSE2304 Semester I, 2001 Practical Session 0 Introduction to Linux Novell accounts. Every Monash student

More information

Linux Command Line Interface. December 27, 2017

Linux Command Line Interface. December 27, 2017 Linux Command Line Interface December 27, 2017 Foreword It is supposed to be a refresher (?!) If you are familiar with UNIX/Linux/MacOS X CLI, this is going to be boring... I will not talk about editors

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND Prof. Michael J. Reale Fall 2014 Finding Files in a Directory Tree Suppose you want to find a file with a certain filename (or with a filename matching

More information

Environment Variables

Environment Variables Environment Variables 1 A shell is simply a program that supplies certain services to users. As such, a shell may take parameters whose values modify or define certain behaviors. These parameters (or shell

More information

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 1

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 1 CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 1 Prof. Michael J. Reale Fall 2014 EXAM 1 OVERVIEW Exam 1 Material Exam 1 will cover the following: REVIEW slides from (1) to (9) (INCLUSIVE) Quizzes

More information

UNIX Kernel. UNIX History

UNIX Kernel. UNIX History UNIX History UNIX Kernel 1965-1969 Bell Labs participates in the Multics project. 1969 Ken Thomson develops the first UNIX version in assembly for an DEC PDP-7 1973 Dennis Ritchie helps to rewrite UNIX

More information

Bash Programming. Student Workbook

Bash Programming. Student Workbook Student Workbook Bash Programming Published by ITCourseware, LLC, 7245 South Havana Street, Suite 100, Englewood, CO 80112 Contributing Authors: Julie Johnson, Rob Roselius Editor: Jeff Howell Special

More information

Introduction to Shell Scripting

Introduction to Shell Scripting Introduction to Shell Scripting Evan Bollig and Geoffrey Womeldorff Presenter Yusong Liu Before we begin... Everyone please visit this page for example scripts and grab a crib sheet from the front http://www.scs.fsu.edu/~bollig/techseries

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA - Kisik Jeong (kisik@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating

More information

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi Bash Scripting Alessandro Barenghi Dipartimento di Elettronica, Informazione e Bioingegneria Politecnico di Milano alessandro.barenghi - at - polimi.it April 28, 2015 Introduction The bash command shell

More information

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

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29 UNIX The Very 10 Short Howto for beginners Soon-Hyung Yook March 27, 2015 Soon-Hyung Yook UNIX March 27, 2015 1 / 29 Table of Contents 1 History of Unix 2 What is UNIX? 3 What is Linux? 4 How does Unix

More information

UNIX Shell Programming

UNIX Shell Programming $!... 5:13 $$ and $!... 5:13.profile File... 7:4 /etc/bashrc... 10:13 /etc/profile... 10:12 /etc/profile File... 7:5 ~/.bash_login... 10:15 ~/.bash_logout... 10:18 ~/.bash_profile... 10:14 ~/.bashrc...

More information

UNIX System Programming Lecture 3: BASH Programming

UNIX System Programming Lecture 3: BASH Programming UNIX System Programming Outline Filesystems Redirection Shell Programming Reference BLP: Chapter 2 BFAQ: Bash FAQ BMAN: Bash man page BPRI: Bash Programming Introduction BABS: Advanced Bash Scripting Guide

More information

C Shell Tutorial. Section 1

C Shell Tutorial. Section 1 C Shell Tutorial Goals: Section 1 Learn how to write a simple shell script and how to run it. Learn how to use local and global variables. About CSH The Barkley Unix C shell was originally written with

More information

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

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University Lecture 4 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation 27-Sep-2017 Location: Goldberg CS Building Time: Wednesday, 16:05

More information

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2) BANK ON & SHELL PROGRAMMING-502 (CORE PAPER-2) TOPIC 1: VI-EDITOR MARKS YEAR 1. Explain set command of vi editor 2 2011oct 2. Explain the modes of vi editor. 7 2013mar/ 2013 oct 3. Explain vi editor 5

More information

COMS 6100 Class Notes 3

COMS 6100 Class Notes 3 COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II

More information

Lecture #10 - Interactive Korn Shell (Chapter 11)

Lecture #10 - Interactive Korn Shell (Chapter 11) CS390 UNIX Programming Spring 2009 Page 1 Lecture #10 - Interactive Korn Shell (Chapter 11) Background Usually ksh Programming interface is a superset of Bourne shell Adopted many of the features from

More information

UNIX 2 OPERATING SYSTEM

UNIX 2 OPERATING SYSTEM UNIX 2 OPERATING SYSTEM hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: Process management in Solaris. omponents of the operating system. Flow of control within the operating

More information

The Unix Shell & Shell Scripts

The Unix Shell & Shell Scripts The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises

More information

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

Shell scripting and system variables. HORT Lecture 5 Instructor: Kranthi Varala Shell scripting and system variables HORT 59000 Lecture 5 Instructor: Kranthi Varala Text editors Programs built to assist creation and manipulation of text files, typically scripts. nano : easy-to-learn,

More information

SOFTWARE ARCHITECTURE 3. SHELL

SOFTWARE ARCHITECTURE 3. SHELL 1 SOFTWARE ARCHITECTURE 3. SHELL Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/login.php 2 Software Layer Application Shell Library MIddleware Shell Operating System Hardware

More information

15-122: Principles of Imperative Computation

15-122: Principles of Imperative Computation 15-122: Principles of Imperative Computation Lab 0 Navigating your account in Linux Tom Cortina, Rob Simmons Unlike typical graphical interfaces for operating systems, here you are entering commands directly

More information

CSC UNIX System, Spring 2015

CSC UNIX System, Spring 2015 CSC 352 - UNIX System, Spring 2015 Study guide for the CSC352 midterm exam (20% of grade). Dr. Dale E. Parson, http://faculty.kutztown.edu/parson We will have a midterm on March 19 on material we have

More information

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

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi Lezione 8 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Sommario Shell command language Introduction A

More information

CHAPTER 3 SHELL PROGRAMS: SCRIPTS

CHAPTER 3 SHELL PROGRAMS: SCRIPTS CHAPTER 3 SHELL PROGRAMS: SCRIPTS Any series of commands may be stored inside a regular text file for later execution. A file that contains shell commands is called a script. Before you can run a script,

More information

Introduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018

Introduction to Linux Part 2b: basic scripting. Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018 Introduction to Linux Part 2b: basic scripting Brett Milash and Wim Cardoen CHPC User Services 18 January, 2018 Overview Scripting in Linux What is a script? Why scripting? Scripting languages + syntax

More information

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University Introduction to Linux Woo-Yeong Jeong (wooyeong@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating system of a computer What is an

More information

Overview of the UNIX File System

Overview of the UNIX File System Overview of the UNIX File System Navigating and Viewing Directories Adapted from Practical Unix and Programming Hunter College Copyright 2006 Stewart Weiss The UNIX file system The most distinguishing

More information

RH033 Red Hat Linux Essentials

RH033 Red Hat Linux Essentials RH033 Red Hat Linux Essentials Version 3.5 QUESTION NO: 1 You work as a Network Administrator for McNeil Inc. The company has a Linux-based network. A printer is configured on the network. You want to

More information

Linux shell programming for Raspberry Pi Users - 2

Linux shell programming for Raspberry Pi Users - 2 Linux shell programming for Raspberry Pi Users - 2 Sarwan Singh Assistant Director(S) NIELIT Chandigarh 1 SarwanSingh.com Education is the kindling of a flame, not the filling of a vessel. - Socrates SHELL

More information

Topic 2: More Shell Skills

Topic 2: More Shell Skills Topic 2: More Shell Skills Sub-topics: 1 quoting 2 shell variables 3 sub-shells 4 simple shell scripts (no ifs or loops yet) 5 bash initialization files 6 I/O redirection & pipes 7 aliases 8 text file

More information

Scripting Languages Course 1. Diana Trandabăț

Scripting Languages Course 1. Diana Trandabăț Scripting Languages Course 1 Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture Introduction to scripting languages What is a script? What is a scripting language

More information

Advanced Unix Programming Module 03 Raju Alluri spurthi.com

Advanced Unix Programming Module 03 Raju Alluri spurthi.com Advanced Unix Programming Module 03 Raju Alluri askraju @ spurthi.com Advanced Unix Programming: Module 3 Shells & Shell Programming Environment Variables Writing Simple Shell Programs (shell scripts)

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Prof. Jin-Soo Kim( jinsookim@skku.edu) TA - Dong-Yun Lee (dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu What is Linux? A Unix-like operating

More information