You are on page 1of 15

Unix Shell Programming

Unit I:
Introduction to Unix:- Architecture of Unix, Features of Unix , Unix Commands PATH, man, echo, printf, script, passwd, uname,
who, date, stty, pwd, cd, mkdir, rmdir, ls, cp, mv, rm, cat, more, wc, lp, od, tar, gzip.
Unit II :
Unix Utilities:- Introduction to unix file system, vi editor, file handling utilities, security by file permissions, process utilities, disk
utilities, networking commands, unlink, du, df, mount, umount, find, unmask, ulimit, ps, w, finger, arp, ftp, telnet, rlogin.Text
processing utilities and backup utilities , detailed commands to be covered are tail, head , sort, nl, uniq, grep, egrep, fgrep, cut,
paste, join, tee, pg, comm, cmp, diff, tr, awk, cpio
Unit III :
Introduction to Shells :
Unix Session, Standard Streams, Redirection, Pipes, Tee Command, Command Execution, Command-Line Editing, Quotes, Command
Substitution, Job Control, Aliases, Variables, Predefined Variables, Options, Shell/Environment Customization.
Filters :
Filters and Pipes, Concatenating files, Display Beginning and End of files, Cut and Paste, Sorting, Translating Characters, Files with
Duplicate Lines, Count characters, Words or Lines, Comparing Files.
Unit IV :
Grep :
Operation, grep Family, Searching for File Content.
Sed :
Scripts, Operation, Addresses, commands, Applications, grep and sed.
Unit V :
awk:
Execution, Fields and Records, Scripts, Operations, Patterns, Actions, Associative Arrays, String Functions, String Functions,
Mathematical Functions, User Defined Functions, Using System commands in awk, Applications, awk and grep, sed and awk.

Unit VI :
Interactive Korn Shell :
Korn Shell Features, Two Special Files, Variables, Output, Input, Exit Status of a Command, eval Command, Environmental Variables,
Options, Startup Scripts, Command History, Command Execution Process.
Korn Shell Programming :
Basic Script concepts, Expressions, Decisions: Making Selections, Repetition, special Parameters and Variables, changing Positional
Parameters, Argument Validation, Debugging Scripts, Script Examples.
Unit VII :
Interactive C Shell :
C shell features, Two Special Files, Variables, Output, Input, Exit Status of a Command, eval Command, Environmental Variables, OnOff Variables, Startup and Shutdown Scripts, Command History, Command Execution Scripts.
C Shell Programming :
Basic Script concepts, Expressions, Decisions: Making Selections, Repetition, special Parameters and Variables, changing Positional
Parameters, Argument Validation, Debugging Scripts, Script Examples.
Unit VIII :
File Management :
File Structures, System Calls for File Management create, open, close, read, write, lseek, link, symlink, unlink, stat, fstat, lstat,
chmod, chown, Directory API opendir, readdir, closedir, mkdir, rmdir, umask.
TEXT BOOKS :
1. Unix and shell Programming Behrouz A. Forouzan, Richard F. Gilberg.Thomson
2. Your Unix the ultimate guide, Sumitabha Das, TMH. 2nd Edition.
REFERENCES :
1. Unix for programmers and users, 3rd edition, Graham Glass, King Ables, Pearson Education.
2. Unix programming environment, Kernighan and Pike, PHI. / Pearson Education
3. The Complete Reference Unix, Rosen, Host, Klee, Farber, Rosinski, Second Edition, TMH.

Lecture 1: What is Unix/Linux?

Basic overview and history of unix/linux

Command line basics

Commands: ssh, ls, pwd, cd, cp, rm, mv

Lecture 2: Using the Command Line

Accessing remote servers and files

Editing and manipulating files

Piping commands and saving output

Searching in command line history

Commands: mkdir, nano, cat, head, tail, less, clear, grep, sort, uniq, man, >, |, ssh-keygen

Lecture 3: Operating System Organization

OS basics, processes

Filesystem layout

File permissions

Commands: chmod, find, locate

Lecture 4: Your Own Copy of Linux

Overview of popular Linux distributions

Running Linux in a virtual machine

Super user powers

Installing applications

Commands: make, apt-get

Lecture 5: Programming in Linux

Simple Bash shell scripting

Compiling C/C++ files

File processing: awk, sed

Commands: gcc, sh

Lecture 6: Programming & Scripting

Scripting

