USP Unit 1
USP Unit 1
INTRODUCTION
1
Structure of Computer System
• A modern computer consists of:
One or more processors
Main memory
Disks
Printers
Various input/output devices.
• Managing all these varied components requires a layer of
software
2
3
• A computer consists of three main functional parts:
1. A processor (CPU)
2. A main-memory system
3. An I/O system
•
• The CPU consists of a control unit, registers, the arithmetic
and logic unit, the instruction execution unit , and the
interconnections among these components
• The information handled by a computer consists of
instructions and data
4
MEMORY UNIT
• Memory
• The storage area in which programs are kept when they are
running and that contains the data needed by the running
programs
• Types of memory
• Volatile memory: storage that retains data only if it is
receiving power, such as dynamic random access memory
(DRAM)
• Nonvolatile memory: a form of memory that retains data
even in the absence of a power source and that is used to
store programs between runs, such as flash memory
• Usually, a computer has two classes of storage
• Primary memory and secondary memory
5
Arithmetic and Logic Unit
• Most computer operations are performed in the Arithmetic
and Logic Unit (ALU) of the processor
• Typical arithmetic and logic operation are:
Addition, subtraction, multiplication, division, comparison,
complement, etc.
• When operands are brought into the processor, they are
stored in high-speed storage elements called registers.
6
Operating System
• Operating System is a Software :-
7
What OS does?
An operating system performs basic tasks such as,
8
Structure of Operating System:
Application Programs
System Programs
HARDWARE
(Contd…)
9
Contd…:
• The structure of OS consists of 4 layers:
1. Hardware :
• Hardware consists of CPU, Main memory, I/O
Devices, etc,
10
Contd…:
3. System programs :
• This layer consists of compilers, Assemblers,
linker etc.
4. Application programs :
• This is dependent on users need.
• Ex. Railway reservation system, Bank database
management etc.,
11
Evolution of OS:
• The evolution of operating systems went through seven
major phases.
12
Contd..
Major Phases Technical Operating
Innovations Systems
(Contd…)
13
Contd..
Timesharing Simultaneous user Multics file system
interaction, (1965),
On-line file systems Unix (1974)
14
Where does the OS fit in?
15
Operating Systems functions:
• The main functions of operating systems are:
1. Program creation
2. Program execution
3. Input/output operations
4. Error detection
5. Resource allocation
6. Accounting
7. protection
16
Types of OS:
Operating System can also be classified as,-
17
Single User Systems:
• Example: DOS
18
Multi-User Systems:
19
THE UNIX OPERATING SYSTEM
• UNIX is a computer operating system, a control program
that works with users to
– run programs,
– manage resources, and
– communicate with other computer systems.
• UNIX was first developed in the 1960s, and has been under
constant development ever since.
21
22
• Unix is designed to extend users functionality
• To build new tools easily and efficiently
• To customize the shell and user interface.
• To string together a series of Unix commands to create
new functionality.
• To create custom commands that do exactly what we
want.
23
UNIX ARCHITECTURE
24
SOFTWARE ARCHITECTURE
• Unix architecture mainly constituents three parts:
3. System Calls
25
Kernel and Shell
• 1.Kernel:
• Interact with machine’s hardware
• It is core of the operating system.
• Contains collection of routine written in C.
• Users programs need to access hardware uses services of
kernel.
• These programs access kernel via some set of functions
called as System Calls.
• It manages system’s memory, schedules processes decide
their priorities and perform other tasks.
• Kernel also called as operating system- a program’s gateway
to computer resources.
26
Kernel and Shell
• 2.Shell
• The shell acts as an interface between the user and the
kernel.
• The shell is a command line interpreter (CLI).
• It interprets the commands the user types in and arranges
for them to be carried out.
• The commands are themselves programs: when they
terminate, the shell gives the user another prompt (% on
our systems).
• There can be multiple shells as per number of users logged
in at a time running on a system
27
Popular Shells
sh Bourne Shell
ksh Korn Shell
csh,tcsh C Shell (for this
course)
bash Bourne-Again Shell
28
• The shell provides you with an interface to the UNIX system.
• It gathers input from user and executes programs based on
that input.
• When a program finishes executing, it displays that
program's output.
• A shell is an environment in which user can run our
commands, programs, and shell scripts.
• There are different flavors of shells, just as there are
different flavors of operating systems.
• Each flavor of shell has its own set of recognized commands
and functions.
29
Flavors of Unix Shells
Two main flavors of Unix Shells
Bourne (or Standard Shell): sh, ksh, bash, zsh
• Fast
• $ for command prompt
C shell : csh, tcsh
• better for user customization and scripting
• %, > for command prompt
To check shell:
% echo $SHELL (shell is a pre-defined variable)
To switch shell:
% exec shellname (e.g., % exec bash)
30
The Kernel-Shell Relationship
31
File and Process
• Files are the actually storage location, it has places
• A file is a collection of data.
• Everything in UNIX is either a file or a process.
• A process is a program that is currently running.
• A process may be associated with a file.
• The file stores the instructions that are executed for that process to
run.
• The operating system tracks processes through a five digit ID
number known as the PID or process ID .
• Each process in the system has a unique PID.
• There are a number of file types.
• When a file is opened a file descriptor is created
32
Examples of files
1. A document (.Doc)
2. The text of A program written in some high-level
programming language(e.G. .C,c++)
3. Instructions comprehensible directly to the machine and
incomprehensible to casual user, for example, A collection
of binary digits (.Exe);
4. A directory, containing information about its contents,
which may be A mixture of other directories
(subdirectories) and ordinary files.
33
Starting a Process
• There are two ways to start a process
1. Foreground Processes:-
• By default, every process that you start runs in the
foreground.
• It gets its input from the keyboard and sends its output to
the screen.
2. Background Processes :-
• A background process runs without being connected to your
keyboard.
• If the background process requires any keyboard input, it
waits.
34
System Calls
• They are functions used to communicate with the kernel.
• System calls define the programmer interface to UNIX .
• All versions of Unix uses same system calls.
• Roughly three categories of system calls in UNIX
– File manipulation (same system calls also support device
manipulation)
– Process control
– Information manipulation
35
Features of UNIX OS
• Portable
— UNIX can be installed on many hardware platforms.
— ts widespread use can be traced to the decision to develop it using the C
language.
• Multiuser
— The UNIX design allows multiple users to concurrently share hardware
and software
• Multitasking
— UNIX allows a user to run more than one program at a time.
— More than one program can be running in the background while a user is
working foreground.
• Networking
— Networking is also incorporated into the heart of the operating system.
— Access to another system uses a standard communications protocol
known as Transmission Control Protocol/Internet Protocol (TCP/IP).
36
Features of UNIX OS
• Organized File System
— UNIX has a very organized file and directory system that allows users to
organize and maintain files.
• Device Independence
— UNIX treats input/output devices like ordinary files.
— The source or destination for file input and output is easily controlled
through a UNIX design feature called redirection.
• Utilities and toolkits
— UNIX provides a rich library of utilities that can be use to increase user
productivity.
— It provides general-purpose tools for text manipulation , compilers and
interpreters , networked applications and system administration tools.
• Pattern matching
— Provides unique feature of matching different patterns with the given
37
Logging in with Username and Password
• Unix has many users ,there should be a system administrator, to grant
authority to use the system
• SA opens account with user name and gives a secret code called as
password
• At the login: prompt, enter your account name, followed by the
ENTER or RETURN key.
• Type your account name in lower case letters.
• If you use upper case letters for the login, then you can not use lower
case letters in the password.
• If you enter a valid account name, you will be asked for your
password.
• login: accountname
Password:
38
• At the Password: prompt, enter your password, followed by the
ENTER or RETURN key.
• Password: password
$
• Failure will be indicated by an error message.
• The exact error message varies by system, but will probably be
something similar to:
• Login incorrect
• The most likely reasons are:
1. Incorrect account name.
2. Incorrect password.
3. You typed the account name in upper case letters (check the
CAPS LOCK key).
39
date command
• The date command under UNIX displays date and time.
• Same command can also be used to set date and time.
• User must be the super-user (root) to change the date and time
• The date command shows the date and time read from the
kernel clock.
• Syntax is :
• date
• Sample outputs:
• Mon Aug 10 14:30:08 GMT 2015
• When executed without arguments, the date command shows
the current date and time.
40
Calendar Command
• Cal
This command will print the calendar on current month by default.
• Its general format is
• $ cal
• If you want to print calendar of August 2015
• cal 8 2015 will print following results.
• $ cal 8 2015
• S M Tu W Th F S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
41
• terminfo – terminal capability database.
• The terminfo database describes the capabilities of devices
such as terminals and printers.
• Devices are described in terminfo source files.
• terminfo source files consist of one or more device
descriptions.
• Each description consists of a header and one or more lines
that list the features for that particular device.
• Every device must be assigned a name, such as "vt100".
• Various suffixes can be added with the device name with
hyphen(-) sign which indicates special mode
42
• Following suffixes are used to indicate special modes.
• Suffix Meaning Example
• -w Wide mode (more than 80 columns) 5410-w
• -am With auto. margins (usually default) vt100-am
• -nam Without automatic margins vt100-nam
• -n Number of lines on the screen 2300-40
• -na No arrow keys (leave them in local) c100-na
• -np Number of pages of memory c100-4p
• -rv Reverse video 4415-rv
43
Clearing the Screen
• tput : initializes a terminal or queries the terminfo database.
• Syntax : $ tput
• Output:
• Usage: tput [-T [term] ] capname [parm argument…]
45
Ways of using tput
1. Set the Cursor Position using tput cup
You can move the cursor to a specific row and column using tput
cup. Following example positions the cursor at row 2 and column
3.
$ tput cup 2 3
2. Clear the Screen Using tput clear
If you are in middle of the terminal screen, tput clear will clear the
screen and put you at the top of the terminal screen.
$ tput clear
3. Get the Number of Columns and Lines of a Terminal
To display the number of columns of your terminal screen use
$ tput cols
Following displays number of lines of your terminal screen.
$ tput lines
46
4. Execute Multiple tput Commands
tput allows you to run set of commands in a single time. For
example, if you want to clear the screen and set cursor to a
particular position, do the following.
$ tput -S <<END > clear > cup 2 4 > END
5. Change the Terminal Background Color
Using tput, the background color of the screen can be changed as
shown below.
$ tput setb 2
6. Change the Foreground Color
You can also change the foreground color of the terminal as shown
below.
$ tput setf 4
47
7. Turn On and Turn Off Highlighting
tput allows you to turn on and turn off the text high lighting.
When you turn it ton, new text in the terminal gets bold.
$ tput bold
8. Underline Text
Start the underline mode:
$ tput smul
Stop the underline mode:
$ tput rmul
9. Hide and Unhide the Cursor
Hide the cursor:
$ tput civis
Display the cursor:
$ tput cnorm
48
To know the users
• Who
• Displays who is logged on to the system.
• Displays the username, line, and time of all currently logged-
in sessions.
• Syntax is : $ who
49
• Columns in o/p indicate:
1. Login name of user
2. Name of terminal user is working on.
3. Date and time of login.
50
Viewing the Processes
• User executes shell commands from their terminals.
• Every command user executes gives rise to a process.
• To view all processes user has created run ps command.
• Syntax is : $ ps
• O/p :
• PID TTY TIME CMD
• 364 console 0:00 ksh
• Ps generates details of ksh process , which is constantly
running at above specific terminal.
• When user log out , this process is killed.
51
Listing files
• Unix is based on large number of file system which controls its
functioning.
• When users create their own files , they were organized in separate
folders called as directories.
• These files stored in a directory can be listed with ls.
• Syntax is: $ ls
• o/p: README
Chap01
Chap02
Chap03
Progs
helpdir
52
Pattern Matching with ls
• Unix provides special short-hand notation (*) to access same type
of files with ls
• $ ls chap *
• Chap01
• Chap02
• Chap03
• To know more about these files , ls can be used with the option of
-l.
$ ls –l chap*
-rw-r- -r-- 1 kumar users 5609 Apr 23 09:30 chap01
-rw-r- -r-- 1 kumar users 34566 May 14 18:55 chap02
-rw-r- -r-- 1 kumar users 26157 Jun 19 10:45 chap03
53
Directing o/p with ls
• Unix has special symbols as metacharacters ,for creating and
storing information in a file.
• Instead of viewing the o/p of ls, it can be saved directly to a
file e.g. list
• Its syntax is :
• $ ls > list
• $_
• Prompt returns – no display on terminal.
• Shell redirect all the o/p coming to the terminal to a disk file
54
Counting Number of Lines
• Unix provides facility to count number of :
• 1. lines
• 2. words
• 3. characters of a file.
• Syntax is:
• $ wc list
• 6 6 42 list
55
Nesting of Commands
• Unix shell can count directly number of attributes in a files
without creating intermediate files.
• wc can be combined with ls using pipeline symbol (|).
• It is used to connect two or more command with each other.
• Syntax :
• $ ls |wc
• o/p: 6 6 42
• Without any file name.
56
The cat command
• Syntax is : cat argument
• The cat command is used to concatenate and display files.
Concatenate means to link together.
• Typing cat file2 will display on the screen file2 assuming that
this file2 already exists.
• cat > newfile : to create a new file and to enter text into it.
• cat file2 file3 >> file4 : to append file2 and file3 to the end of
the file4.
• If file4 does not exist, it is created now to receive the input
from file2 and file3.
Programming with Shell
• Shell provides programming facility
• Value to a variable can be assigned at the prompt as
• $ x=5
• $_
• Then this value can be evaluated using echo command
• $ echo $ x
• 5
58
Signing Off
• To log off from UNIX system user can use exit
• $ exit
• Login:
• Another way is press [ctrl-d ]
• After logging off login: message confirms that the session
has been terminated.
59
Locating Commands
• The simple way to know location of every command is to use
type command
• Syntax is :
• $ type ls
• o/p:
• ls is /bin/ls
• When ls is executed ,shell locates this file in the /bin
directory and makes arrangements to execute it
• Type searches for given command in the directories specified
in the path variable.
60
The PATH: Locating Commands
• UNIX obtains the list of directories that has to be searched
from of an environment variable – PATH.
• If you evaluate the value of PATH, you’ll find a directory list
separated by colons:
$ echo $PATH
/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin: .
• There are five directories in this list, and when a command is
issued, the system will search this list in the sequence
specified to locate and execute it.
• . indicates the current directory.
Internal and External Commands
• Some commands in UNIX e.g.ls are program or file having
independent existence in /bin directory.
• These are called as external commands.
• Whereas, some commands are not executed normally even
if they are in one of the directories specified by PATH.
• e.g. $ echo
• o/p echo is a shell built-in
• When shell reads echo command it will not search for it in
given path whereas ,it will execute it directly from its own
set of built-in commands that are not stored separately.
• These commands are called as internal commands.
62
Command Structure
• An UNIX command is composed of two parts: command
and argument.
• Commands and arguments are separated by any number
of spaces or tabs know as whitespace.
$ ls-l
o/p: ls-l: Command not found.
There must be whitespace between ls and –l.
• The argument that begins with a – symbol is called an
option.
Options and Filenames
• Every command has a fixed set of options.
• The command with its arguments and options is entered
in one line that is referred to as the command line.
• Every option must be preceded by (-) sign ,to separate
from files system.
• Wrong options will be indicated.
• An option can have its own arguments.
Combining Options
• Options that begin with a – sign can normally be combined
with only one – sign.
• For instance, this command has three options:
$ ls –l –a –t
where option,
• -l : provides most details of a file’s attributes.
• -t : sorts files according to the time of modification.
• -a : lists the hidden files. These options can be combined as:
$ ls –lat
$ ls –atl
• The shell parses (break up) the option combination into
separate options.
Filename Arguments
• Many UNIX commands use a filename as argument
• Some commands accept a single filename, some accept
more than one filenames.
• If a command uses a filename as argument, it will be the last
argument, after all options.
• Example:
• $ ls –l chap01 chap02
• $ cp file1 file2 file3 dest_dir
• $ rm file1 file2 file3
66
Exceptions and Variations
• All commands do not compulsorily use options and
arguments.
• Commands like clear do not accept any argument.
• The who and date commands may or may not be
specified with arguments.
• The ls command permits more variations:
– Without any argument : ls
– With only one option: ls –l
– With only filenames : ls f1 f2
– Using a combination of both : ls –l a chap01 chap02
Flexibility of Command Usage
• UNIX allows to specify more than one command in the same
command line.
• Each command is separated from the other by a
; (semicolon):
$ who; ls –l
• Unix also allows to group several commands together so that
their combined output is redirected to a file.
• e.g. (wc sample.txt ; ls –l sample.txt) > newfile
• The ; is one of special characters that are understood by the
shell.
• These special characters are known as metacharacters.
A Command Line Can Overflow
• When a command has more characters than the terminal
width, it simply overflows to the next line.
• User has to pre enter ,so that prompt goes to next line.
• The shell issues a secondary prompt, usually >.
$ echo “This is a two-line
> text message”
o/p: This is a two-line
text message
Flexibility of Command Usage
• Subsequent commands can be entered at the keyboard
without waiting for the prompt.
• There is a type-ahead buffer (a temporary storage area)
• This is maintained by the kernel for all keyboard input.
• The next command will be passed on to the shell for
interpretation after the previous command has
completed its execution.
• Every shell flavor has its own command behavior.
Flexibility of Command Usage
• The uname can print system information.
$ uname
o/p: Linux
• The uname –r command shows the version number of
the kernel.
$ uname –r
2.2.19
man command
• This command is used for Browsing The Manual Pages
Online.
• It displays online documentation of a specified command.
• A pager is a program that displays one screenful information
and pauses for the user to view the contents.
• The user can make use of internal commands of the pager to
scroll up and scroll down the information.
• The two popular pagers are more and less.
• more is the Berkeley’s pager and less is the standard pager
used on Linux systems
72
Understanding The man Documentation
• The man documentation is organized in eight sections.
• User can provide the section number additionally as
argument
• For example, passwd appears in section 1 and section 4.
• By default man displays information of section 1 , not of
section 4.
• If we want to get documentation of passwd in section 4, we
use,
• $ man 4 passwd
• OR
• $ man –s4 passwd
73
Understanding a man Page
• USER COMMANDS
wc(1)
• NAME
wc – displays a count of lines, words and characters in a file
• SYNOPSIS
wc [-c | -m | -C] [-lw] [file ...]
• DESCRIPTION
The wc utility reads one or more input files and, by default, writes
the number of newline characters, words and bytes contained in
each input file to the standard output. The utility also writes a
total count for all named files, if more than one input file is
specified.
74
• OPTIONS
The following options are supported:
-c Count bytes.
-m Count characters.
-C Same as –m.
-l Count lines.
-w Count words delimited by white spaces or new line
characters
• OPERANDS
The following operand is supported:
file A path name of an input file.
If no file operands are specified, the standard input will be used.
75
• EXIT STATUS
The following exit values are returned
0 Successful completion
>0 An error occurred
• SEE ALSO
cksum(1), isspace(3C), iswalpha(3C), iswspace(3C),
largefile(5), ...
76
• The following table shows the organization of man
documentation.
6 Games Games
7 Special files (in /dev) Macro packages and conventions
78
The File System
• File is container for storing information.
• Unix file doesn’t contain the end-of-file mark(eof).
• All file attributes are kept in a separate area of the hard disk.
• These can be directly accessed only to kernel.
• Unix treats directories and devices as files.
• Unix is a multi-user system, each user is allocated his own
file space.
• Each user has a directory on the system where his files will
be kept.
• This file is known as that user's home directory.
79
Types of files
• Most files are just files, called regular files : they contain
normal data.
• for example text files, executable files or programs, input for
or output from a program a
• Directories: files that are lists of other files.
• Special files or Device Files: All devices and peripherals are
represented by files.
• Links: a system to make a file or directory visible in multiple
parts of the system's file tree.
80
Types of files
• (Domain) sockets: a special file type, similar to TCP/IP
sockets, providing inter−process networking protected by
the file system's access control.
• Named pipes: act more or less like sockets and form a way
for processes to communicate with each other, without
using network socket semantics.
81
Ordinary (Regular) File
• This is the most common file type.
• An ordinary file can be either a text file or a binary file.
• A text file contains only printable characters that can viewed
and edited.
• All C and Java program sources, shell scripts are text files.
• Every line of a text file is terminated with the newline
character.
• A binary file, contains both printable and nonprintable
characters that cover the entire ASCII range.
• The object code and executables that user produces by
compiling C programs are binary files.
• Sound and video files are also binary files.
82
Directory File
• A directory contains no data, but keeps details of the files and
subdirectories that it contains.
• A directory file contains one entry for every file and subdirectory
that it houses.
• Each entry has two components namely, the filename and a
unique identification number of the file or directory (called the
inode number).
• When user create or remove a file, the kernel automatically
updates its corresponding directory by adding or removing the
entry associated with the file.
83
Device File
• All the operations on the devices are performed by reading
or writing the file representing the device.
• It is advantageous to treat devices as files as some of the
commands used to access an ordinary file can be used with
device files as well.
• Device filenames are found in a single directory structure,
/dev.
• A device file is not really a stream of characters.
• It is the attributes of the file that entirely govern the
operation of the device.
• The kernel identifies a device from its attributes and uses
them to operate the device.
84
Filenames in UNIX
• UNIX system, a filename can consist of up to 255 characters.
• Files may or may not have extensions.
• It consist of practically any ASCII character except the / and the Null
character.
• Only following characters be used in filenames:
1. Alphabets and numerals.
2. The period (.), hyphen (-) and underscore (_).
• UNIX imposes no restrictions on the extension.
• A file can have as many dots embedded in its name.
• A filename can also begin with or end with a dot.
• UNIX is case sensitive; cap01, Chap01 and CHAP01 are three different
filenames that can coexist in the same directory.
85
Directories and Files
• A file is a set of data that has a name.
• The information can be an ordinary text, a user written
computer program, results of a computation, a picture, and so on.
• The file name may consist of ordinary characters, digits and special
tokens like the underscore, except the forward slash (/).
• Unix organizes files in a tree-like hierarchical structure, with the
root directory, indicated by a forward slash (/), at the top of the
tree.
86
87
Absolute and Relative Paths
• A path, is the way need to follow in the tree structure to reach a
given file.
• An absolute path is simply sequence of directory names separated
by slashes.
• It shows a file’s location with reference to the top i.e.root.
• Relative path names does not start with a slash and are always
relative to the current directory.
• In relative paths we also use the . and .. indications for the current
and the parent directory.
88
The HOME Variable
• When user log on to the system.
• UNIX automatically places user in a directory called the home
directory.
• The shell variable HOME indicates the home directory of the user.
• E.g.,
• $ echo $HOME
• /home/kumar
• above is an absolute pathname, which is a sequence of directory
names starting from root (/).
• The subsequent slashes are used to separate the directories
89
pwd – Checking Current Directory
• When user log in ,it is placed in a specific directory of the file
system.
• User files can move from one directory to another, but at a time
files are only in one directory ,known as current directory.
• At a time user is able to know , what is current directory using
pwd, print working directory, command,
• E.g.: $ pwd
• /home/kumar
90
cd - change directory
• User can change directory to a new directory with the cd, change
directory.
• Syntax
• cd [directory]
• Examples
• cd changes to user's home directory
• cd / changes directory to the system's root
• cd .. goes up one directory level
• cd ../.. goes up two directory levels
• cd /full/path/name/from/root changes directory to absolute path
named
• cd path/from/current/location changes directory to path relative
to current location.
91
Examples of cd
1.$ pwd
/home/kumar 3.$ pwd
$cd progs /home/kumar/progs
$pwd $cd
/home/kumar/progs $pwd
*progs must be in current /home/kumar
directory * cd used without arguments
2. $pwd reverts to the home directory
/home/kumar/progs
$cd /bin
$pwd /bin
*requires absolute pathname
,if bin is not in a current directory
92
mkdir – Make Directory
• New directories are created with mkdir make directory
command
• The command is followed by names of the directories to be
created.
• Examples
• mkdir patch Creates a directory patch under current
directory
• mkdir patch dbs doc Creates three directories under current
directory
• mkdir pis pis/progs pis/data
• Creates a directory tree with pis as a directory under the
current directory and progs and data as subdirectories
under pis
93
• The parent directory should be specified first, followed by
the subdirectories to be created under it.
• The system may refuse to create a directory due to the
following reasons:
• 1. The directory already exists.
• 2. There may be an ordinary file by the same name in the
current directory.
• 3. The permissions set for the current directory don’t permit
the creation of files and directories by the user.
94
rmdir - Remove Directory
• The rmdir command is used to remove directories
• A directory needs to be empty before removing it.
• If it’s not, the files need to be removed first.
• a directory can not be removed if it is your present working
directory;
• User need to first change out of that directory.
• e.g.
• rmdir patch Directory must be empty
• rmdir pis pis/progs pis/data Shows error as pis is not empty.
• However rmdir silently deletes the lower level subdirectories
progs and data.
95
ls - List Directory Contents
• It is used to list directories and files .
• With options it can provide information about the size, type
of file, permissions, dates of file creation, change and access.
• Syntax
• ls [options] [argument]
96
Common Options
• When no argument is used, the listing will be of the current directory.
• -a Lists all files, including those beginning with a dot (.).
• -d Lists only names of directories, not the files in the directory
• -F Indicates type of entry with a trailing symbol: executables with *,
directories with / and symbolic links with @
• -R Recursive list
• -x Multicolumnar o/p
• -r Sorts file name in reverse order
• -u Sorts filenames by last access time
• -t Sorts filenames by last modification time
• -i Displays inode number
• -l Long listing: lists the mode, link information, owner, size, last modification
(time).
• If the file is a symbolic link, an arrow (-->) precedes the pathname of the
linked-to file.
97
The UNIX File System
98
99
Assignment 1
1. What is Operating system? Explain functions of OS.
2. Explain history of Unix OS.
3. Explain in detail Unix architecture.
4. Draw and explain kernel and shell relationship.
5. What is process?
6. What is difference between internal and external commands.
7. Explain features of Unix OS
8. Explain following commands : login ,who, ps, tput.
9. How to create a new file in Unix ? Also explain how to modify it.
10. Explain man command in detail
11. What is a file? Explain types of files.
12. Explain parent-child relationship
13. Explain absolute and relative path.
14. Explain ls in details also explain all options with ls.
15. Explain following commands associated with directory
cd, mkdir, rmdir.
100