AC109/AT109 UNIX & SHELL PROGRAMMING DEC 2014

Similar documents
Basic File Attributes

Introduction to the UNIX command line

5/8/2012. Creating and Changing Directories Chapter 7

Basic File Attributes

Operating Systems, Unix Files and Commands SEEM

5/20/2007. Touring Essential Programs

PESIT Bangalore South Campus

Unix Introduction to UNIX

Files and Directories

commandname flags arguments

Permission and Ownership

Introduction to Linux

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

Introduction to Unix CHAPTER 6. File Systems. Permissions

12/7/10 ATSC 212 UNIX ATSC 212 ATSC 212 UNIX

Mills HPC Tutorial Series. Linux Basics I

File Commands. Objectives

Introduction to Unix: Fundamental Commands

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

12.1 UNDERSTANDING UNIX SHELL PROGRAMMING LANGUAGE: AN INTRODUCTION Writing a Simple Script Executing a Script

Welcome to Linux. Lecture 1.1

Unix basics exercise MBV-INFX410

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

5/8/2012. Encryption-based Protection. Protection based on Access Permission (Contd) File Security, Setting and Using Permissions Chapter 9

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

FILESYSTEMS. Mmmm crunchy

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

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Introduction: What is Unix?

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

UNIX Shell Programming

Scripting Languages Course 1. Diana Trandabăț

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Files

CSCI 2132 Software Development. Lecture 5: File Permissions

On successful completion of the course, the students will be able to attain CO: Experiment linked. 2 to 4. 5 to 8. 9 to 12.

Working with Basic Linux. Daniel Balagué

Introduction. SSH Secure Shell Client 1

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Linux & Shell Programming 2014

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

CS246 Spring14 Programming Paradigm Notes on Linux

Lec 1 add-on: Linux Intro

Lecture 2b. Pathnames, files, special characters in filenames, and file permissions. COP 3353 Introduction to UNIX, FALL 2013

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

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Linux & Shell Programming 2014

Operating Systems Lab 1 (Users, Groups, and Security)

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.

The Unix Environment for Programming (COMP433)

CSCI 2132 Software Development. Lecture 4: Files and Directories

Operating Systems. Copyleft 2005, Binnur Kurt

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

AN INTRODUCTION TO UNIX

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

read: permitted to read the contents of directory ( view files and sub-directories in that directory ).

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

find Command as Admin Security Tool

CISC 220 fall 2011, set 1: Linux basics

The Unix Shell & Shell Scripts

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

28-Nov CSCI 2132 Software Development Lecture 33: Shell Scripting. 26 Shell Scripting. Faculty of Computer Science, Dalhousie University

The e switch allows Perl to execute Perl statements at the command line instead of from a script.

Std: XI CHAPTER-3 LINUX

Listing Directory Attributes. Bamuengine.com Page 1. BY Prof. P. Katkar, DIEMS, AURANGABAD

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to Linux Workshop 1

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

CMSC421: Principles of Operating Systems

CSE II-Sem)

5/8/2012. Exploring Utilities Chapter 5

Introduction to Linux

Unix Internal Assessment-2 solution. Ans:There are two ways of starting a job in the background with the shell s & operator and the nohup command.

Chapter 1 - Introduction. September 8, 2016

I/O and Shell Scripting

lsx [ls_options ] [names]

Using the Unix system. UNIX Introduction

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Week 2 Lecture 3. Unix

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

UNIT I Linux Utilities

PROGRAMME: COMPUTER SCIENCE & ENGINEERING COURSE: Operating System Lab SEMESTER: VI CREDITS: 2

CST Lab 2 Review #1

Answers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R

Introduction to PC Operating Systems

Lecture 18 Regular Expressions

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

RH033 Red Hat Linux Essentials

C Shell Tutorial. Section 1

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

Part 1: Basic Commands/U3li3es

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

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

2. UDP Client, UDP Server

Chapter-3. Introduction to Unix: Fundamental Commands

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

UNIX File Hierarchy: Structure and Commands

Transcription:

Q.2 a. Explain the principal components: Kernel and Shell, of the UNIX operating system. Refer Page No. 22 from Textbook b. Explain absolute and relative pathnames with the help of examples. Refer Page No. 73-75 from Textbook Q.3 a. What is the function of ls command? List the different options and what is the use of -a, -l, -d and -R in it. ls command is used to print content of directory. Following are the different options and their uses: -a list hidden files -d list the name of the current directory -F show directories with a trailing '/' executable files with a trailing '*' -g show group ownership of file in long listing -i print the inode number of each file -l long listing giving details about files and directories -R list all subdirectories encountered -t sort by time modified instead of name b. Explain the three modes of operation in vi editor. (8) Modes of Operation in vi editor There are three modes of operation in vi: Command Mode, Input Mode, and Line Mode: (A) Command Mode: When vi starts up, it is in Command Mode. This mode is where vi interprets any characters we type as commands and thus does not display them in the xterm window. This mode allows us to move through a file, and to delete, copy, or paste a piece of text. To enter into Command Mode from any other mode, it suffices to press the [Esc] key. If we press [Esc] when we are already in Command Mode, then vi will beep or flash the screen. (B) Input Modet: In Input Mode, vi accepts keystrokes as text and displays the text as it is entered from the keyboard. vi must be in Input Mode before we can insert text into a file. To enter into Input Mode, we need to put vi into Command Mode and type the key [i]. (C) Line Mode: Line Mode is invoked by typing a colon [:] or a slash [/] while vi is in IETE 1

