0% found this document useful (0 votes)
2 views20 pages

Unix M1

The document outlines the salient features of the Unix Operating System, including its multi-user and multi-tasking capabilities, the relationship between the kernel and shell, and the types of files supported in Unix. It also explains the differences between internal and external commands, the parent-child relationship in the Unix file system, and provides examples of various commands. Additionally, it discusses the structure of the Unix file system and the concept of hidden files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views20 pages

Unix M1

The document outlines the salient features of the Unix Operating System, including its multi-user and multi-tasking capabilities, the relationship between the kernel and shell, and the types of files supported in Unix. It also explains the differences between internal and external commands, the parent-child relationship in the Unix file system, and provides examples of various commands. Additionally, it discusses the structure of the Unix file system and the concept of hidden files.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MODULE 1

1. Explain salient features of the Unix Operating System. MQP


SILENT FEATURES OR BASIC FEATURES:-
Multi-user system:
➢ Unix is a multi-user system i.e. multiple user can use the system at a time, resources are
shared between all users.
➢ In unix systems, computer breaks up a unit of time into several segments. So at any point in
time, the machine will be doing the job of a single user. The moment the allocated time
expires, the previous job will be preempted and next user’s job is taken up.
➢ Unix is a multi-programming system, it permits multiple programs to run. This can happen in
two ways:
Multiple user can run separate jobs.
A single user can also run multiple jobs.
Multi-tasking system:
➢ A single user can run multiple tasks concurrently, in multitasking environment.
➢ A user sees one job running in the foreground, the rest running in the background.
➢ It is possible to switch the job between background and foreground, suspend or even
terminate them.
Building block approach:
➢ Unix contains several commands each performs one simple job.
➢ It is possible to connect different with the pipe (|) to get different jobs done.
➢ The commands that can be connected in this way are called filters, because they filter or
manipulate data in different way.
➢ Eg: ls command lists all files.wc command counts the number of words .They can be
combined using pipes(|) to find the total number of files in the directory.
Unix tool kit:
➢ Unix contains set of tools like general purpose tools, text manipulation utilities (called
filters), compilers, interpreters, networked application and system
administration tools.
Pattern matching:
➢ Unix contains pattern matching features, using this features it is possible to match the
different strings.
➢ Eg: ‘*’
$ls chap*
Here ‘*’ is the special character, which matches the filename, which starts with ‘chap’.
Programming facility:
➢ Unix shell is also a programming language. It has control structures, variables, loops that
establish it as a powerful programming language. This features can be used to design a shell
scripts.
Documentation:
➢ Unix contains ‘man’ pages for each command, it contains references for commands and their
configuration files.
2. With a neat diagram explain the kernel and shell relationship in UNIX operating system. Or Explain Unix
architecture with neat diagram. MQP
1. Kernel:
➢ The kernel provides a bridge between the hardware and the user.
➢ It is a software application that is central to the operating system.
➢ The kernel handles the files, memory, devices, processes and the network for the operating
system.
➢ It is the responsibility of the kernel to make sure all the system and user tasks are performed
correctly.
2. Shell:
➢ The program between the user and the kernel is known as the shell.
➢ It translates the many commands that are typed into the terminal session.
➢ These commands are known as the shell script.
➢ There are two major types of shells in Unix.
➢ These are Bourne shell and C Shell.
➢ The Bourne shell is the default shell for version 7 Unix.
➢ The character $ is the default prompt for the Bourne shell.
➢ The C shell is a command processor that is run in a text window.
➢ The character % is the default prompt for the C shell.

Division of labor: Kernel and shell

