KEMBAR78
Module-4 Ho | PDF | Directory (Computing) | Computer File
0% found this document useful (0 votes)
22 views8 pages

Module-4 Ho

Uploaded by

Madhushree S G
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 views8 pages

Module-4 Ho

Uploaded by

Madhushree S G
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/ 8

Module-4

1.Discuss the various types of UNIX files.


In UNIX, files are divided into three categories –
* Ordinary file * Directory file * Device file
• Ordinary (Regular) File
It is a most common type of file that contains only data as a stream of
characters. An ordinary file can be one among these –
* Text file * Binary file * Device file
• Directory File
• A directory contains no data, but it keeps some information
about the files and subdirectories that it contains.
• A directory actually do not contain the file itself, rather it
contains only the file name and a number.
• We cannot write into a directory file. But the actions like
creating a file, removing a file etc. makes kernel to update the
corresponding directory by creating/removing filename and
inode number associated with that file. inode number refers to
the physical file, the data stored in a particular location.
• Device File :
• Device filenames are generally found inside a single directory
structure, /dev.
• A device file is not a stream of characters. In fact it does not
contain anything.
• The operation of a device is completely managed by the
attributes of its associated file. The kernel identifies a device
from its attributes and then uses them to operate the device.
2.Elucidate the different types of pathnames with its example.
ABSOLUTE PATHNAMES :
A path of a file (or directory) which specifies the complete hierarchy of that
file starting from the root (/) directory is called as absolute pathname of that
file (or directory).
Example: it is assumed that the file test.sh is in current directory. If you would
like to access the file in some other directory, you have to give the command
by specifying absolute pathname of that file as –
$ cat /home/john/test.sh
RELATIVE PATHNAMES :
A relative path is defined as the path related to the present working
directory.
For example, if we are currently in /home/john and would like to move to
/home/john/test, then we can just give the command as –
$cd test(Relative path usage)
We can also give the command as:
$ cd /home/john/test (Absolute path usage)
Note:-if the pathname starts with / (root), we can say that it is absolute path.
Otherwise, it is relative path.
4.Describe the Relative pathnames using dot(.) and two dot(..).
Using . and .. in Relative Pathnames :
A single dot (.) – represents current directory
Two dots (..) – represents parent directory.
we can use ./(dot with slash).
For example, assume there is a file shell1.sh in the current directory.
And, we want to copy it into directory myDir which is within current
directory. Now we can use the command –
$cp ./shell1.sh ./myDirt
3.Illustrate the working process of UNIX file system with its root
directory.
1. Root Directory (/):
o The root directory is the top-level directory in the Unix file system. It is
denoted by a forward slash (/).
o All other directories and files are descendants of the root directory.
o The root directory contains essential system files and subdirectories.
2. Hierarchical Structure:
o The Unix file system follows a hierarchical (tree-like) structure.
o Directories (folders) and files are organized into a multi-level hierarchy.
o Each directory can contain both files and other directories.
3. Subdirectories:
o Below the root directory, you’ll find several subdirectories:
▪ /bin: Contains fundamental utilities (e.g., ls, cp) needed by all users.
▪ /boot: Holds files required for the booting process.
▪ /dev: Represents devices (both physical and pseudo-devices).
▪ And many more, depending on the Unix variant.
4. File Representation:
o In Unix, everything is treated as a file, including devices.
o Device files (located in /dev) represent peripherals (e.g., disks, keyboards).
o There are two types of device files:
▪ Block Special Files: Transfer data in blocks (similar to disks).
▪ Character Special Files: Transfer data as a stream of bits (e.g., keyboard
input).
5. Unique Inodes:
o Each file in Unix has a unique identifier called an “inode.”
o Processes accesss files through a well-defined set of system calls.
o Pathnames (character strings) uniquely identify files and are converted to
inodes.
6.Discuss the process of removing a permission in file using ls
command and chmod command.
1. Viewing File Permissions with ls:
o The ls command allows you to list files and directories along
with their permissions. When you run ls -l filename.txt,
you’ll see output like this:
o -rw-r--r-- 12 linuxize users 12.0K Apr 8 20:51 filename.txt
o The first character indicates the file type (e.g., - for a regular
file).
o The next nine characters represent the permissions: three
triplets for owner, group, and others.
o For example, rw-r--r-- means the owner has read and write
permissions, while the group and others have read-only
permissions1.
2. Removing Permissions with chmod:
o To remove permissions, use the chmod command.
o Suppose you want to remove read permissions for others
(everyone else) from a file named example.txt. You can do
this:
o chmod o-r example.txt
o This command removes read permissions for the “other”
category of users.
o If you want to include files in subdirectories as well, use
the -R (recursive) option2.
7.Write the differences between hard links and soft links.
Hard links :
1. Hard Links have the same inodes number.
2. ls -l command shows all the links with the link column showing the
number of links.
3. Links have actual file contents
4. Removing any link, just reduces the link count but doesn't affect
the other links.
5. You cannot create a Hard Link for a directory.
6. Even if the original file is removed, the link will still show you the
contents of the file.
Soft links :
1. Soft Links have different inodes numbers.
2. ls -l command shows all links with second column value 1 and the
link points to the original file.
3. Soft Link contains the path for original file and not the contents.
4. Removing soft link doesn't affect anything but when the original
file is removed, the link becomes a 'dangling' link that points to
nonexistent file.
5. A Soft Link can link to a directory.
8.Explain the method of changing file permissions using chmod
command.
1. Basic Permissions Model:
o Each file has an owner, a group, and permissions for three
classes of users: owner, group members, and others.
o Permissions include read (r), write (w), and execute (x).
o Example: -rw-r--r-- means the owner has read and write
permissions, while the group and others have read-only
permissions1.
2. Syntax:
o To change permissions, use: chmod
[references][operator][modes] filename.
o References: u (user/owner), g (group), o (others).
o Operator: + (add), - (remove), = (set explicitly).
o Modes: r (read), w (write), x (execute)2.
3. Examples:
o Grant executable permission: chmod +x filename
o Remove executable permission: chmod -x filename
o Give owner read and write permissions: chmod u=rw
filename
o Give group read and write permissions: chmod g=rw
filename
o Give others read and write permissions: chmod o=rw
filename
9.Generalize the concept of file permissions using ls-l command.
When using the ls -l command in a Unix shell, the output displays
information about the file permissions. Each line represents a file or
directory, and the permissions are displayed in the first column. The
permissions are represented by a 10-character string, with the first
character indicating the type of the file (e.g. regular file, directory,
symbolic link), followed by three sets of three characters representing
the permissions for the owner, group, and others, respectively.
For example, a file with permissions rw-r--r-- means that the owner
can read and write to the file, while the group members and others
can only read it. Similarly, a directory with permissions rwxr-xr-
x allows the owner to read, write, and execute the contents of the
directory, while group members and others can only read and
execute.
10.Describe the types of links in UNIX file system with its example.
A link is a connection between the file to be shared and the directory
entries of the users who want to have access to this file
2 types of links exist:
• hard links
• soft (symbolic) links
• Hard Link acts like a mirror copy of the original file.
• These links share the same inodes.
• Changes made to the original or hard-linked file will reflect in the
other.
• When you delete Hard Link nothing will happen to the other file.
Hard links can't cross file systems.

• Soft Link is an actual link to the original file also know as symbolic
link or symlinks.
• These Links will have a different Inodes value.
• The soft link points to the original file so if the original file is
deleted then the soft link fails.
• If you delete the Soft Link, nothing will happen to file.

You might also like