understanding operating systems seventh edition chapter 13 unix operating system

70
Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Upload: theresa-turner

Post on 12-Jan-2016

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating SystemsSeventh Edition

Chapter 13

UNIX Operating System

Page 2: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 2

Learning Objectives

After completing this chapter, you should be able to describe:• The goals of UNIX designers• The significance of using files to manipulate devices• The strengths and weaknesses of competing

versions• The advantages of command-driven user interfaces

Page 3: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 3

Brief History

• Three major advantages of UNIX– Portability

• Code written in high-level language (C language) – Powerful utilities

• Brief, single operation commands• Combinable into single command

– Application device independence• Configurable to operate on any device type

Page 4: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Brief History (cont’d.)

• Research project originally in 1965– Joint venture between Bell Laboratories (AT&T

research and development group), General Electric, and MIT

• Bell Laboratories withdrew in 1969– Ken Thompson and Dennis Ritchie continued the

project

Understanding Operating Systems, 7e 4

Page 5: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 5

(table 13.1) The historical roots of UNIX. For current information about the many versions of UNIX, see www.theopengroup.org. © Cengage Learning 2014

Page 6: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 6

The Evolution of UNIX

• First official version– Design

• Do one thing well– Ran on a popular minicomputer– Widely adopted: competitive in the market

• Thompson and Ritchie: version 3– New programming language (C language)

Page 7: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 7

