Vous êtes sur la page 1sur 10

COURSE CODE: CAP423

COURSE NAME: Network Operating System - I


Homework No. 2

SUBMITTED TO
ABINASH BHAGAT

SUBMITTED BY
PRIYANKA SHARMA
ROLL NO RTB901A04
MSC( CS)

Part-A

1. Discuss the organization of the file system in terms of directories


and configuration files?
Ans)Root directory - Strictly speaking, there is only one root directory in
your system, which is denoted by / (forward slash). It is root of your entire
file system and can not be renamed or deleted.
* Sub directory - Directory under root (/) directory is subdirectory which can
be created, renamed by the user.
Directories are used to organize your data files, programs more efficiently.
Organization of the Linux Filesystem
Of the first things the average user needs to understand is the inner workings
of the root file system and Linux core directory structure. To help you
understand this structure, we have listed each directory explaining what it is
commonly used for.
bin - contains the vital tools necessary to diagnose, repair and or get the
system running
boot - houses the boot loader programs and configuration files
cdrom - shortcut to the CD/DVD drive
devbootstrap - contains files generated during the install of Ubuntu
dev - contains virtual files representing the hardware on your system
etc - central location for configuration files
home - where each users personal directory and files are located
initrd.img - symbolic link to ramdisk used to boot Linux
lib - shared system files
lost+found - where salvaged files get saved upon improper shutdown
media - directories that represent storage devices are found here
mnt - temporarily mounted external filesystems are located here
opt - optional additional software that is not a vital part of the system
proc - contains data about your system and current status
root - root users directory
sbin - administration programs are stored here
srv - network server configuration files go here
sys - Sysfs mount point used by the Linux kernel to administer your system
hardware
tmp - temporary files are stored here
usr - shared files and data go here
var - constantly changing data is placed here
vmlinuz - symbolic link to the kernel file used at boot

2. Discuss the functions related to random file access with suitable


example?
Ans)Random Access Files

The problem with sequential files is that they are, well, sequential. They are
great for dumping and retrieving large blocks of data all at once, but they are
not suitable for applications that need to read, write, and rewrite the same
data in a file multiple times. In those situations random access files provide
the only reasonable alternative.
Windows and Linux don't differentiate sequential and random access files
anymore than the CPU differentiates byte and character values in memory;
it's up to your application to treat the files as sequential or random access. As
such, you use many of the same functions to manipulate random access files
as you use to manipulate sequential access files; you just use them
differently is all.

You still open files with fileio.open and fileio.openNew. Random access files
are generally opened for reading or reading and writing. You rarely open a
random access file as write-only since a program typically needs to read data
if it's jumping around in the file.

You still close the files with fileio.close.

You can read and write the files with fileio.get and fileio.put, although you
would not normally use these functions for random access file I/O because
each record you read or write has to be exactly the same length and these
functions aren't particularly suited for fixed-length record I/O. Most of the
time you will use one of the following functions to read and write fixed-
length data:

fileio.write( fileHandle, buffer, count );

fileio.read( fileHandle, buffer, count );

The fileHandle parameter is the usual file handle value (a dword variable).
The count parameter is an uns32 object that specifies how many bytes to
read or write. The buffer parameter must be an array object with at least
count bytes. This parameter supplies the address of the first byte in memory
where the I/O transfer will take place. These functions return the number of
bytes read or written in the EAX register. For fileio.read, if the return value
in EAX does not equal count's value, then you've reached the end of the file.
For fileio.write, if EAX does not equal count then the disk is full.

Here is a typical call to the fileio.read function that will read a record from a
file:

fileio.read( myHandle, myRecord, @size( myRecord ) );


If the return value in EAX does not equal @size( myRecord ) and it does not
equal zero (indicating end of file) then there is something seriously wrong
with the file since the file should contain an integral number of records.

Writing data to a file with fileio.write uses a similar syntax to fileio.read.