➢ The main concept in the unix architecture is the division of labor between two agencies the
KERNEL and SHELL.
➢ The kernel interacts with hardware and shell interacts with user.
➢ The kernel is the core of the operating system- a collection of routines mostly written in C.
➢ It is loaded into memory when the system is booted and communicates directly with the
hardware. User applications (programs) that need to access the hardware, uses the services of
kernel. These programs access the kernel through a set of function called system calls.
➢ Apart from providing support to user programs, the kernel also performs other tasks like
managing system’s memory, scheduling processes, decides their priorities etc. So the kernel
is often called the operating system- a program’s gateway to the computer’s resource.
➢ The shell is the command interpreter, it translates command into action.
➢ It is the interface between user and kernel.
➢ System contains only one kernel, but there may be several shells.
➢ When user enters a command through the keyboard the shell thoroughly examines keyboard
input for special characters, if it finds any, it rebuilds simplified command line and finally
communicates with kernel to see that the command is executed.
➢ For eg,consider a echo command which has lots of spaces between the arguments:
➢ Eg: $echo Sun solaris
In the above example shell first rebuilds the command line i.e. it will compress all extra
spaces, then it will produces output.
Sun solaris
The file and process:
➢ Two simple entities supports the unix system is the file and process.
➢ A file is just an array of bytes and can contain virtually anything.
➢ It is also related to another file by being part of a single hierarchical structure.
➢ Files will be arranged in a hierarchical structure in unix system.
➢ A process is the name given to a file when it is executed as program.
➢ So the process is an time image of executable file.
➢ Process are treated as living organism which have parents, children and grand-children and
are born and die.
The system calls:
➢ Unix system’s kernel, shell and applications are written in C.
➢ There are several commands in the unix system, they uses system call functions to communicate
with kernel.
➢ Eg: Unix command writes into the file using write system call.Open system call can be used to open
the file.

3. Explain basic file types in Unix OR Explain different types of files supported in UNIX. MQP
DIFFERENT TYPES OF FILES IN UNIX OR BASIC FILE TYPES OR CATEGORIES:-

1. Ordinary (Regular) File:


An ordinary file or regular file is the most common file type.
An ordinary file itself can be divided into two types:
i) Text File.
ii) Binary File.
Text File:
➢ A Text file contains only printable characters, and you can often view the
➢ contents and make sense out of them.
➢ All C and Java program sources, shell and scripts are text files.
➢ A text file contains lines of characters where every line is terminated with the newline
character, also known as line feed (LF).
Binary File:
➢ A binary file, on the other hand, contains both printable and unprintable
➢ characters that cover the entire ASCII range (0 to 255).
➢ Most UNIX commands are binary files, and the object code and executables that you produce
by compiling C programs are also binary files. Picture, sound and video files are binary files
as well.
2. Directory File:
➢ A directory does not store actual data but holds details of the files and subdirectories it
contains.
➢ The UNIX file system is organized hierarchically with directories and subdirectories. Users
can create directories as needed.
➢ Each directory entry represents a file or subdirectory it contains.
➢ Example: A directory with 20 files will have 20 entries.
➢ Each directory entry includes:
➢ Filename: Name of the file or subdirectory.
➢ Inode Number: A unique identifier assigned to each file or directory.

3. Device File:
➢ Device files represent hardware devices in UNIX.
➢ Example: Used for printing files, installing software, or backing up data.
➢ Device files are stored in the /dev directory.
➢ A device file does not store data but acts as an interface to interact with hardware devices.
➢ Types of device files:
i) Character Device Files:
➢ Represent hardware devices that transfer data character by character.
➢ Used for devices where data is read/written in a continuous stream.
➢ Eg:- Keyboards, mice, terminals, and serial ports.
➢ Data is transferred one character at a time without buffering.
➢ Typically found in the /dev directory (e.g., /dev/tty1 for a terminal).
ii) Block Device Files:
➢ Represent hardware devices that transfer data in blocks (fixed-size chunks).
➢ Used for storage devices where data is accessed randomly.
➢ Eg:- Hard drives, USB drives, and CD-ROMs.
➢ Data is buffered, improving performance for large transfers.
➢ Typically found in the /dev directory (e.g., /dev/sda for a hard disk).

➢ These files are crucial for organizing the file system and interacting with hardware devices
efficiently

