You are on page 1of 45

The UNIX Operating System

Introduction to UNIX
List the functions of an OS List the types of Operating Systems available List the features of UNIX that make it useful as an OS in a multiuser system Understand the basic concepts of a multi-user system List the components of the UNIX system List the features of the shell

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Objectives (contd.)
Describe the standard UNIX file hierarchy List the file-naming conventions in UNIX List the various types of files in UNIX List the types of users in UNIX Login and logout from a UNIX session Understand the role of the shell as a command interpreter List the types of shells

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Objectives (contd.)
Use the following directory commands in UNIX: pwd cd mkdir rmdir ls ls -l

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Objectives (contd.)
Use the following file commands in UNIX: cat cp rm mv Use the following commands in UNIX: date tput clear who

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Objectives (contd.)
Use the *, ?, and [ ] wildcard characters with file commands Display the manual pages using man Set the File Access Permissions for files using the chmod command Use the vi editor in UNIX to create and edit files

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
An Operating System
Software program designed to act as an interface between a user and a computer Performs the following functions: Command Interpretation Peripheral Management Memory Management Process Management Can be of the following types: Single-user Multi-user
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Multi-user System
Printer Communication Lines

System Console

System Unit Processor Disk Tape Floppy Disk

Local User

Terminals

Remote User

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Features of a Multi-user System
Multi-programming Time-sharing Multi-tasking

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Features and Benefits of UNIX
Portability Machine-independence Multi-user Operations Hierarchical File System UNIX Shell Pipes and Filters Utilities Background Processing Software Development Tools Maturity
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Components of UNIX
User/Application Programs/Utilities Shell Kernel Hardware

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Shell
Is a utility program provided with the system Acts as an interface between the user and the kernel Is executed as soon as the user logs in Can be of the following types: Bourne Shell C Shell Korn Shell Restricted Shell

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Features of the Shell
Interactive Processing Background Processing Input/Output Redirection Pipes Shell Scripts Shell Variables Programming Language Constructs

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
UNIX File System
Is a hierarchical, inverted tree structure Consists of the following directories under the root directory: /bin /dev /etc /usr /user /lib /tmp Each user is given a HOME directory under the user directory
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
File-naming Conventions
File names in UNIX: Can be upto 14 characters long Can contain digits, a dot (.) or the hyphen (-) or the underscore symbol (_) anywhere Can contain both upper-case and lower-case alphabets Are case-sensitive Should not have a blank, or a tab Example: a.h is not the same as A.H or A.h

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
   

Directory Typical Contents / - The "root" directory /bin - Essential low-level system utilities /usr/bin - Higher-level system utilities and application programs /sbin - Superuser system utilities (for performing system administration tasks) /lib - Program libraries (collections of system calls that can be included in programs by a compiler) for low-level system utilities /usr/lib - Program libraries for higher-level user programs
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX


Directory
Tmp

Typical Contents Temporary file storage space (can be used by any

user) /home( or /homes) - User home directories containing personal file space for each user. Each directory is named after the login of the user. /etc UNIX system configuration and information files /dev Hardware devices /proc A pseudo-filesystem which is used as an interface to the kernel. Includes a sub-directory for each active program (or process).

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Types of Files in UNIX
Ordinary files Directory files Special files

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Types of Users in UNIX
System Administrator File Owner Group Owner Other Users

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Working with UNIX
Logging In Logging Out

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Shell as a Command Interpreter
Shell prints $ prompt on screen Utility does action shell waits User enters command

Shell interprets command


Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Directory Commands
root

bin

dev

etc bin

usr

user gomes

lib dolly

tmp

Users:

Gomes

Dolly

d a t a 1

d a t a 2

