Distributed Networks Distributed Networks





Unix Shell Programming   «Prev  Next»
Lesson 1

Introduction to Unix Processes and Shells

This module covers basic information about how shell scripts are executed on a UNIX system. Subsequent modules in this course will focus on the programming aspects of the shell. Before we begin those modules, we will look at the difference between using the shell as an interactive command interpreter and using it as a programming language. We will also examine techniques available for running a shell script and go over what processes are started when you run the shell using the various techniques.

Learning objectives
In this module, the following will be discussed:
  1. Determine your login shell
  2. Run a shell interactively
  3. Run a shell through a script
  4. Describe the relationship between parent and child processes
  5. Run a shell script using three different techniques


Processes and Process ID

An executing instance of a program is called a process.
Some operating systems use the term task to refer to a program that is being executed. The UNIX System guarantees that every process has a unique numeric identifier called the process ID. The process ID is always a non-negative integer.
The program in the figure below prints its process ID.
#include "apue.h"
int
main(void){
 printf("hello world from process ID %ld\n", (long)getpid());
 exit(0);
}