4. Difference between Internal & External commands with an example. MQP


Internal and External Commands in UNIX

Internal Commands
➢ Built into the shell itself.
➢ Do not exist as separate executable files.
➢ Faster to execute as they run directly in the shell.
➢ Example:
➢ $ type echo
➢ echo is a shell builtin
➢ Here, echo is an internal command.
External Commands
➢ Independent executables stored in directories like /bin or /usr/bin.
➢ Found and executed by the shell using the PATH variable.
➢ Slower to execute compared to internal commands.
➢ Example:
➢ $ ls
➢ /bin/ls
➢ The ls command is an external command.
Shell Precedence
➢ If a command exists as both internal and external, the shell prioritizes the internal version.
➢ Example: The echo command is both internal and external, but the shell uses its internal
version.
Command Arguments
➢ Commands can accept arguments in different forms:
➢ Expression: Example in grep: grep "pattern" file.
➢ Instructions: Example in sed: sed 's/old/new/g' file.
➢ Program: Example in awk: awk '{print $1}' file.
Example:
➢ Internal Command: cd (Change Directory)
Usage: cd Documents changes the working directory to "Documents."
➢ External Command: ping (Test network connection)
Usage: ping google.com checks connectivity to Google's server.

This classification optimizes shell performance and ensures efficient command usage.

Difference Between Internal and External Commands:


Aspect Internal Commands External Commands
Built into the operating system's shell Stored as separate executable
Definition
or command processor. files on the disk.
Does not require disk access; Requires disk access to locate
Execution
executed directly by the shell. and execute the file.
Slower due to the need for disk
Speed Faster as they are part of the shell.
access.
Always available as long as the shell Requires the external file to be
Availability
is running. present on the system.
Examples dir, cd, copy, echo, del. format, diskpart, ping, xcopy.

5. What is Parent child relationship? With the help of neat diagram, explain Unix File System
PARENT-CHILD RELATIONSHIP
➢ All files in unix are related to one another.
➢ The file system is organized in a hierarchical structure.
➢ The implicit feature of unix file system is that there is a top directory which is called as root
which serves as the reference point for all files.
➢ Top is represented by a /(front slash).
➢ Root directory(/) has several sub directories under it.
➢ These subdirectories in turn have more sub directories and other files under them.
• Ex: bin and usr are two directories directly under /, while cp and pwd are
subdirectories under bin.
➢ Every file must have a parent and it should be possible to trace the ultimate parentage of a
file to root.
➢ Thus, the home directory in the above figure is the parent for mthomas, while / is the parent
of home and the grand parent of mthomas.
➢ In the parent-child relationship, the parent is always a directory.
• Ex: login.sql is an ordinary file, it cannot have a directory under it.
UNIX FILE SYSTEM

Directories or Files and their description:

Data is organized into files and files into directories and directories into tree like structure.

i. / : The slash / character alone denotes the root of the filesystem tree.
ii. /bin : Stands for “binaries” and contains certain fundamental utilities, such as ls or cp, which are
generally needed by all users.
iii. /boot : Contains all the files that are required for successful booting process.
iv. /dev : Stands for “devices”. Contains file representations of peripheral devices and pseudo-devices.
v. /etc : Contains system-wide configuration files and system databases. Originally also contained
“dangerous maintenance utilities” such as init,
vi. /home : Contains the home directories for the users.
vii. /lib : Contains system libraries, and some critical files such as kernel modules or device drivers.
viii. /media : Default mount point for removable devices, such as USB sticks, media players, etc.
ix. /root : The home directory for the superuser “root” – that is, the system administrator. This
account’s home directory is usually on the initial filesystem, and hence not in /home (which may
be a mount point for another filesystem) in case specific maintenance needs to be performed, during
which other filesystems are not available. Such a case could occur, for example, if a hard disk drive
suffers physical failures and cannot be properly mounted.
x. /tmp : A place for temporary files. Many systems clear this directory upon startup; it might have
tmpfs mounted atop it, in which case its contents do not survive a reboot, or it might be explicitly
cleared by a startup script at boot time.
xi. /usr : Originally the directory holding user home directories,its use has changed. It now holds
executables, libraries, and shared resources that are not system critical, like the X Window System,
KDE, Perl, etc. However, on some Unix systems, some user accounts may still have a home
directory that is a direct subdirectory of /usr, such as the default as in Minix. (on modern systems,
these user accounts are often related to server or system use, and not directly used by a person).
xii. /usr/bin : This directory stores all binary programs distributed with the operating system not
residing in /bin, /sbin or (rarely) /etc.
xiii. /usr/include : Stores the development headers used throughout the system. Header files are mostly
used by the #include directive in C/C++ programming language.
xiv. /var : A short for “variable.” A place for files that may change often – especially in size, for example
e-mail sent to users on the system, or process-ID lock files.
xv. /var/spool : Spool directory. Contains print jobs, mail spools and other queued tasks.
xvi. /var/tmp : A place for temporary files which should be preserved between system reboots.