Command Mode. The cursor will jump to the last line of the screen and vi will wait for a command. Q.4 a. List the steps that the shell undertakes in order to execute a given command. Refer Page No. 146 (summarized points) from Textbook b. What are pipes in Unix and what is their use? (8) Refer Page No. 161-164 from Textbook Q.5 a. What is hard link and soft link? How can they be created? (3+3+2) Hard links: a hard link is a pointer to the file's i-node. For example, suppose that we have a file a-file.txt that contains the string "The file a-file.txt": % cat a-file.txt The file a-file.txt Soft links (symbolic links): a soft link, also called symbolic link, is a file that contains the name of another file. We can then access the contents of the other file through that name. That is, a symbolic link is like a pointer to the pointer to the file's contents. For instance, supposed that in the previous example, we had used the -s option of the ln to create a soft link: % ln -s a-file.txt b-file.txt b. Which command is used to change permission associated to File/Directories? List and explain methods to change permission of File/Directories. There are three types of permissions: r read the file or directory w write to the file or directory x execute the file or search the directory Each of these permissions can be set for any one of three types of user: u the user who owns the file (usually you) IETE 2

g members of the group to which the owner belongs o all other users The access permissions for all three types of user can be given as a string of nine characters: user r w x group r w x oth ers r w x Permission File Directory r read read a file list files in... w write write a file create file in... rename file in... delete file... x execute execute a shell script read a file in... write to a file in... execute a file in... execute a shell script in... Setting access permissions numerically There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1. r w x 4 2 1 These values are added together for any one-user category: 1 = execute only 2 = write only 3 = write and execute (1+2) 4 = read only IETE 3

5 = read and execute (4+1) 6 = read and write (4+2) 7 = read and write and execute (4+2+1) So access permissions can be expressed as three digits. For example: user group others chmod 640 file1 rw- r-- --- chmod 754 file1 rwx r-x r-- chmod 664 file1 rw- rw- r-- Q.6 a. What is the difference between a wild card and a regular expression? A wildcard is a generic term referring to something that can be substituted for all possibilities. This is like a joker being a wildcard in poker. In computer terms, usually a simple "wildcard" is just a * that can match one or more characters, and possibly a? that can match any single character. A regular expression certainly includes such functionality, but is a much more powerful pattern matcher that gives you the ability to restrict the type of characters and give more flexible specification on how many characters to match. Picture matching a phone number. A wildcard at best could do something like???-???-???? while a regex can do \d{3}-\d{3}-\d{3} which will match any US phone number in that particular format, ensuring each character in the phone number is 0-9 (that's what the \d) is. But parentheses in regexes can be used for another purpose too. You can match sections of the pattern, which you can use later. Let's say you want the area code. (\d{3})-\d{3}-\d{3} will not only match the phone number, but it will also store the area code in the first "group". A regex parser, in a language like Perl or Java, will then let you retrieve the group, to do what you want with it. b. What is the difference between Interval Regular Expression (IRE) and Tagged Regular Expression (TRE)? IETE 4

Refer Page No. 263-266 from Textbook Q.7 a. What is the exit status of a command? What is its normal value and which shell parameter stores its value? The exit status is an integer that represents the success or failure of a command. If has the value 0 when the command executes successfully and is stored in the parameter $? b. Explain the test command. (8) Refer Page No. 278-283 from Textbook Q.8 a. Explain in detail the simple awk filtering. (6) a filter action is the most efficient way to limit its scope. In AWK scripts, the action specified by such a conditional filter occurs only if the specified pattern matches the record in question. The format for a conditional filter rule is as follows: pattern { action } The action here is a series of statements just like any other filter rule. The pattern can be blank (in which case it matches every record), or it can contain any combination of regular expressions or relational expressions. These two types of expressions are briefly explained in the following sections. b. Explain with an example how if statement can be used in an awk command. Refer Page No. 395 from Textbook c. What is the difference between print and print $0? (4) File 1 - firstfile #!/usr/bin/perl -w use strict; print $0. "\n"; print FILE. "\n"; IETE 5

do 'filetwo'; File 2 - filetwo #!/usr/bin/perl -w use strict; print $0. "\n"; print FILE. "\n"; Q.9 a. Explain the foreach loop in perl with the help of an example. Refer Page No. 412 from Textbook b. Explain the following: (4+4) (i) chop function (ii) substr function (i) chop This function removes the last character of a string and returns that character. If given a list of arguments, the operation is performed on each one and the last character chopped is returned. chop VARIABLE chop( LIST ) chop (ii) Refer Page No. 406 from Textbook TEXT BOOK I. UNIX Concepts and Applications, 4 th Edition, Sumitabha Das, Tata McGraw Hill, 2008 IETE 6