The Evolution of UNIX (cont'd.)

• AT&T forbidden to sell software– Universities and developers advanced software

• Commercial transformation• Berkley “bsd” version: 1973-1975

Page 8: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 8

The Evolution of UNIX (cont'd.)

• 1991: “The Open Group” formed– Owns UNIX trademark

• Key UNIX features preserved– Expanded commands and controls: increased to meet

new needs• Standards established

– Improve program’s portability from one system to another

Page 9: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Design Goals

• Thompson and Ritchie vision– UNIX operating system

• Created by programmers for programmers– Fast, flexible, and easy-to-use

• Immediate goals– Support software development

• Included utilities for customized code• Utilities designed for simplicity: do one thing well• Small manageable sections of code

– Keep algorithms simple• Based on simplicity, not speed or sophistication

Understanding Operating Systems, 7e 9

Page 10: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Design Goals (cont'd.)

• Long-term goal– Portability

• Reduces conversion costs• Application packages not obsolete with hardware

changes– Achieved with UNIX version 4: device-independent

• POSIX – Portable Operating System Interface for Computer

Environments• IEEE standards defining portable operating system

interface

Understanding Operating Systems, 7e 10

Page 11: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Memory Management

• Multiprogramming systems– Swapping (small jobs)

• Entire program in main memory before execution• Program size restriction• Round robin policy

– Demand paging (large jobs)• More complicated hardware• Increases system overhead• Thrashing (under heavy loads)• Advantage: implements virtual memory concept

Understanding Operating Systems, 7e 11

Page 12: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 12

Memory Management (cont'd.)

• Typical internal memory layout (single user)– Program code– Data segment– Stack

Page 13: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 13

(figure13.2) The historical roots of

UNIX. For current information about the many

versions of UNIX, see www.theopengroup.org.© Cengage Learning 2014

Page 14: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 14

Memory Management (cont'd.)

• Program code– Sharable portion of program– Reentrant code

• Physically shared by several processes • Code protected: instructions not modified during normal

execution• Data references: without absolute physical address

– Space allocation• Program cannot release until all processes completed• Text table: tracks processes using program code

Page 15: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 15

Memory Management (cont'd.)

• Data segment– After program code

• Grows toward higher memory locations – Nonsharable section of memory

• Stack– Starts at highest memory address

• Grows downward• Subroutine calls and interrupts add information • Main memory section: process information saved when

process interrupted– Nonsharable section of memory

Page 16: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 16

Memory Management (cont'd.)

• UNIX kernel– Implements “system calls”

• Memory boundaries for process coexistence– System calls

• File Manager interaction and I/O services request– Implements most primitive system functions

• Permanently resides in memory– Employs least recently used (LRU) page replacement

algorithm• Network PCs, single-user, and multi-user systems

– Applies same memory management concepts

Page 17: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 17

Process Management

• Handles– CPU allocation– Process scheduling– Satisfaction of process requests

• Kernel maintains tables– Coordinates process execution– Device allocation

• Uses predefined policies– Select process from READY queue– Begin execution

• Give time slice

Page 18: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 18

Process Management (cont'd.)

• Process scheduling algorithm– Selects highest priority process to run first– Priority value: accumulated CPU time

• Processes with large CPU time get lower priority– Compute-to-total-time ratio

• System updates for each job every second• Total time process in system divided by used process

CPU time– Ratio = one (1)

• CPU-bound job

Page 19: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 19

Process Management (cont'd.)

• Process scheduling algorithm (cont'd.)– Processes with same computed priority

• Handled by round robin– Interactive processes: low ratio (no special policies)– Balance I/O-bound jobs with CPU-bound jobs

• Keeps processor busy• Minimizes waiting processes overhead

Page 20: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 20

Process Management (cont'd.)

• Process scheduling algorithm (cont'd.)– Loading process from READY queue

• Process with longest secondary storage time– Swap out process

• Process waiting longest (disk I/O, idle)– When processor becomes available

• Process selected may not be ready (waiting on I/O)• Determine inactive but ready for execution• Process priorities recalculated• Handled dynamically

Page 21: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 21

Process Table Versus User Table

• Simple processes (nonsharable code)• Process table and user table

– Keep system running smoothly• Process table

– Always resides in memory– Maintains text table

• User table– Resides in memory while process is active– User table, process data segment, and code segment

• Swapped as needed

Page 22: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Process Table Versus User Table (cont'd.)

• Each process table entry contains: – Process identification number– User identification number– Process memory address or secondary storage

address– Process size and scheduling information

• Process table existence– Set up when process is created – Deleted when process terminates

Understanding Operating Systems, 7e 22

Page 23: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 23

Process Table Versus User Table (cont'd.)

• Text table– Sharable code processes– Process table maintains

• Text table contains:– Memory address or secondary storage address of

text segment (sharable code)– Count: tracks number of processes using code

• Increased by one when process starts using code• Decreased by one when process stops using code• Count = zero (0): implies code no longer needed

Page 24: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Process Table Versus User Table (cont'd.)

• User table– Allocated to each active process– Stored in transient memory area

• User table contains:– User and group identification numbers

• Determine file access privileges– Pointers to system’s file table

• Every file that the process uses– Pointer to current directory– List of responses for various interrupts– All information is accessible during process

Understanding Operating Systems, 7e 24

Page 25: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 25

Synchronization

• UNIX– True multitasking operating system

• Requires processes wait for certain events– Each event represented by integers

• Equal to address of table associated with event

• Race occurs – Event happens during process transition decision

• Wait for event and entering WAIT state

Page 26: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 26

Synchronization (cont'd.)

• fork– UNIX command: executes one program from another

program – Gives second program all first program attributes

(open files)– Saves first program in original form– Splits program: two copies

• Both run from statement after fork command– fork executed

• “Process id” (pid) generated• Ensures each process has unique ID number

Page 27: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 27

Synchronization (cont'd.)

(figure13.4) When the fork

command is received, the

parent process shown in (a)

begets the child process shown in

(b) and Statement 2 is executed

twice.© Cengage

Learning 2014

Page 28: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 28

Synchronization (cont'd.)

• wait– UNIX command: synchronizes process execution

• Suspends parent until child finished– Program IF-THEN-ELSE structure

• Controlled by pid value• pid > zero: parent process• pid = zero: child process• pid < zero: error in fork call

Page 29: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 29

Synchronization (cont'd.)

(figure13.5) The wait command used in

conjunction with the fork command will synchronize

the parent and child processes. In (a) the parent

process is shown before the fork, (b) shows the

parent and child after the fork, and (c) shows the

parent and child during the wait.

© Cengage Learning 2014

Page 30: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 30

Synchronization (cont'd.)

• exec– exec commands

• execl, execv, execls, execlp, and execvp• Start new program execution from another program

– Successful exec call • Overlay second program over first• Only second program in memory

– No return from successful exec call• Parent-child concept: does not hold

– Create parent-child relationship• Call fork, wait, and exec in that order

Page 31: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 31

Synchronization (cont'd.)

(figure13.6) The exec command is used

after the fork and wait combination. In (a) the

parent is shown before the fork, (b) shows the parent

and child after the fork, and (c) shows how the child process (Process 2) is

overlaid by the ls program after the exec command.

© Cengage Learning 2014

Page 32: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Device Management

• Device independence to applications– I/O device treated as special file type

• Device files given name– Descriptors called inodes

• Identify devices, contain device information, and stored in the device directory

• Device drivers– Subroutines working with operating system – Supervise data transmission

• Between main memory and peripheral unit

Understanding Operating Systems, 7e 32

Page 33: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 33

Device Management (cont'd.)

• Device driver kernel incorporation– During system configuration

• Recent UNIX versions– Program called config– Automatically creates conf.c

• For any hardware configuration– conf.c contains parameters controlling resources

• Number of internal kernel buffers and swap space size– conf.c contains two tables

• bdevsw (block device switch)• cdevsw (character device switch)

Page 34: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 34

Device Classifications

• Divide I/O system– Block I/O system (structured I/O system) – Character I/O system (unstructured I/O system)

• Physical device identification– Minor device number– Major device number– Class: block or character

Page 35: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 35

Device Classifications (cont'd.)

(figure13.7) When a process sends an I/O request, it goes to the UNIX kernel where the char and block device drivers reside.© Cengage Learning 2014

Page 36: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 36

Device Classifications (cont'd.)

• Class: block or character– Each has configuration table

• Array of entry points into device drivers– Major device number

• Array index accessing appropriate code (specific driver)– Minor device number

• Passed as an argument to device driver• Access one of several identical physical devices

– Block I/O system• Devices addressed as 512-byte block sequences• Allows device manager to buffer (reduce I/O traffic)

Page 37: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 37

Device Classifications (cont'd.)

• Character class devices– Handled by device drivers implementing character

lists– Example: terminal

• Typical character device• Two input queues and one output queue

• I/O procedure synchronized through hardware completion interrupts

• Some devices belong to both block and character classes– Examples: disk drives and tape drives

Page 38: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 38

Device Drivers

• Special section in kernel• Disk drive’s device drivers

– Use seek strategy to minimize arm movement• Kept in set of files

– Included as needed– Small changes due to peripheral upgrades

• Linked into the kernel to keeping the operating system informed of new features and capabilities

– Kept in /dev directory by default and convention

Page 39: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 39

File Management

• Three file types – Directories– Ordinary files– Special files

• Each enjoys certain privileges• Directories

– Maintain hierarchical structure of file system– Users allowed to read information in directory files– Only system allowed directory file modification

Page 40: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 40

File Management (cont'd.)

• Ordinary files– Users’ stored information– Protection based on user requests

• Related to read, write, execute, delete functions performed on file

• Special files– Device drivers providing I/O hardware interface– Appear as entries in directories– Part of file system (most in /dev directory)– Special filename indicates type of device association

Page 41: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

File Management (cont'd.)

• Files stored as sequences of bytes– No structure imposed

• Structure of files– Controlled by programs using them: not by system

• Text files– Character strings

• Lines delimited by line feed or new line character

• Binary files– Sequences of binary digits

• Grouped into words as they appear in memory during program execution

Understanding Operating Systems, 7e 41

Page 42: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 42

File Management (cont'd.)

• Organizes disk into blocks• Divides disk into four basic regions

– First region (address 0): reserved for booting– Second region (superblock): contains disk size and

other regions’ boundaries – Third region: includes file definitions called i-list– Remaining region: holds free blocks available for file

storage• Files stored in contiguous empty blocks

– Simple allocation and no need to compact

Page 43: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 43

File Management (cont'd.)

• Each entry in i-list called an i-node (or inode)– Contains 13 disk addresses

• Contains specific file information– Owner’s identification– Protection bits, physical address, and file size– Time of creation, last use, and last update– Number of links– File type

• Directory, ordinary file, or special file

Page 44: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 44

File Naming Conventions

• Case-sensitive filenames• 255 character length• Special characters allowed, except colon (:)• No file naming conventions

– Some compilers expect specific suffixes• Supports hierarchical tree directory structure

– Root directory identified by slash (/)

Page 45: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 45

(figure13.9) File hierarchy seen as an upside-down tree with the forward slash (/ ) as the root, leading next to the directories and subdirectories, and then to the files shown in dashed line boxes.© Cengage Learning 2014

Page 46: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 46

File Naming Conventions (cont'd.)

• Absolute path name: starts at the root directory• Relative path name: does not start at the root

directory• Path name rules

– Path name beginning with a slash starts at the root directory

– Path name • One name or list of names: separated by slashes• Last name on list: filename requested

– Two periods (..) in path name• Moves upward in hierarchy (closer to root)

Page 47: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Directory Listings

• “long listing” – Eight information pieces for each file

• Access control, number of links, name of the group and owner, byte size of the file, date and time of last modification, and filename

Understanding Operating Systems, 7e 47

Page 48: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 48

Directory Listings (cont'd.)

(table 13.2) This table shows the list of files stored in the directory journal from the system illustrated in Figure 13.9. The command ls -l (short for “listing-long”) generates this list.© Cengage Learning 2014

Page 49: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Directory Listings (cont’d.)

• First column – Shows file type and access privileges for each file

• First character: nature of file or directory• Next three characters: access privileges granted file

owner• Next three characters: access privileges granted other

user’s group members• Last three characters: access privileges granted to

users at large (system-wide)

Understanding Operating Systems, 7e 49

Page 50: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 50

(figure 13.10) Graphical depiction of a list of file and directory permissions in UNIX.© Cengage Learning 2014

Page 51: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Directory Listings (cont'd.)

• Second column– Indicates number of links (number of aliases)

• Referring to same physical file

• Aliases– Important UNIX feature: support file sharing

• Several users work together on same project– Shared files appear in different directories belonging

to different users– Filename: may be different from directory to directory– Eventually number will indicate when file is no longer

needed: can be deleted

Understanding Operating Systems, 7e 51

Page 52: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 52

Data Structures

• File information divided into parts between:– Directory entries: filename and device’s physical

addresses– i-nodes: all other information

• i-nodes stored in reserved part of device– Where directory resides

Page 53: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 53

Data Structures

• i-node has 13 pointers (0–12)– First 10 pointers ► direct blocks– Eleventh entry ► indirect block– Twelfth entry ► double indirect block– Thirteenth entry ► triple indirect block

• When a file is created– i-node is allocated to it– Directory entry with filename and i-node number is

created

Page 54: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Data Structures (cont'd.)

• When a file is linked– Directory entry created with the new name and the

original i-node number– Link-count field in the i-node is incremented by one

• When a shared file is deleted– Link-count field in the i-node decremented by 1

• When the count reaches 0, the directory entry is erased and all disk blocks allocated to the file are deallocated

Understanding Operating Systems, 7e 54

Page 55: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 55

User Interfaces

• Menu-driven systems and command-driven interfaces– Both are nearly identical in UNIX and Linux

• User commands in command driven system– Very short

• One character or a group of characters (acronym) – Cannot be abbreviated or spelled out – Must be in correct case: generally only lowercase– May combine on single line: additional power and

flexibility

Page 56: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 56

(table 13.3) Small sample of UNIX (and Linux) user commands which are entered in all lower case. Check your technical documentation for proper spelling and syntax.© Cengage Learning 2014

Page 57: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 57

(table 13.3) (cont’d.)Small sample of UNIX (and Linux) user commands which are entered in all lower case. Check your technical documentation for proper spelling and syntax.© Cengage Learning 2014

Page 58: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 58

User Interfaces (cont'd.)

• General syntax of commandscommand arguments file_name

• “command”– Any legal operating system command

• Interpreted and executed by shell

• “arguments“– Required for some commands, optional for others

• “file_name” – Relative or absolute path name

Page 59: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 59

Script Files

• Automate repetitious tasks– Command files

• Often called shell files or script files

• Each line of file– Valid instruction

• Executed by typing sh and script file name

• Also executed by defining file as executable command– Type filename at system prompt

Page 60: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 60

Script Files (cont'd.)

• Script file example

setenv DBPATH /u/lumber:.:/zdlf/product/central/dbsetenv TERMCAP $INFODIR/etc/termcapstty erase `^H’set savehistoryset history=20alias h historyalias 4gen infogen -fsetenv PATH /usr/info/bin:/etc

Page 61: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 61

Redirection

• Send output to file or another device– Angle bracket ( > ) inserted between command and

destination– Examples:

• ls > myfiles• cat chapter_1 chapter_2 > section_a• cat chapt* > section_a

– Double bracket symbol ( >> ) appends new file to an existing file

– Example:• cat chapter_1 chapter_2 >> section_a

Page 62: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 62

Redirection (cont'd.)

• Reverse redirection ( < )– Takes input for program from existing file instead of

keyboard– Example:

• mail Chris Anthony Ida Roger < memo

Page 63: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 63

Redirection (cont'd.)

• Redirection ( > )– Combined with system commands to achieve any

desired results– Example: who > temporary

• Store in “temporary” file: all user names logged on

• Interpretation of < and >– Carried out by shell – Not by individual program

• Input and output redirection– Used with any program

Page 64: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 64

Pipes

• Provide possibility to redirect output or input to selected files or devices– Connect output from one program to input of another– No need for temporary or intermediate files– Example: who | sort

• Pipeline– Several programs simultaneously processing same

I/O stream– Example: who | sort | lpr

Page 65: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 65

Filters

• Program– Read some input, manipulate it, generate output– wc (word count):

• Example: wc journal• System response: 10 140 700• File journal has 10 lines, 140 words, 700 characters

– sort• Command with filename given: contents of file sorted

and displayed on screen• Example: sort wk_names > sortednames

– Input file sorted and written to another file

Page 66: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 66

Filters (cont'd.)

• Obtain numerical sort in ascending order– sort -n wk_names > sortednumbs

• Obtain numerical sort in descending order– sort -nr wk_names > sortednumbs

• Obtain sort on the third field in alphabetical order– sort +2f empl > sortedempl

Page 67: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 67

Additional Commands

• man– Displays operating system online manual– Example: man cmp

• Displays page for compare (cmp) command• grep

– “global regular expression and print”– Look for specific character patterns– Examples:

• grep Pittsburgh mail-list• grep -v Pittsburgh mail-list• grep -c Pittsburgh mail-list

Page 68: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 68

Additional Commands (cont'd.)

• grep (cont'd.)– Can be combined with who command– Example: who | grep bob

• Bob’s name, device, date and time he logged in– Example: ls -l / | grep '\d'

• Displays subdirectories list (not files) in root directory

• nohup– Log off the system without program completion– Example:

nohup cp old_largefile new_largefile &

Page 69: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Understanding Operating Systems, 7e 69

Additional Commands (cont'd.)

• nice– Allows lowering program priority– Example:

nice cp old_largefile new_largefile &

Page 70: Understanding Operating Systems Seventh Edition Chapter 13 UNIX Operating System

Conclusion

• UNIX: far reaching impact on the computing world– Has revolutionized development of operating systems

• Power, speed and flexibility• Widespread adoption on computing devices of every

size– Reasons for success

• Spare, flexible, and powerful command structure• Recent addition of several standard graphical user

interfaces: easier to issue commands• Adoption by Apple: basis for Mac OSX operating

system: extended the user base

Understanding Operating Systems, 7e 70