Don’t watch the clock; do what it does. Keep going.
--Your friends at LectureNotes

Unix & Shell Programming

by Vtu Rangers
Type: NoteInstitute: VTU Downloads: 138Views: 4202Uploaded: 7 months agoAdd to Favourite

Share it with your friends

Suggested Materials

Leave your Comments


Unix and Shell Programming 15CS35 SYLLABUS UNIX SHELL PROGRAMMING [As per Choice Based Credit System (CBCS) scheme] (Effective from the academic year 2015 -2016) SEMESTER - III Subject Code 15CS35 Number of Lecture Hours/Week 03 Total Number of Lecture Hours 50 IA Marks 20 Exam Marks 80 Exam Hours 03 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. Module -1 Teaching Hours: 10 Hours 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. Module -2 Teaching Hours: 10 Hours Unix files. Naming files. Basic file types/categories. Organization of files. Hidden files. Standard 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 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 Teaching Hours: 10 Hours 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 Dept of CSE,SJBIT Page 1
Unix and Shell Programming 15CS35 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. Module – 4 Teaching Hours: 10 Hours 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. Module-5 Teaching Hours: 10 Hours 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 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. Understand UNIX process control, relationships, commands and utilities Text Books: 1. Behrouz A. Forouzan, Richard F. Gilberg : UNIX and Shell Programming- Cengage Learning – India Edition. (Chapters- 1,2, 3, 4, 5, 7,8, 13, 14) 2009. 2. Sumitabha Das: UNIX – Concepts and Applications,4th Edition, Tata McGraw Hill. Reference Books: 1. Richard Blum , Christine Bresnahan : Linux Command Line and Shell Scripting Bible, 2ndEdition , Wiley,2014 2. M.G. Venkateshmurthy: UNIX & Shell Programming, Pearson Education. 3. W. Richard Stevens, Stephen A Rago: Advanced Programming in the UNIX Environment, 2nd Edition, Pearson Education.(Chapters 3,7.1 to 7.9, 8, 9.1 to 9.8) .2009 Dept of CSE,SJBIT Page 2
Unix and Shell Programming 15CS35 MODULE-1 Introduction 1.1 Why UNIX? , Computer System, 1.2 The UNIX Environment, UNIX Structure, 1.3 Accessing Unix, Commands, Common Commands, 1.4 Other Useful Commands. 1.5 File Systems- Filenames, 1.6 File types, Regular Files, Directories, 1.7 File System Implementation, 1.8 Operations Unique to Directories, 1.9 Operations Unique to Regular Files, 1.10 Operations Common to Both. 1.11Security and File Permission – Users and Groups, 1.12Security Levels, Changing permissions, 1.13User masks, Changing Ownership and group. Dept of CSE,SJBIT Page 3
Unix and Shell Programming 15CS35 1.1. The UNIX Operating System Introduction This chapter introduces you to the UNIX operating system. We first look at what is an operating system and then proceed to discuss the different features of UNIX that have made it a popular operating system. Objectives • • • What is an operating system (OS)? Features of UNIX OS A Brief History of UNIX OS, POSIX and Single Unix Specification (SUS) What is an operating system (OS)? An operating system (OS) is a resource manager. It takes the form of a set of software routines that allow users and application programs to access system resources (e.g. the CPU, memory, disks, modems, printers, network cards etc.) in a safe, efficient and abstract way. For example, an OS ensures safe access to a printer by allowing only one application program to send data directly to the printer at any one time. An OS encourages efficient use of the CPU by suspending programs that are waiting for I/O operations to complete to make way for programs that can use the CPU more productively. An OS also provides convenient abstractions (such as files rather than disk locations) which isolate application programmers and users from the details of the underlying hardware. User Applications Application Programs System Utilities System Call Interface Operating System Kernel Processor/Hardware UNIX Operating system allows complex tasks to be performed with a few keystrokes. It Dept of CSE,SJBIT Page 4

Lecture Notes