Chapter 2: Linux & POSIX “She sells bash shells by the C shore”

Slides:



Advertisements
Similar presentations
Operating System Structures
Advertisements

What is an operating system? Is it software?
Chap 2 System Structures.
Chapter One The Essence of UNIX.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Linux+ Guide to Linux Certification, Second Edition
Operating Systems - Introduction S H Srinivasan
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Basic Unix Dr Tim Cutts Team Leader Systems Support Group Infrastructure Management Team.
The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 145 Operating Systems Introduction to UNIX/Linux.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Linux Commands LINUX COMMANDS.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – Shell Programming The activities of.
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Introduction to Shell Script Programming
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 5 Acknowledgements: The syllabus and power point presentations are modified versions.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
UNIX and Shell Programming (06CS36) Unit 1 Continued… Shrinivas R. Mangalwede Department of Computer Science and Engineering K.L.S. Gogte Institute of.
CS 390 Unix Programming Summer Unix Programming - CS 3902 Course Details Online Information Please check.
CS 390 Unix Programming Environment Summer Suchindra Rengan - CS3902 Course Details Instructors Suchindra Rengan – ‘sachin’ ( Section 001)
Linux Operations and Administration
1 Homework / Exam HW7 is due next class Starting Glass chapter 4 and parts of 7 Exam 3 – Class 26 –Open Book / Open Notes –Up through End of K&R Chapter.
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. An operating.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
CSC 360- Instructor: K. Wu Interfaces to OS Services.
Operating Systems Process Creation
UNIX Command RTFM: trap(1p) Gilbert Detillieux October 8, 2013 MUUG Meeting.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Basic UNIX Concepts. Why We Need an Operating System (OS) OS interacts with hardware and manages programs. A safe environment for programs to run is required.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Introduction to UNIX CS 2204 Class meeting 1 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Introduction to UNIX CS465. What is UNIX? (1) UNIX is an Operating System (OS). An operating system is a control program that allocates the computer's.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Unix Advanced Shells Chapter 10. Unix Shells u Command Line Interpreter –once logged in, login gives control to a shell –it prompts for input, then parses,
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
1 CSE 451 Section 2: Processes, the shell, and system calls.
Shell ITEC400 Yukari Kitamura. What is shell? An interface between the user and OS A utility program to interact with the kernel A programming language.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Bash Jerome Lewis Kelly Benson Andrew Kimble. Overview  Shell Language (UNIX based)  Paradigms – Command, Scripting  Has ability to read straight from.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
A LECTURE NOTE.
Unix Scripting Session 1 March 6, 2008.
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
CASE STUDY 1: Linux and Android
UNIX System Overview.
Operating Systems Georgios Varsamopoulos
CSE 303 Concepts and Tools for Software Development
INTRODUCTION TO UNIX: The Shell Command Interface
Introduction to UNIX.
Chapter 2: System Structures
Advanced UNIX progamming
CSE 303 Concepts and Tools for Software Development
Chapter 2: Operating-System Structures
Consult America Technology Consulting Services
LPI Linux Certification
Presentation transcript:

Chapter 2: Linux & POSIX “She sells bash shells by the C shore”

The Linux kernel We know that the linux kernel manages system resources and especially when applications are running “on” the computer The kernel itself cannot communicate, even though it handles user interface devices: “ You can compute all you like, but if you can’t I/O, it don’t mean a thing.” Enter the shell: A shell is a program (interpreter) that 1.prints a prompt, 2.reads a line of input from you (the “command”) 3.interprets it to manipulate files or run other programs

The shell: more… Early PCs (without “windows”) had a DOS prompt. Aside, what does DOS acronym mean? That DOS prompt was printed by the DOS shell, called: command.com The linux kernel has multiple shells that can be used by different users at the same time. There are 3 major types. 1.The Bourne-compatible shells use the syntax derived from the original Bourne shell.Bourne shell 2.C shells use the syntax from the original C shell.C shell 3.Nontraditional shells that invent their own syntax, or borrow one from some programming language Examples Bash shell Bourne shell Bourne again shell Korn shell

built-ins A shell can execute a built-in command itself, without interpretation. Compilers have built-in commands, called APIs or functions, also. (Most math functions are built in, a possible reason why java math API’s do not need to be associated with “an object” Characteristics: Faster and more efficient Can change the state of the shell itself Which commands are built-in? It depends on the shell It also depends on POSIX compliance.

built-ins: more… There are three levels of built-in utilities: Utility built-ins are part of the shell as programming language, and control execution.., :, break, continue, return, trap, exit, exec Special built-ins need to be implemented inside the shell They act on the shell's internal settings: cd, dir, pushd, popd ; job control utilities: bg, disown, fg, jobs, wait; utilities that read/manipulate attributes: builtin, command, hash, read, type, ulimit utilities related to interactive features: fc, history, bind. Performance built-ins: utilities implemented for speed: echo, printf, test, true, false.

What’s POSIX? Short Answer: Portable Operating Systems Interface for uniX

What’s POSIX? A longer answer… All unix systems have their own cute little quirks (aix, solaris, linux, etc.) POSIX defines a standard to work with, across all the “nix’s” + any other OS that wants to be POSIX compliant (mainframe OS’s, windows) Standards? The Open Group, and IEEE set standards for (multiple) POSIX versions. pubs.opengroup.org/onlinepubs/ / Open Group Base Specifications Issue 7 == IEEE Std ™, 2013 Edition The standards evolve as technologies (HW/SW) change.

What’s POSIX? A longerer answer… POSIX 7 defines the following: ANSI C extensions that appear outside the bounds of C (file I/O, networking) Utilities (builtins too): ls, cd, echo, mkdir, mkdir() grep sed Shell language: GNU bash Environment variables: PATH How programs exit on error condition (errno) Filesystem directory structure: /home, /usr, /etc Filesystem naming conventions More pubs.opengroup.org/onlinepubs/ /nfindex.html

Let’s make a directory! pubs.opengroup.org/onlinepubs/ /utilities/mkdir.html NAME mkdir - make directories SYNOPSIS mkdir [-p] [-m mode] dir... DESCRIPTION The mkdir utility shall create the directories specified by the operands, in the order specified. For each dir operand, the mkdir utility shall perform actions equivalent to the mkdir() function defined in the System Interfaces volume of POSIX , called with the following arguments: mkdir() The dir operand is used as the path argument The value of the bitwise-inclusive OR of S_IRWXU, S_IRWXG, and S_IRWXO is used as the mode argument.

Let’s write code to make a directory! pubs.opengroup.org/onlinepubs/ /functions/mkdir.html NAME mkdir - make a directory relative to directory file descriptor SYNOPSIS #include sys/stat.h int mkdir(const char *path, mode_t mode); DESCRIPTION The mkdir() function shall create a new directory with name path. The file permission bits of the new directory shall be initialized from mode. These file permission bits of the mode argument shall be modified by the process' file creation mask.

A coding example #include // int status; //... status = mkdir("/home/cnd/mod1", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); If (status == 0) { // } else //