0% found this document useful (0 votes)
12 views10 pages

Week 3 OSA

The document provides an overview of file systems, particularly in UNIX, detailing their structure, types, and navigation methods. It explains file attributes, access control lists (ACLs), and commands for file manipulation, including appending text and comparing files. Additionally, it covers various file types, including ordinary, directory, special files, pipes, sockets, and symbolic links.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Week 3 OSA

The document provides an overview of file systems, particularly in UNIX, detailing their structure, types, and navigation methods. It explains file attributes, access control lists (ACLs), and commands for file manipulation, including appending text and comparing files. Additionally, it covers various file types, including ordinary, directory, special files, pipes, sockets, and symbolic links.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

WEEK-03

INTRODUCTION

 A file system is a method of organizing and retrieving files from a


storage medium (e.g., hard drive).
 File systems usually consist of files separated into groups called directories.
Directories can contain files or additional directories.
 The most commonly used file system with Windows is NTFS.
 Files are most often managed in a hierarchy, which allows to view files in
the current directory and then navigate into any subdirectories.

Examples of file systems:


1. exFAT (Extensible File Allocation Table)
2. FAT (e.g., FAT16 and FAT32) (File Allocation Table)
3. GFS (Global File System)
4. HFS (Hierarchical File System)
5. NTFS (New Technology File System)
6. UDF (Universal Disk Format)
File is a container for storing information. UNIX treats directories and devices as
files.
Generally, files are classified into three categories:
1. Ordinary(regular) Files: Contains only data as a stream of characters.
2. Directory Files: It contains names of files and directories and a
DEPT. OF CSE, SLVP, HASSAN Page |1
OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

number associated with each name.


3. Device Files: All devices and peripherals are represented as files.

PATH NAMES:
 A sequence of symbols and names that identifies a file.
 Every file has a name, called a filename, so the simplest type of pathname is
just a filename.
 If we specify a filename as the pathname, the operating system looks for that
file in our current working directory.
 However, if the file resides in a different directory, we must tell the operating
system how to find that directory.
 We need do this by specifying a path that the operating system must follow.

 Pathnames are classified into Absolute and Relative Pathnames.


 Absolute Path: Where the first character of the pathname is ‘/’
Eg: cat /home/kumar/[Link]
 Relative Path: Where the first character of the pathname is not ‘/’
Eg: cd progs
cat [Link]
cd progs/scripts
 A relative pathname uses following cryptic symbols:
a. . (a single dot) – This represents the current directory.
b. .. (two dots) – This represents the parent directory.
Eg: cp ../sharma/profile . – This copies the file profile to the current directory.

FILE SYSTEM:
 It is a collection of all related files (ordinary, directory and device files)
organized in a hierarchical structure.
DEPT. OF CSE, SLVP, HASSAN Page |2
OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

 This system is also adopted by DOS and Windows.

UNIX File System Tree


 /: The topmost directory is called root directory represented as ‘/’, which has
many subdirectories or files under it.
 /bin: Stands for “binaries” and contains certain fundamental utilities, such
as ls or cp, which are generally needed by all users.
 /boot: Contains all the files that are required for successful booting process.
 /dev: Stands for “devices”. Contains file representations of peripheral
devices and pseudo-devices.
 /etc: Contains system-wide configuration files and system databases.
 /home: Contains the home directories for the users.
 /lib: Contains system libraries, and some critical files such as kernel
modules or device drivers.
 /media: Default mount point for removable devices, such as USB
sticks, media players, etc.
 /mnt: Stands for “mount”. Contains filesystem mount points. These are used,
for example, if the system uses multiple hard disks or hard disk partitions. It
is also often used for remote (network) filesystems, CD-ROM/DVD drives,
etc.
 /proc: procfs virtual filesystem showing information about processes as files.
 /root: The home directory for the superuser “root” – that is, the system
administrator.
 /tmp: A place for temporary files. Many systems clear this directory upon
startup.
 /usr: Originally the directory holding user home directories. It also holds
executables, libraries, and shared resources that are not system critical, like the
DEPT. OF CSE, SLVP, HASSAN Page |3
OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

X Window System, KDE, Perl, etc.


 /usr/bin: This directory stores all binary programs distributed with the
operating system not residing in /bin, /sbin or (rarely) /etc.
 /usr/include: Stores the development headers used throughout the system.