Lecture 7: Configuring the System

Basic system administration

Setting environment variables

Listing users and processes

Basics of mount and NFS

Commands: uname, users, finger, alias, ps, top, kill, mount, df, du

Lecture 8: Subversion Control and Advanced Topics

Source control with SVN

More powerful editors: emacs, vim

More commands: svn, tar, screen, nohup, disown, nice, cron, whereis, which, diff, scp, rsync

Lecture 9: UNIX Networking Basics

Network Configuration

Network background knowledge

Basic Networking debugging

Lecture 10: Security Issues and Traffic Monitoring

IP Addressing

Address Resolution Protocol

Packet Sniffing

Unsecure vs Secure Network Connections

Lecture 11: Network Connections and WWW

HTML

CSS

Course Objectives:
This course will enable students to:

Understand the UNIX Architecture, File systems and use of basic Commands.

Use of editors and Networking commands.

Understand Shell Programming and to write shell scripts.

Understand and analyze UNIX System calls, Process Creation, Control & Relationship.

Modules
Module -1

Teachin
g Hour

Text book

Introduction, Brief history. Unix Components/Architecture. Features of Unix. The UNIX Environment
and UNIX Structure, Posix and Single Unix specification. The login prompt. General features of Unix
commands/ command structure. Command arguments and options. Understanding of some basic
commands such as echo, printf, ls, who, date, passwd, cal, Combining commands. Meaning of
Internal and external commands. The type command: knowing the type of a command and locating
it. The man command knowing more about Unix commands and using Unix online manual pages. The
man with keyword option and whatis. The more command and using it with other commands.
Knowing the user terminal, displaying its characteristics and setting characteristics. Managing the
nonuniform behaviour of terminals and keyboards. The root login. Becoming the super user: su
command. The /etc/passwd and /etc/shadow files. Commands to add, modify and delete users.

10 Hours

Module -2

Unix files. Naming files. Basic file types/categories. Organization of files. Hidden files. Standard
10 Hours
directories. Parent child relationship. The home directory and the HOME variable. Reaching required
files- the PATH variable, manipulating the PATH, Relative and absolute pathnames. Directory
commands pwd, cd, mkdir, rmdir commands. The dot (.) and double dots (..) notations to represent

Topics from
chapter 2 , 3
and 15 of text
book 1,chapter
1 from text
book 2

Topics from
chapters 4, 5
and 6 of text
book 1

present and parent directories and their usage in relative path names. File related commands cat,
mv, rm, cp, wc and od commands. File attributes and permissions and knowing them. The ls
command with options. Changing file permissions: the relative and absolute permissions changing
methods. Recursively changing file permissions. Directory permissions.

Module -3

The vi editor. Basics. The .exrc file. Different ways of invoking and quitting vi. Different modes of vi.
Input mode commands. Command mode commands. The ex mode commands. Illustrative examples
Navigation commands. Repeat command. Pattern searching. The search and replace command. The
set, map and abbr commands. Simple examples using these commands. The shells interpretive cycle.
Wild cards and file name generation. Removing the special meanings of wild cards. Three standard
files and redirection. Connecting commands: Pipe. Splitting the output: tee. Command substitution.
Basic and Extended regular expressions. The grep, egrep. Typical examples involving different regular
expressions.

10 Hours

Module -4

Shell programming. Ordinary and environment variables. The .profile. Read and readonly commands.
Command line arguments. exit and exit status of a command. Logical operators for conditional
execution. The test command and its shortcut. The if, while, for and case control statements. The set
and shift commands and handling positional parameters. The here ( << ) document and trap
command. Simple shell program examples. File inodes and the inode structure. File links hard and
soft links. Filters. Head and tail commands. Cut and paste commands. The sort command and its
usage with different options. The umask and default file permissions. Two special files /dev/null
and /dev/tty.

10 Hours

Module -5

Topics from
chapters 7, 8
and 13 of text
book
1. Topics from
chapter 2 and
9 ,10 of text
book 2

Textbook 1:
Ch 2: 2.1, Ch
6: 6.1 to 6.7

