0% found this document useful (0 votes)
22 views52 pages

Unit 3

Uploaded by

0176rahulsharma
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)
22 views52 pages

Unit 3

Uploaded by

0176rahulsharma
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

www.universitystudy.

in

in
y.
Orientation to Computing-I

ud
st
ty
si
er
iv

L T P :2 0 0
un

www.lpu.in Lovely Professional University


www.universitystudy.in
1
www.universitystudy.in

Unit 3
File system management
File system management :

in
File system basics, Types of file systems( FAT, NTFS, GFS, HDFS, DFS,

y.
UDF, Extended file systems), Pipes and redirection, Searching the file

ud
system using find and grep with simple regular expressions, Basic process
control using signals, pausing and resuming process from a Linux terminal,

st
terminating a process, Adding/removing from search path using PATH

ty
variable.
si
er
Other Shell commands:
iv
un

ls, cat, man, cd, touch, cp, mv, rmdir, mkdir, rm, chmod, pwd, ps, kill, etc,
Kernel and types of kernels.

www.lpu.in Lovely Professional University


www.universitystudy.in
2
www.universitystudy.in

Understanding File System


• File system is a structure used to organize data and programs on computer
storage devices.

in
y.
• It keeps track of the physical locations of all data elements on disk and

ud
allows users to quickly and reliably retrieve files when needed.

st
• Every operating system, from MS-DOS to Windows 95, Windows XP and

ty
Linux, has its own file system.
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
3
www.universitystudy.in

Representation of File System

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
4
www.universitystudy.in

File can be..


• Regular files
• Directory Files
• Device Files or Special Files

in
y.
ud
• Regular Files stores data (text, binary, and executable)

st
• Directory files contains information used to access other files.

ty
• Device Files defines a FIFO (first-in, first-out) pipe file or a
physical device
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
5
www.universitystudy.in

File can be..


Regular files

in
Regular files, also known simply as files, are the most

y.
common type of files found in a Unix-like file system. These

ud
files contain data, such as text, images, videos, or program

st
code. When we create or edit a document, write a script, or

ty
si
create any other type of content, we are working with a
er
regular file.
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
6
www.universitystudy.in

File can be..


Directory files
Directory files are special files that store

in
information about files and other directories within

y.
a specific directory. In simpler terms, directories

ud
are folders that contain lists of file names and their

st
corresponding inode numbers (unique identifiers

ty
si
for files). When we create a new directory, we are
er
creating a directory file. Directories provide the
iv
structure and organization for the file system,
un

allowing users to organize files into a hierarchical


structure.

www.lpu.in Lovely Professional University


www.universitystudy.in
7
www.universitystudy.in

File can be..


Device files
Device files, also known as special files, represent devices attached to
the system, such as hard drives, printers, or terminals. There are two
types of device files: block devices and character devices.

in
y.
Block Devices: These devices read and write data in fixed-size blocks.

ud
Examples include hard drives, SSDs, and USB drives. Block devices are

st
used for storing and retrieving data in chunks, making them suitable for

ty
file systems.

si
er
Character Devices: These devices transfer data character by character,
iv
like keyboards, mice, or serial ports. Character devices are used for
un

devices that transfer data one character at a time.

Device files are essential for interacting with hardware components and
are located in the /dev directory on Unix-like systems.

www.lpu.in Lovely Professional University


www.universitystudy.in
8
www.universitystudy.in

File System Representation

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
9
www.universitystudy.in

Popular File System

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
10
www.universitystudy.in

Useful Symbols for Files

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
11
www.universitystudy.in

Types of File Systems


• Following are the various file system in a device:
– FAT
– GFS

in

y.
HDFS

ud
– DFS

st
UDF

ty
– Extended file system
– NTFS
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
12
FAT File System
www.universitystudy.in

• FAT
– Full form is file allocation table
– One of the oldest file systems available on the windows machine.
– Introduced on ms-dos 7.1 / windows 95 in 1996

in
– Developed for floppy disks but later used on hard drive, USB flash

y.
drives, and SSD cards.

ud
– Until windows xp, it was default file system

st
– FAT8, FAT12, and FAT16, FAT32 are its variations. Each has an

ty
increasing number of clusters, and maximum file and volume sizes.

si
er
iv
un

Structure of FAT32 File


www.lpu.in Lovely Professional University
www.universitystudy.in
13
www.universitystudy.in