prog-files

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
pwd Command
Displays the full path-name for the current directory $ pwd <Enter> /usr/bin $ /usr/bin is the directory in which the user is currently working

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
cd Command
Changes the current directory to the directory specified $ cd /user <Enter> $ pwd <Enter> /user $ The full path-name of the directory which the user wants to make current is specified .. can be used to change to a parent directory

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
cd Command (contd.)
$ pwd <Enter> /user/gomes $ cd .. <Enter> $ pwd <Enter> /user $ .. refers to the parent directory of the current directory

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
mkdir Command
Creates subdirectories $ mkdir prog-files <Enter> $ The current directory does not change to the new directory Full path-names can be specified when creating a directory

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
rmdir Command
Removes empty directories $ rmdir cob-prog <Enter> $ The directory to be deleted should: be empty not be the current directory

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
ls Command
Lists names of files and subdirectories of a directory $ ls /user/gomes <Enter> data1 data2 prog-files Names are printed in sorted order The directory name is optional if the names of files and directories under the current directory are to be listed

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
ls -l Command
Provides a long listing of a directory $ ls -l /user/gomes <Enter> total 3 -r w -r - -r - - 1 gomes student 13 Jan 1 10:39 data1 -rwxrwxrw x 1 gomes student 19 Feb 10 21:35 data2 drwxrwxr - - 2 gomes student 32 Jan 16 16:50 prog-files $ -l is referred to as an option of the ls command

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
cat Command
Displays the contents of one or more files $ cat data1 <Enter> A sample file $ Full path-names can also be specified to display a file in another directory The cat command can also display more than one file $ cat data1 data2 <Enter> A sample file Another sample file (contents of data2) $
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
cp Command
Duplicates files $ cp data1 data3 <Enter> If the target file already exists, its contents will be overwritten by the contents of the source file Files can be copied to and from another subdirectory

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
rm Command
Removes files $ rm data1 <Enter>

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
mv Command
Changes the name of a file or directory/moves files from one directory to another Example: Renaming a file $ mv data3 newfile <Enter> Example: Renaming a directory $ mv /user/gomes/prog-files /user/gomes/programs <Enter> In UNIX, a file can also be moved to another directory (not copied) $ mv data3 /user/gomes/programs/data3 <Enter>

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Other Commands
date Command Displays the current date and time $ date <Enter> Sat Feb 18 11:30:05 IST 1989 $ tput clear Command Clears the screen and positions the cursor on the top left corner of the screen

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
who Command Displays names of all users logged in $ who <Enter> gomes tty02 Feb 2 10:30 dolly ttyi3 Feb 2 9:40 anita tty01 Feb 2 9:00 paula tty07 Feb 2 9:00 The who command with am i can be used to display the name of current user $ who am i <Enter> gomes tty02 Feb 2 10:30 $
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Wildcard Matching
Offers the facility to perform an operation on a set of files The wildcard characters are: * matches a string of none, one or more characters ? matches any one character [] matches any one of the specified set of characters

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Displaying Manual Pages
The man command displays pages from the UNIX reference maunal The manual pages are organized as follows: Synopsis Description Example Files See Also Diagnostics Warnings Bugs
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
File Access Permissions (FAP)
Are permissions associated with a file with respect to: File Owner Group Owner Other Users Three kinds of access permissions are: Read access Write access Execute access

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Changing FAP
To change permissions the File Owner has to: Invoke the chmod command Indicate for which user the permission is to be changed users are denoted by u, g or o Indicate which permission is to be changed permissions are denoted by r, w or x Indicate whether the permission is to be given or removed use + or Indicate the file for which permissions are to be changed

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
chmod Command
Changes FAP for files $ chmod ug+wx <filename> <Enter> File Owner and Group Owner are granted write and execute permissions for the specified filename $ chmod g-w <filename> <Enter> The write permission is revoked from Group Owner for the specified filname

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
vi Editor
Used to enter and edit text files containing data or documents or programs Displays the contents of files on the screen Allows the user to add, insert, delete or change parts of the text

Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Commands of vi
i Insert text at current cursor position a Append text after current cursor position h Move to previous character l Move to next character k Move up one line j Move down one line x Delete character at current cursor position dd Delete line :wq Save all changes and quit :q! Quit without saving changes
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Summary
An Operating System (OS) forms an interface between users and the hardware and performs functions of Command Interpretation, Peripheral, Memory and Process Management. Operating Systems are of two types: single-user and multi-user. Multi-user OS handles multiple users as well as multiple devices simultaneously. Such an Operating System is more efficient and more sophisticated than a single-user OS. Multi-user systems allow many users to share the computing power of a computer. This kind of system consists of a central unit, a console and a number of terminals attached to the central unit. These terminals may be dumb or smart.
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Summary (contd.)
UNIX is a multi-user OS and has a number of features that make it ideal as a multi-user OS. UNIX is a multi-programming, timesharing and multi-tasking system. The three components of UNIX are Kernel, Utilities and Application programs. The shell is a utility program that comes with the system. The shell forms an interface between the user and the kernel and acts as the command interpreter for the kernel. For organizing data on the disk, UNIX provides a file system which allows you to group files in a convenient manner. The UNIX file system has a hierarchical structure where the files can be stored under directories.
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Summary (contd.)
UNIX commands are entered at the prompt. The directory and file commands in UNIX can be summarized as follows: Command Function pwd Print working directory cd Change directory mkdir Make directory rmdir Remove directory ls List the contents of a directory cat Display the contents of files cp Copy one file to another rm Remove files
Copyright Zensar Technologies, 2007. All rights reserved.

The UNIX Operating System


Introduction to UNIX
Summary (contd.)
Command Function mv Change the name of a file/directory or move files from one directory to another date Display system date tput clear Clear screen who Display names of users logged in

Copyright Zensar Technologies, 2007. All rights reserved.