Meaning of a process. Mechanism of process creation. Parent and child process. The ps command with
its options. Executing a command at a specified point of time: at command. Executing a command
periodically: cron command and the crontab file.. Signals. The nice and nohup commands.
Background processes. The bg and fg command. The kill command. The find command with
illustrative example. Structure of a perl script. Running a perl script. Variables and operators. String
handling functions. Default variables $_ and $. representing the current line and current line
10 Hours
number. The range operator. Chop() and chomp() functions. Lists and arrays. The @- variable. The
splice operator, push(), pop(), split() and join(). File handles and handling file using open(), close()
and die () functions.. Associative arrays keys and value functions. Overview of decision making loop
control structures the foreach. Regular expressions simple and multiple search patterns. The
match and substitute operators. Defining and using subroutines.
Course outcomes: After studying this course, students will be able to:

Explain multi user OS UNIX and its basic features

Interpret UNIX Commands, Shell basics, and shell environments

Design and develop shell programming, communication, System calls and terminology.

Design and develop UNIX File I/O and UNIX Processes.

Perl script writing

Graduate Attributes (as per NBA)

Engineering Knowledge

Environment and Sustainability

Design/Development of Solutions

Question paper pattern:

The question paper will have ten questions.

There will be 2 questions from each module.

Topics from
chapter 9 and
19 of text
book
1. Topics from
chapter 11 of
reference book
1

Each question will have questions covering all the topics under a module.

The students will have to answer 5 full questions, selecting one full question from each module.

Text Books:

Sumitabha Das., Unix Concepts and Applications., 4th Edition., Tata McGraw Hill

Behrouz A. Forouzan, Richard F. Gilberg : UNIX and Shell Programming- Cengage Learning India Edition.
2009.

Reference Books:

M.G. Venkatesh Murthy: UNIX & Shell Programming, Pearson Education.

Richard Blum , Christine Bresnahan : Linux Command Line and Shell Scripting Bible, 2ndEdition ,
Wiley,2014.

Basic Shell Scripting

1.

2.

3.

4.

Shell Basics
1.

Types of shells

2.

Shell functionality

3.

Environment

Writing first script


1.

Writing script & executing basic script

2.

Debugging script

3.

Making interactive scripts

4.

Variables (default variables)

5.

Mathematical expressions

Conditional statements
1.

If-else-elif

2.

Test command

3.

Logical operators-AND,OR,NOT

4.

ase esac

Loops

5.

6.

7.

1.

While

2.

For

3.

Until

4.

Break & continue

Command line arguments


1.

Positional parameters

2.

Set & shift

3.

IFS

4.

Break & continue

Functions & file manipulations


1.

Processing file line by line

2.

Functions

Regular Expression & Filters


1.

What is regular expression

2.

Grep,cut ,sort commands

3.

Grep patterns

8.

SED & AWK

9.

Processes
1.

Concept of process in Unix

2.

Background processes

3.

Scheduling processes -At, batch & Cron

10. Misc
1.

Trapping signals

2.

String substitutions / manipulations

At the end of the course Student will be able to


1.

Work on any Unix platform with confidence

2.

Write effective scripts for their day to day jobs

3.

Understand and use most of the Unix features and commands

4.

Will be able to do Basic System administration

5.

Getting accquainted with Linux

6.

1.

Logging in-out

2.

Brief History

3.

Unix Flavours

4.

Linux distros

Linux/Unix Architecture
1.

Concept of Multiuser-multitasking

2.

Architectural view

7.

3.

Unix command structure

4.

Getting help

5.

Combining the commands

Using Linux/Unix
1.

8.

Frequently used commands and utilities


1.

Ls , cat ,cd ,mkdir ,rmdir,touch ,grep etc

2.

User commands who ,who am i etc

2.

IO redirection and piping ( stdin ,stdout,stderr, tee)

3.

Concept of Users and groups


1.

User access privileges

2.

Superuser and permissions

3.

Password files

Filesystem
1.

Filesytem concept

2.

Unix s File/dir hierarchy

3.

Filesystem types

4.

Creating and mounting filesystem

5.

Filesystem related command

6.

Configuration files

9.

Handling Files & directories


1.

Creation, deletion

2.

Permissions

3.

Compressing/decompressing files

10. Networking Utilities


1.

Ping ,ifconfig,ssh,scp etc

2.

Starting and stopping networking services

3.

Network configuration files

11. Application Installation on Unix


1.

Package formats and installation

12. Booting Linux


1.

Boot order

2.

Run levels and rc scripts

3.

Configuration files for booting

13. Installation
1.

Installation & configuration of Linux

2.

Getting updates

You might also like