FAT32 contd..
Advantages:
• Can hold up to 268,173,300 files
• The backup FAT table copy gets automatically relocated to the root folder

in
in FAT32 systems, which further can be used for the restoration of files.

y.
• Drive sizes are between 2 and 16 tb with 64kb clusters.

ud
• Is the official format for sd and sdhc cards.

st
ty
si
Limitations: er
• Each file can have a maximum size of 4GB (GigaBytes).
iv
• No control over file permissions and data security.
un

• The native disk’s maximum disk size for FAT32 is 32 GB. It is possible to
expand it up to 2TB.
• FAT32 is no longer used on modern, internal Windows hard drives as most
systems have adopted the NTFS standard.
www.lpu.in Lovely Professional University
www.universitystudy.in
14
www.universitystudy.in

NTFS (New Technology File


System)
• NTFS:-

in
• Current Windows versions beginning

y.
with Windows XP — use the NTFS

ud
file system to partition their code.
• It is possible to format external drives

st
with either FAT32 or NTFS.

ty
• File size limit of 16 exabytes
si
er
• Supports file permissions and
iv
encryption.
un

www.lpu.in Lovely Professional University


www.universitystudy.in
15
www.universitystudy.in

Differences between FAT32, exFAT,


and NTFS File Systems.

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
16
www.universitystudy.in

HFS File System


• A file with the HFS file extension is an HFS disk image file.
• Known as Hierarchical File System

in
y.
• Used to store the files on floppy disks, CD-ROM discs, and hard drives of

ud
older Apple Macintosh computers.
• In 2017, Apple File System (APFS) was launched.

st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
17
www.universitystudy.in

Btrfs
• Btrfs — "better file system" — is a newer, still in development, Linux file
system.

in
• It is a copy-on-write (CoW) filesystem.

y.
• When data is modified in a CoW system, a new copy of the modified data

ud
is created, leaving the original data unchanged. This means that if multiple

st
processes or users are accessing the same data and one of them wants to

ty
modify it, the system creates a copy of the data, applies the modification
si
to the copy, and the process making the change operates on the copied
er
data. This way, the original data remains intact, and only the modified
iv
version is stored as a new file.
un

• The goal is to provide additional features that allow Linux to scale up to


larger storage amounts.

www.lpu.in Lovely Professional University


www.universitystudy.in
18
www.universitystudy.in

Ext2/Ext3/Ext4 File System


• In 1992 the Extended File System (ext) was launched for Linux
• On Ubuntu, you will often see the file systems Ext2, Ext3, and Ext4.

in
• If the power is gone or a device crashes when writing to an ext2 disk, data

y.
may be lost.

ud
• Ext3 provides these features of robustness at the expense of some speed.

st
• Ext4 is simpler and more modern, it's now the default file system on most

ty
Linux distributions, and it's faster.
si
• Such file systems are not supported by Windows and Mac.
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
19
www.universitystudy.in

Concept of Pipes and Redirection


A pipe is a connection between two processes, such that the standard output
from one process becomes the standard input of the other process.

in
y.
In UNIX Operating System, Pipes are useful for communication between

ud
related processes(inter-process communication).
Although pipe can be accessed like an ordinary file, the system actually

st
manages it as FIFO queue.

ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
20
www.universitystudy.in

Concept of Redirection
Redirection is for files (you redirect streams to/from files).
One common need when we run applications is to direct the output

in
into a file instead of the terminal. A redirect sends a channel of

y.
output to a file.

ud
st
This is typically done with the > operator between the application to

ty
run and the file to write the output into. For example, we can send

si
the output of the ls command into a file called files as follows:
er
$ ls > files
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
21
www.universitystudy.in

Searching the File System


• Use command- find

in
– It search for files in a directory hierarchy under Linux and

y.
all other UNIX like operating systems.

ud
– Examples:

st
• find . - name thisfile.txt. ...

ty
• find /home -name *.jpg. Look for all . ...
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
22
www.universitystudy.in

Searching the File System contd..


Use command- grep
• Grep is an acronym that stands for Global Regular Expression

in
y.
Print.

ud
The grep command searches through the file, looking for matches to
the pattern specified.

st
Grep is case-sensitive.

ty
si
er
Example:
iv
grep myname biodata
un

• Here biodata is file and myname is specific pattern for searching in


biodata file

www.lpu.in Lovely Professional University


www.universitystudy.in
23
www.universitystudy.in

