You are on page 1of 6

Unix shell

programming
IV SEMESTER
Unix shell
programming
IV SEMESTER Unix shell programming

Q1. What is the use of WHO Command?


Ans: WHO command provides the login details of all the current users in the system.
Syntax : $who [options] [filename]

who command is used to find out the following information :


1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
Description : The who command is used to get information about currently logged in
user on to system.
Syntax : $who [options] [filename]
Examples :
1. The who command displays the following information for each user currently logged
in to the system if no option is provided :
1. Login name of the users
2. Terminal line numbers
3. Login time of the users in to system
4. Remote host name of the user

Q2. List different parts of Unix File System.


Ans: Classification of Unix File System:
1. Ordinary File or Regular Files
2. Directory Files
3. Device Files or Special Files
Q3. Mention different States of a Process.
A process is an instance of a program in execution. A set of processes combined together make
a complete program.

Process States

The states that a Process enters in working from start till end are known as Process states.
These are listed below as:
 New- The process is newly created and is in transition state. The process exists, but
it is not ready to run nor it is in sleeping.
 User running-Process is running in user mode which means it is a user process.
 Kernel Running-Indicates process is a kernel process running in kernel mode.
 Zombie- Process does not exist/ is terminated.
 Preempted- When process runs from kernel to user mode, it is said to be
preempted.
 Ready to run in memory- It indicated that process has reached a state where it is
ready to run in memory and is waiting for kernel to schedule it.
 Ready to run, swapped– Process is ready to run but no empty main memory is
present
 Sleep, swapped- Process has been swapped to secondary storage and is at a blocked
state.
 Asleep in memory- Process is in memory(not swapped to secondary storage) but is
in blocked state.
The numbers indicate the steps that are followed.

Process Transitions

The working of Process is explained in following steps:


1. User-running: Process is in user-running.
2. Kernel-running: Process is allocated to kernel and hence, is in kernel mode.
3. Ready to run in memory: Further, after processing in main memory process is
rescheduled to the Kernel.i.e.The process is not executing but is ready to run as
soon as the kernel schedules it.
4. Asleep in memory: Process is sleeping but resides in main memory. It is waiting
for the task to begin.
5. Ready to run, swapped: Process is ready to run and be swapped by the processor
into main memory, thereby allowing kernel to schedule it for execution.
6. Sleep, Swapped: Process is in sleep state in secondary memory, making space for
execution of other processes in main memory. It may resume once the task is
fulfilled.
7. Pre-empted: Kernel preempts an on-going process for allocation of another
process, while the first process is moving from kernel to user mode.
8. Created: Process is newly created but not running. This is the start state for all
processes.
9. Zombie: Process has been executed thoroughly and exit call has been enabled.
The process, thereby, no longer exists. But, it stores a statistical record for the
process.
This is the final state of all processes.
Q4. Define Inode.
-it is a data structure which has Information about each file, kept in special kernel
structure called an inode.
Inode contains the following information:
 File owner Id(UID) – id used to identify the file
 Group id(GUID) – (indicates group) file owner grants access to the group by
giving id.
 File type – if file exist, then inode exists else return 0 (file closed).
Q5. Explain process creation in unix or explain the mechanism of process.
Ans:
 A process creates new process, the new process created are called child process, the child
process is created by parent process.
 A process may be created during system initialization or during execution of a program
using fork().
 Child process is an identical copy of a parent process.
 Parent process work parallel with the child or waits until child executes.

Q6. Explain Unix architecture with a neat diagram.


Unix architecture consist of
 Layer-1: Hardware – 
It consists of all hardware related information. 
 Layer-2: Kernel – 
It interacts with hardware and most of the tasks like memory management, task
scheduling, and management are done by the kernel. 
 Layer-3: Shell commands – 
Shell is the utility that processes your requests. When you type in a command at the
terminal, the shell interprets the command and calls the program that you want.  
There are various commands like cp, mv, cat, grep, id, wc, nroff, a.out and more.  
Layer-4: Application Layer – 
It is the outermost layer that executes the given external applications.
OR
1)hardware
2) The Kernel
3) The Shell
4) Files and Processes
5) System Calls

1)Hardware: it is a physical components like CPU, monitor etc.,


2)Kernel:
 It acts as an interface between shell and hardware.
 It works with the hardware on behalf of user, as user cannot directly interact with
Hardware.
 It performs low level task like scheduling, synchronization etc.,
 It is an hear of the operating system

3) Shell:
 It is an interface between kernel and user.
 Shell is a collection of commands; the commands satisfy user requirement.

4) Files and Process


 A File is an array of bytes.
 A Process is a program file under execution.
5) System Calls
 Thousands of commands in the system given set of different functions called
system calls.

You might also like