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

Types of Files in Uni1

The document outlines the various types of files in the Unix operating system, including ordinary files, directories, special files, pipes, sockets, and symbolic links. It explains the characteristics and purposes of each file type, as well as how they are represented in the long-format output of the 'ls -l' command. Additionally, it covers concepts related to processes, the HOME variable, inode numbers, absolute and relative path names, and the significance of '.' and '..' in Unix file navigation.

Uploaded by

arindamghorui03
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)
12 views9 pages

Types of Files in Uni1

The document outlines the various types of files in the Unix operating system, including ordinary files, directories, special files, pipes, sockets, and symbolic links. It explains the characteristics and purposes of each file type, as well as how they are represented in the long-format output of the 'ls -l' command. Additionally, it covers concepts related to processes, the HOME variable, inode numbers, absolute and relative path names, and the significance of '.' and '..' in Unix file navigation.

Uploaded by

arindamghorui03
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/ 9

Types of Files in Unix

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.

The following are the types of files in Unix:

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.

Ordinary files are used to store our information like the text which we have to write or a picture
which we have to draw. This is the kind of the file which we mainly work with.

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. For the users who are familiar with Mac or
Windows operating systems, Unix directories are equivalent to the folders. 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.

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.
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.

This is one character at a time for the terminal devices. However, for disk devices, raw access
means reading or writing across an entire section of data-blocks that are native to our disk.

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 command 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. 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. In order to reference
another file of the file system, we use the symbolic link. It involves a text representation of the
path to the file it refers to. To an end-user, a symbolic link will seem to have its own name, yet
when we need writing or reading data to this file, it will rather reference these tasks to the file it
focuses to. When we delete the soft link itself, then the data file would, in any case, be there.
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.

Here's a well-structured answer for each topic, designed to meet the *5-mark* requirement:

---

1. Parent–Child Relationship in Unix


In Operating System, the fork() system call is used by a process to create another process. The
process that used the fork() system call is the parent process and process consequently created
is known as the child process.

Details about these are given as follows −

Process

A process is an active program i.e a program that is under execution. It is more than the
program code as it includes the program counter, process stack, registers, program code etc.
Compared to this, the program code is only the text section.

A process changes its state as it executes. This state partially depends on the current activity of
a process. The different states that a process is in during its execution are new, ready, running,
blocked, terminated.

A process control block is associated with each of the processes. It contains important
information about the process it is associated with such as process state, process number,
program counter, list of files and registers, CPU information, memory information etc.
Parent Process

All the processes in operating system are created when a process executes the fork() system call
except the startup process. The process that used the fork() system call is the parent process. In
other words, a parent process is one that creates a child process. A parent process may have
multiple child processes but a child process only one parent process.

On the success of a fork() system call, the PID of the child process is returned to the parent
process and 0 is returned to the child process. On the failure of a fork() system call, -1 is
returned to the parent process and a child process is not created.

Child Process

A child process is a process created by a parent process in operating system using a fork()
system call. A child process may also be called a subprocess or a subtask.

A child process is created as its parent process’s copy and inherits most of its attributes. If a
child process has no parent process, it was created directly by the kernel.

If a child process exits or is interrupted, then a SIGCHLD signal is send to the parent process.

A diagram that demonstrates parent and child process is given as follows −


2. HOME Variable in Unix
- *Definition:* The HOME environment variable stores the path of a user’s home directory.

- *Importance:* It allows easy navigation to personal files.

- *Example:* echo $HOME displays /home/user. cd $HOME moves to the home directory.

- *Key Commands:* cd ~ (shortcut to the home directory).

- *Summary:* It simplifies access to a user's files and configurations.

---

3. Inode Number in Unix


In Unix based operating system each file is indexed by an Inode. Inode are special disk blocks
they are created when the file system is created. The number of Inode limits the total number
of files/directories that can be stored in the file system.

An Inode is a data structure in UNIX operating system that contains important information
pertaining to files within a file system. When a file system is created in UNIX, a set amount of
indoes is created as well. Usually, about 1 percent of the file system disk space is allocated to
the inode table.

The Inode contains the following information:

14 Bytes 2 Bytes

File name 1 i-node 1

File name 2 i-node 2

Directory name 1 i-node 3

1. Numeric UID of the owner.

2. Numeric GUID of the owner.

3. Size of the file.


4. File type: regular,directory,device etc...

5. Date and Time of Last modification of the file data.

6. Date and Time of Last access of file data.

7. Date and Time of Last change of the I-node.

• Administrative information (permissions, timestamps, etc).

• A number of direct blocks (typically 12) that contains the first 12 blocks of the files.

• A single indirect pointer that points to a disk block which in turn is used as an index
block, if the file is too big to be indexed entirely by the direct blocks.

• A double indirect pointer that points to a disk block which is a collection of pointers to
disk blocks which are index blocks, used if the file is too big to beindexed by the direct
and single indirect blocks.

• A triple indirect pointer that points to an index block of index blocks of index blocks.

Inode Total Size:

• Number of disk block address possible to store in 1 disk block = (Disk Block Size / Disk
Block Address).

• Small files need only direct blocks, so there is little waste in space or extra disk reads in
those cases. Medium-sized files may use indirect blocks. Only large files use double or
triple indirect blocks, which is reasonable since those files are large anyway. The disk is
now broken into two different types of blocks: Inode and Data Blocks.

• There must be some way to determine where the Inodes are, and to keep track of free
Inodes and disk blocks. This is done by a Superblock. Superblock is located at a fixed
position in the file system. The Superblock is usually replicated on the disk to avoid
catastrophic failure in case of corruption of the main Superblock.

• Index allocation schemes suffer from some of the same performance problems. As does
linked allocation. For example, the index blocks can be cached in memory, but the data
blocks may be spread all over a partition.

Inode Structure :
### 4. *Absolute Path Name*

An absolute path is a full path that specifies the location of a file or directory from the root
directory ('/'). It provides a complete address that points directly to a file or directory, regardless
of the current working directory. This path type always begins with the root directory, followed
by subdirectories, and ends with the desired file or directory name.

Characteristics of Absolute Paths:

• Starts with a slash (/).

• Specifies a file location from the root directory.

• Does not depend on the current directory.


### 5. *Relative Path Name*

A relative path specifies the location of a file or directory in relation to the current working
directory (often abbreviated as pwd). It does not start with a slash ('/'), and it utilizes
navigational shortcuts to refer to the file or directory.

Characteristics of Relative Paths:

• Does not begin with a slash ('/').

• Dependent on the current directory.

• Utilizes shortcuts like '.' (current directory) and '..' (parent directory) to navigate the
filesystem.

### 6. **Significance of . and .. in Unix**

UNIX offers a shortcut in the relative pathname- that uses either the current or parent directory
as reference and specifies the path relative to it. A relative path-name uses one of these cryptic
symbols:

• . (Dot): Represents the current directory.


• .. (Double Dots): Represents the parent directory.

Now, what this actually means is that if we are currently in directory '/home/kt/abc' and now
you can use '..' as an argument to 'cd' to move to the parent directory /home/kt as :

$pwd

/home/kt/abc

$cd .. ***moves one level up***

$pwd

/home/kt

Note: Now '/ ' when used with '..' has a different meaning; instead of moving down a level, it
moves one level up:

$pwd

/home/kt/abc ***moves two level up***

$cd ../..

$pwd

/home

You might also like