You can use fileio.read and fileio.write to read and write data from/to a
sequential file, just as you can use routines like fileio.get and fileio.put to
read/write data from/to a random access file. You'd typically use these
routines to read and write data from/to a binary sequential file.

The functions we've discussed to this point don't let you randomly access
records in a file. If you call fileio.read several times in a row, the program
will read those records sequentially from the text file. To do true random
access I/O we need the ability to jump around in the file. Fortunately, the
HLA Standard Library's file module provides several functions you can use
to accomplish this.

The fileio.position function returns the current offset into the file in the EAX
register. If you call this function immediately before reading or writing a
record to a file, then this function will tell you the exact position of that
record. You can use this value to quickly locate that record for a future
access. The calling sequence for this function is

fileio.position( fileHandle ); // Returns current file position in EAX.

The fileio.seek function repositions the file pointer to the offset you specify
as a parameter. The following is the calling sequence for this function:

fileio.seek( fileHandle, offset ); // Repositions file to specified offset.

The function call above will reposition the file pointer to the byte offset
specified by the offset parameter. If you feed this function the value returned
by fileio.position, then the next read or write operation will access the record
written (or read) immediately after the fileio.position call.

You can pass any arbitrary offset value as a parameter to the fileio.seek
routine; this value does not have to be one that the fileio.position function
returns. For random access file I/O you would normally compute this offset
file by specifying the index of the record you wish to access multiplied by
the size of the record. For example, the following code computes the byte
offset of record index in the file, repositions the file pointer to that record,
and then reads the record:

intmul( @size( myRecord ), index, ebx );

fileio.seek( fileHandle, ebx );

fileio.read( fileHandle, (type byte myRecord), @size( myRecord ) );

3. Q)Everything in Linux is treated as a file. Justify? What are


various file
Descriptors? Explain Input output redirections.
Ans) Types of files :
1. Regular file:(-):contains data in either text format or
binary format
2. Directory file:(d):contains entries of files
3. FIFO file:(f):2 communicate betn 2 processes running on
same system
4. Block special file:(b):name given 2 special blocks of
hard disk
5. Sybolic file:(l):its a link or pointer to already
existing file
6. Socket file:(s):2 communicate betn 2 processes running on
different system in a network
7. Character special file:(c):handles only characted
formatted data
There are a three major of reasons which *justify* this.

First: because the original designers of UNIX were programmers first


(and everything else later...), they designed the system to make it easy to:

(1) write,
(2) test or debug, and
(3) successfully run programs.

The most important thing their desire for programming convenience.


Second: In those days (1970s) there were terrible (compared to today)
size constraints on the system and its software. Now the designers were
BIG on computing efficiency and ease of expressing their coding so this
ended being not only efficient approach, but also created a very elegant
design. This was in those days called a ``salvation through suffering''
philosophy, and it worked! (Proof - UNIX is 40 years old today!).

Third: Due to the early bad experiences the creators of UNIX (Thompson
and Ritchie) of being kicked off of many a system, they resolved to be
able to easily maintain the entire UNIX source code. This fact is more
important than it might seem. Because all source programs were always
available and easily modified on-line, everyone could revise and rewrite
the system and its software when new ideas were thrown up, modified,
added or discovered by others.

Finally, The interface to the file system, for example, is extremely


convenient from a programming standpoint. The lowest possible interface
level is designed to eliminate distinctions between the various devices
and files - for example, between direct and sequential access. No large
``access method'' routines are required to insulate the programmer from
the system calls; in fact, all user programs either call the system directly
or use a small library program, less than a page long, that buffers a
number of characters and reads or writes them all at once.

Another important aspect of programming convenience is that there are


no old style ``control blocks'' nonsense with a complicated schema.....
Generally speaking, the contents of a program's address space are the
property of the program, and by letting the program decide how it can
tackle the I/O, gave it complete independence.