Use of grep

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
24
www.universitystudy.in

Use of grep contd..

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
25
www.universitystudy.in

Process Signals
• A signal is basically a one-way notification.
• A signal can be sent by the kernel to a process, by a process to another

in
y.
process, or a process to itself.

ud
• Signals are one of the ways process communicate among themselves and
with the kernel.

st
• The list of the most commonly used signals follow:

ty
• SIGTERM: Surprisingly, the default signal sent by kill command.
si
er
• Asks the process to terminate voluntarily.
iv
• SIGKILL: unlike SIGTERM, forces the process to terminate.
un

• Can't be blocked or handled.


• SIGSTOP: suspend the process execution.

www.lpu.in Lovely Professional University


www.universitystudy.in
26
www.universitystudy.in

Process Signals contd..

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
27
www.universitystudy.in

Description of Signals

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
28
www.universitystudy.in

Linux Signals

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
29
www.universitystudy.in

Kill command
– The killall is a Linux only command. It kills processes by names.
– Examples:

in
y.
• killall {Process-Name-Here}

ud
• killall -9 {Process-Name-Here}

st
• killall -15 {Process-Name-Here}

ty
• kill the process using a PID (Process ID)
– # kill 3486
si
er
PID can be searched using pgrep command
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
30
www.universitystudy.in

Path Variable
• It displays or set a search path for executable files at the command line.
• Syntax PATH pathname [;pathname] [;pathname] [;pathname]... PATH

in
y.
PATH ; Key pathname : drive letter and/or folder ; : the command 'PATH ;'

ud
will clear the path PATH without parameters will display the current path.
• The %PATH% environment variable contains a list of folders.

st
ty
• The PATH variable is an environment variable containing an ordered
si
er
list of paths that Linux will search for executables when running a
iv
command.
un

– For example, if we want to print Hello, world! in Bash, the


command echo can be used rather than /bin/echo, so long as /bin is in
PATH:

www.lpu.in Lovely Professional University


www.universitystudy.in
31
www.universitystudy.in

Adding/Deleting a Path
• Using the export command, new path can be added.

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
32
www.universitystudy.in

• Activity

in
y.
• Add to the path in Windows

ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
33
www.universitystudy.in

Other Shell Commands:


• ls • rmdir
• • mkdir

in
cat

y.
• man rm

ud
• cd • chmod
• •

st
touch pwd

ty
• cp ps

si
• mv er • kill
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
34
www.universitystudy.in

ls command
• The ls command is used to list files or directories in Linux and other Unix-

in
based operating systems.

y.
• Use of ls command as below:

ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
35
www.universitystudy.in

cat command
• Outputs the contents of a text file.

in
• You can use it to read brief files or to concatenate files together.

y.
ud
• To append file1 onto the end of file2, enter:
• cat file1 >> file2

st
• To view the contents of a file named myfile, enter:

ty

si
cat myfile er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
36
www.universitystudy.in

man command
• The man command is a built-in manual for using Linux commands.
• Displays the user manual of any command that we can run on the terminal.

in
It provides a detailed view of the command which includes NAME,

y.
SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN

ud
VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS.

st
• Basic Symbol

ty
si
er
iv

• option – the search result output.


un

• section number – the section in which to look for the man page.
• command name – the name of the command which man page you want to
see.

www.lpu.in Lovely Professional University


www.universitystudy.in
37
www.universitystudy.in

cd command
• It changes your current directory location.

in
• By default, your Unix login session begins in your home directory.

y.
ud
• To switch to a subdirectory (of the current directory) named myfiles, enter:
• cd myfiles

st
• To switch to a directory named /home/dvader/empire_docs, enter:

ty
si
• cd /home/dvader/empire_docs er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
38
www.universitystudy.in

Touch
The touch command's

in
primary function is to

y.
modify a timestamp.

ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
39
www.universitystudy.in

cp
• This command copies a file, preserving the original and creating an
identical copy.

in
– cp -i oldfile newfile

y.
ud
mv
mv stands for move.

st
ty
mv is used to move one or more files or directories from one place to
another in a file system like UNIX.
si
er
Use it as:
iv
mv [Option] source destination
un

chmod
• This command changes the permission information associated with a
file.
www.lpu.in Lovely Professional University
www.universitystudy.in
40
www.universitystudy.in

Mkdir
• The mkdir command is used to create (or make) a directory.
• Example:

in
• # mkdir LPUCSE

y.
ud
rmdir

st
• The rmdir directory is used to remove directories, but only those that are

ty
si
empty (i.e., contain no files or subdirectories). In order to delete a directory
er
with actual contents, you must use the rm -R command.
iv
• Example
un

• To remove an empty directory:


• # rmdir /mike

www.lpu.in Lovely Professional University


www.universitystudy.in
41
www.universitystudy.in

Rm
Use the rm command to remove files you no longer need.
Example
Removing one file at a time
$ rm CSEA.txt

in
y.
Pwd

ud
Simply type pwd into your terminal, and the command will output the absolute

st
path of your print working directory.

ty
The pwd command writes to standard output the full path name of your current
si
directory (from the root directory). All directories are separated by a /
er
(slash). The root directory is represented by the first /, and the last directory
iv
named is your current directory.
un

The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a
Linux system.

www.lpu.in Lovely Professional University


www.universitystudy.in
42
www.universitystudy.in

ps
The ps command, short for Process Status, is a command line utility that is
used to display or view information related to the processes running in a

in
Linux system.

y.
ud
kill

st
kill command in Linux (located in /bin/kill), is a built-in command which is

ty
used to terminate processes manually.
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
43
www.universitystudy.in

• Activity

in
y.
• Execute various commands on Linux Operating System

ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
44
www.universitystudy.in

Kernel and types of kernels


• A Kernel is an intermediary between applications and hardware.
• Functions of a Kernel
A Kernel in an operating system performs the following functions:

in
• Device Management: Processes require various peripheral devices such as

y.
a mouse and keyboard connected to the computer to perform various tasks.

ud
The Kernel manages the allocation of the peripheral devices.

st
• Resource Management: Kernel shares the resources between different

ty
processes while ensuring that every process has uniform access to the
resources.
si
er
• Memory Management: Every process requires some memory to execute.
iv
The Kernel allows the processes to access the memory safely.
un

• Access Computer Resource: A kernel can access different computer


resources such as RAM, CPU, I/O devices, and other resources. The Kernel
decides which memory each process will use, and the action is taken if
memory is unavailable.
www.lpu.in Lovely Professional University
www.universitystudy.in
45
www.universitystudy.in

More about Linux Kernel

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
46
www.universitystudy.in

More about Linux Kernel

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
47
www.universitystudy.in

Basic types of kernels


• 3 basic types of kernels as below:

• Monolithic

in
• Microkernel

y.
• Hybrid

ud
st
• A monolithic kernel is a type of kernel in which the complete OS runs in

ty
the kernel space.
si
er
• A microkernel is a kernel type that implements an operating system by
iv
providing methods, including low-level address space management, IPC,
un

and thread management.


• A hybrid kernel is an operating system kernel architecture that attempts to
combine aspects and benefits of microkernel and monolithic kernel
architectures used in computer operating systems.

www.lpu.in Lovely Professional University


www.universitystudy.in
48
www.universitystudy.in

Basic types of kernels


• Monolithic Kernel

in
• In a monolithic kernel, most operating system functions are

y.
tightly integrated into a single, large software module. This

ud
includes core services like process management, memory

st
management, file systems, and device drivers. Example of

ty
operating system with monolithic kernel is Linux.
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
49
www.universitystudy.in

Basic types of kernels


• Micro Kernel

in
• A microkernel takes a different approach by keeping the core

y.
functionality minimal. It only includes essential services like

ud
process scheduling and inter-process communication.

st
Additional functionalities, such as file systems and device

ty
drivers, are implemented as separate user-space modules.
si
This design aims to improve system stability and security by
er
minimizing the code that runs in kernel mode. Examples of
iv
un

operating systems with microkernels include MINIX and QNX.

www.lpu.in Lovely Professional University


www.universitystudy.in
50
www.universitystudy.in

Basic types of kernels


• Hybrid Kernel

in
• Hybrid kernels combine aspects of both monolithic and

y.
microkernels. They include a core set of essential services in

ud
the kernel, similar to a microkernel, but also allow some non-

st
essential services to run in kernel mode for improved

ty
performance. Windows NT and its derivatives, like Windows
si
10, are examples of operating systems with hybrid kernels.
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
51
www.universitystudy.in

Basic types of kernels

in
y.
ud
st
ty
si
er
iv
un

www.lpu.in Lovely Professional University


www.universitystudy.in
52

You might also like