Header files are mostly used by the #include directive in C/C++ programming
language.
 /usr/lib: Stores the required libraries and data files for programs stored within
/usr or elsewhere.
 /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.
 /var/log: Contains system log files.
 /var/mail: The place where all the incoming mails are stored. Often, this
directory is a symbolic link to /var/spool/mail.
 /var/spool: Spool directory. Contains print jobs, mail spools and other queued
tasks.
 /var/tmp: A place for temporary files which should be preserved
between system reboots.
NAVIGATION:
 Moving from one location to another in a file system is called a navigation.
 Navigation in Unix is the same as pointing and clicking in a typical
graphical user interface.
Eg: If you have the folder “ExperimentFolder” on my Desktop, you can point
and double-click to open it.
You can do the same thing by typing cd ~/Desktop/ExperimentFolder in the
Terminal and then typing ls to see what’s in the directory.
FILE TYPES:
 In Unix Operating System, all data is organized into files, each file is
organized into directories, and these directories are organized in a tree
like structure called a File System.
 Following are the types of files in UNIX

DEPT. OF CSE, SLVP, HASSAN Page |4


OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

1. Ordinary Files
 Ordinary files are the files in Unix, which includes program instructions, text,
and data.
 In ordinary files, there are no other files.
 Ordinary files are always placed under the directory file.
 In the long-format output of ls -l, the "-" symbol is used to specified such kind
of file.
2. Directory
 Directory store both special as well as ordinary files.
 Unix directories are equivalent to the folders of Mac or Windows.
 A directory file includes an entry file for each file and a subdirectory which
it houses.
 If there are 5 files in a directory, then there will be 5 entries in the
directory. Every entry comprises of 2 components.
1. The name of the File.
2. An inode number, which is a unique identification number for the file
or directory.
 Each file is descendant of the root directory (named /) located at the tree's top.
 In the long-format output of ls -l, we used the "d" symbol in order to specify
this kind of file.
3. Special Files
 We use special files to represent the real physical device like terminal,
tape drive, and printer. and also used for Input/Output(I/O) operations.
 Special files or devices are used for Input/Output(I/O) on Linux and Unix
systems.
 They look as similar to the ordinary file or directory in a file system.
 Mainly two kinds of special files for every device in the Unix system are there
such as block special files and character special files.
1. If we use the block special file for the device input/output (I/O),
the data is moved to the higher fixed-size blocks. This kind of
access is known as block device access.
2. In the other kind, one character at a time for the terminal devices.
 In the long-format output of ls -l, using the "c" symbol character distinct, files
are marked.
 In the long-format output of ls -l, using the "b" symbol block, distinct files are
marked.
4. Pipes
 In Unix, with the help of pipes, we can link commands together.
 Pipes is like a temporary file that only exists to hold the data from
one command till it is read by another.
 A one-way flow of data is provided by the Unix pipe.
 The first command's output sequence is used like an input to the next
command sequence.
DEPT. OF CSE, SLVP, HASSAN Page |5
OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

 In order to create a pipe, the vertical bar (|) has to be placed on the
command line between 2 commands. Such as who | wc -l
 In the long-format output of ls -l, known as pipes, are marked using the
symbol "p."
5. Sockets
 Unix sockets are a type of file that enables for advanced inter-process
communication.
 It is also known as inter-process communication socket.
 In the framework of the client-server application, a Unix Socket is used.
 It is essentially a data stream, same as the network stream and network socket,
except each transaction is local to the file system.
 In the long-format output of ls -l, using the "s" symbol, Unix sockets are
marked.

6. Symbolic Link
 The symbolic link is used to reference another file in the file system.
 The symbolic file will not function if the source file is deleted or moved to the
different location.
 In the case of the long-format output of ls -l, using the "l" symbol,
the symbolic link is marked.
FILE ATTRIBUTES:
 In UNIX, using ls –l command, we can see the attributes of a file and using
chmod command, we can modify its attributes.

 The ls –l command lists seven attributes of a file;


a. File Type and Permissions
b. Links
c. File Ownership
d. Group Ownership
e. File Size
f. Last Modification Time and
g. Filename

 The Three file permissions are;


a. read(r)
b. write(w) and
c. execute(e)

 Read – Designated as an “r”; allows a file to be read, but nothing can