Given the requirement that all programs should be usable with any file or
device as input or output, it is desirable to push device-dependence into
the operating system itself. Which is what happened and the rest is
history!

I will end this answer by sharing this with you - It was originally RH
Canaday of the CSTR at Bell Labs, who suggested (and helped
implement) to Ritchie and Thomson everything with a file like simple
structure, since
Part- B

4. Discuss Run Level in detail with example.


Ans)Linux run levels are numbered 0 through 6. Run levels stop at six
for practical and historical reasons, but it is entirely possible to have
more if desired.

The following table summarises the UserLinux run levels:

*0 System Halt
*1 Single user
*2 Full multi-user mode (Default)
* 3-5 Same as 2
*6 System Reboot

When run levels are discussed they are referred to as 'moving into', or 'going
into' a certain run level. The inference is that you came from somewhere.
With the exception of booting up, a system always transitions from one
runlevel to another in response to certain conditions.

Special Run Levels

Run level 0 is the system halt condition. Nearly all modern X86 computers
will power off automatically when run level 0 is reached. Older X86
computers, and various different architectures will remain powered on and
display a message referring to the halt condition.

Run Level 1 is known as 'single user' mode. A more apt description would
be 'rescue', or 'trouble-shooting' mode. In run level 1, no daemons (services)
are started. Hopefully single user mode will allow you to fix whatever made
the transition to rescue mode necessary.

(You can boot into single user mode typically by using your boot loader, lilo
or grub, to add the word 'single' to the end of the kernel command line).
Run levels 2 through 5 are full multi-user mode and are the same in a default
UserLinux (Debian) system. It is a common practise in other Linux
distributions to use run level 3 for a text console login and run level 5 for a
graphical login.

Run level 6 is used to signal system reboot. This is just like run level 0
except a reboot is issued at the end of the sequence instead of a power off

5. Write down the steps to connect to the internet through linux.

Ans)Firstly you need a network crossover cable. Available from most


computer stores. This is a special type of cable (not a standard LAN cable)

Secondly Make sure both computers are on the same workgroup. TO do this
Right click on My computer, Properties, go to the Computer Name Tab, See
what is written in Workgroup. Change one computer by clicking on change
and then type in the name of the other computer in the workgroup space
down the bottom. Do not make the computer part of a domain. You want
Workgroup.

This name change will require a computer reboot.

When both computers are on the same workgroup, we need to set IP


Addresses.

In Control Panel, Open Network Settings.


Right click on Local Area Connections and select properties.

Under the heading "This connection uses the following items, Find Internet
Protocol (TCP/IP)
Highlight it, Make sure you don't untick the box, and click on properties
Under the heading Use the following IP Address ENter in the Following on
ONE Computer.

IPAddress 192.168.0.10
Subnet Mask 255.255.255.0
Default Gateway LEave Blank
Under the Heading Obtain DNS Serveraddress automatically
Set this to Automatic. Don't enter anything in.

On the second computer Make the IP Address 192.168.0.20


Everything else the same.

Q)6Elaborate network configuration tool.


Ans)To communicate with other computers, computers need a network
connection. This is accomplished by having the operating system recognize
an interface card (such as Ethernet, ISDN modem, or token ring) and
configuring the interface to connect to the network.

The Network Administration Tool can be used to configure the following


types of network interfaces:

• Ethernet

• ISDN

• modem

• xDSL

• token ring

• CIPE

• wireless devices

To use the Network Administration Tool, you must have root privileges.
To start the application, go to the Main Menu Button (on the Panel)
=> System Settings => Network, or type the command redhat-config-
network at a shell prompt (for example, in an XTerm or a GNOME
terminal). If you type the command, the graphical version is displayed if X
is running, otherwise, the text-based version is displayed. To force the text-
based version to run, use the redhat-config-network-tui command.
Figure 12-1. Network Administration Tool

Vous aimerez peut-être aussi