Unit 3
Unit 3
in
in
y.
Orientation to Computing-I
ud
st
ty
si
er
iv
L T P :2 0 0
un
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.
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
in
y.
ud
st
ty
si
er
iv
un
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
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
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
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
Device files are essential for interacting with hardware components and
are located in the /dev directory on Unix-like systems.
in
y.
ud
st
ty
si
er
iv
un
in
y.
ud
st
ty
si
er
iv
un
in
y.
ud
st
ty
si
er
iv
un
in
–
y.
HDFS
ud
– DFS
–
st
UDF
ty
– Extended file system
– NTFS
si
er
iv
un
• 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
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
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
in
y.
ud
st
ty
si
er
iv
un
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
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
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
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
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
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
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
Use of grep
in
y.
ud
st
ty
si
er
iv
un
in
y.
ud
st
ty
si
er
iv
un
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
in
y.
ud
st
ty
si
er
iv
un
Description of Signals
in
y.
ud
st
ty
si
er
iv
un
Linux Signals
in
y.
ud
st
ty
si
er
iv
un
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
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
Adding/Deleting a Path
• Using the export command, new path can be added.
in
y.
ud
st
ty
si
er
iv
un
• Activity
in
y.
• Add to the path in Windows
ud
st
ty
si
er
iv
un
in
cat
•
y.
• man rm
ud
• cd • chmod
• •
st
touch pwd
•
ty
• cp ps
si
• mv er • kill
iv
un
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
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
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
• 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.
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
Touch
The touch command's
in
primary function is to
y.
modify a timestamp.
ud
st
ty
si
er
iv
un
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
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.
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
• Activity
in
y.
• Execute various commands on Linux Operating System
ud
st
ty
si
er
iv
un
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
in
y.
ud
st
ty
si
er
iv
un
in
y.
ud
st
ty
si
er
iv
un
• 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
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
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
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
in
y.
ud
st
ty
si
er
iv
un