be written to or changed in the file.
 Write – Designated as a “w”; allows a file to be written to and changed.
 Execute - Designated as an "x"; allows a file to be executed by users or
the operating system.

DEPT. OF CSE, SLVP, HASSAN Page |6


OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

3.5 Access control list (ACL)


An access control list (ACL) is a list of rules that specifies which users or systems are granted or
denied access to a particular object or system resource.
Each system resource has a security attribute that identifies its access control list. The list
includes an entry for every user who can access the system. The most common privileges for a
file system ACL include the ability to read a file or all the files in a directory, to write to the file
or files, and to execute the file if it is an executable file or program.
What is access control lists used for?
Access control lists are used for controlling permissions to a computer system or computer
network.
How do ACLs work?
Each ACL has one or more access control entries (ACEs) consisting of the name of a user or
group of users. The user can also be a role name, such as programmer or tester. For each of these
users, groups or roles, the access privileges are stated in a string of bits called an access mask.
Generally, the system administrator or the object owner creates the access control list for an
object.
Types of access control lists
There are two basic types of ACLs:
File system ACLs manage access to files and directories. They give OSes the instructions that
establish user access permissions for the system and their privileges once the system has been
accessed.
Networking ACLs manage network access by providing instructions to network switches and
routers that specify the types of traffic that are allowed to interface with the network. These
ACLs also specify user permissions once inside the network. The network administrator
predefines the networking ACL rules. In this way, they function similar to a firewall.

3.6 Adding text to file

Append Text Using >> Operator

The >> operator redirects output to a file, if the file doesn't exist, it is created but if it exists, the
output will be appended at the end of the file. For example, you can use the echo command to
append the text to the end of the file as shown

DEPT. OF CSE, SLVP, HASSAN Page |7


OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

# echo [Link] >> /etc/exports

You can also use the cat command to concatenate text from one or more files and append it to
another file.
In the following example, the additional file system shares to be appended in
the /etc/exports configuration file are added in a text file called [Link].

# cat [Link] >> /etc/exports

3.5 Pipe

Conceptually, 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 UNIX Operating System, Pipes
are useful for communication between related processes(inter-process communication).
 Pipe is one-way communication only i.e we can use a pipe such that One process write to the
pipe, and the other process reads from the pipe. It opens a pipe, which is an area of main
memory that is treated as a “virtual file”.
 The pipe can be used by the creating process, as well as all its child processes, for reading
and writing. One process can write to this “virtual file” or pipe and another related process
can read from it.
 If a process tries to read before something is written to the pipe, the process is suspended
until something is written.
 The pipe system call finds the first two available positions in the process’s open file table
and allocates them for the read and write ends of the pipe.

3.6 File Comparison

cmp command in Linux/UNIX is used to compare the two files byte by byte and helps you to
find out whether the two files are identical or not.
 When cmp is used for comparison between two files, it reports the location of the first
mismatch to the screen if difference is found and if no difference is found i.e the files
compared are identical.
 cmp displays no message and simply returns the prompt if the files compared are identical.
Syntax:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]

SKIP1 ,SKIP2& OPTION are optional


and FILE1 & FILE2 refer to the filenames .

The syntax of cmp command is quite simple to understand. If we are comparing two files then
obviously we will need their names as arguments (i.e as FILE1 & FILE2 in syntax). In addition
to this, the optional SKIP1 and SKIP2 specify the number of bytes to skip at the beginning of
each file which is zero by default and OPTION refers to the options compatible with this
command about which we will discuss later on. cmp Example : As explained that the cmp
command reports the byte and line number if a difference is found. Now let’s find out the same
with the help of an example. Suppose there are two files which you want to compare one is
[Link] and other is [Link] :
$cmp [Link] [Link]
DEPT. OF CSE, SLVP, HASSAN Page |8
OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

1. If the files are not identical : the output of the above command will be :
$cmp [Link] [Link]
[Link] [Link] differ: byte 9, line 2

/*indicating that the first mismatch found in


two files at byte 20 in second line*/
1. If the files are identical : you will see something like this on your screen:
$cmp [Link] [Link]
$_
/*indicating that the files are identical*

DEPT. OF CSE, SLVP, HASSAN Page |9


OPERATING SYSTEM AND ADMINISTRATION – 20CS42P December 30, 1899

DEPT. OF CSE, SLVP, HASSAN P a g e | 10

You might also like