The Home Variable and The Home Directory:


➢ When we log on to the system, UNIX automatically places you in a directory called the home
directory. It is called by the system when a user account is opened.
➢ If you log in using the login name Kumar, you will land up in a directory that could have the
pathname /home/kumar.
➢ Home directory can be changed by the user.
➢ The shell variable HOME knows your home directory.
o E: $echo $HOME
▪ /home/Kumar
➢ The above output is an absolute pathname. • The slashes act as a delimiter to the file and
directory names except the first /(root).
Hidden Files:
➢ To show all the hidden files in the directory, use ‘-a option’. Hidden files in Unix starts with
‘.’ in its file name.It will show all the files including the ‘.’ (current directory) and ‘..’
(parent directory).
➢ ls
–a

6. Write the output for the following commands. (THEY CAN EVEN AS THE SAME FOR OTHER
COMMANDS TOO)

i. cal 10 2021
Displays the calendar for October 2021.
October 2021
Su Mo Tu We Th Fr Sa
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

ii. date + “%D%T”


Displays the current date and time in the format: MM/DD/YY HH:MM:SS.
01/18/25 09:30:15

iii. type echo


Identifies whether echo is a built-in or an external command.
echo is a shell builtin

iv. passwd
Prompts the user to change their password.
Changing password for <username>.
Current password:
New password:
Retype new password:

v. who
Displays information about users currently logged into the system.
username tty1 2025-01-18 09:00
username pts/0 2025-01-18 09:15 (192.168.1.10)

STUDY ALL THE COMMANDS GIVEN BELOW: -

DIRECTORY COMMANDS, BASIC COMMANDS, FILE RELATED COMMANDS.


(VVIMP)
f_P.._•No_Y_
Oare
____,]
-r V 1Jl.,.t51-
_,_
J
" {) Q_~
\ --)

. -j vi ___o --

\ n ➔
·e '1
..· . 0./\
,.
@...
r
~ _
... -

~9
\ 4 Q,

\ r- ➔ A- <I c..aa,
) -d)
;~ o
, .... Nnz
Date/
I

+ 1/.. ---)

t"/. nJZ.
-f 1/· y -) ~

f 1/. . -." \

-+

·0,\.a~-
'· ···-·


- .P
r cJO : r:J C: o)
/ -o ··
)

Po iwJ
Date/
l

l . \ ,-
I (

0 . f}
~ \ • I

.)
)t (_Q_ cWI\. ()~(r.t: . flit (}-

0-Y\..CL. 0 G .('.p, \·&'\ (] 1-''/\,( tL,(

G\..P-4__ --~

- \I f\£),-,V'

- r\ (j
,
,, ·.,,

..._

(J
/ -) ~
If)
)l ~

..}¥. CQp;; •I, f} 1


r N_oz_ ___;/
~•--'-ge
Date

- {V\\/

. \ 0

You might also like