Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne...

33
MODEL PAPER 2 Q1(a)Mention the various components of a Unix operating system and explain their functions. [8M] sol) Unix system organization. Unix contains three layers: shell, kernel, end users. sol) - shell : This plays the role of an interpreter. it is actually the interface the user and the kernel. That effectively insulates the user

Transcript of Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne...

Page 1: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

MODEL PAPER 2

Q1(a)Mention the various components of a Unix operating system and explain their functions. [8M] sol) Unix system organization.Unix contains three layers: shell, kernel, end users.

sol) -

shell: This plays the role of an interpreter. it is actually the interface the user and the kernel. That effectively insulates the user from the knowledge of Unix functions. In other words shell acts a mediator. There are 4 types of shell inUnix .

Bourne shell-most popular among the rest-created by Steve bourne-default working.

Page 2: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Shell-prompt $Bash shell-also known as ‘bourne again shell’-default working shell in linux-Created by FSF >Free Software Foundation by Brain fox & Chet ramey.

C shell-designed by Bill Joy &developed by university of California-prompt %. Korn shell-created by David Korn-prompt $

Kernel:-It is also known as the heart of Unix operating system. It manages files,manages memoryManages system resources, allocates time between users and processes ,decides process priority, and so on. It is mostly a collection of programs written in C. there can be number of shells but has only one kernel.

End users :-They are also known as third party application programmers.

Ι a) Explain the following: script, ispell, bc, echo commands each with an example. [8M]

Soln) script : lets you record your login session in a file typescript in the current directory. All the commands, their output and error messages are stored in the file for later viewing. If you are doing some important work and wish to keep a log of all your activities, then you should invoke this command immediately after logging in.Syntax: $ scriptscript started, file is typescript$the prompt returns, and all the keystrokes that are entered from now on are recorded in typescript ispell: this is an interactive spell checking program provided by Linux. It highlights the line and the word and also suggests some alternatives and offers some other options.Syntax:$ ispell ux2nd25cron file: ux2nd25that have been queued up for printing. Cron is the systems chronograph.00: chon01: con02: coon

Page 3: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

…….and so on. It provides options to replace, accept, insert, look up, uncap, quit or exit. The system totally offers ten possible alternatives out of which one has to be chosen or press a to accept it for the rest of the session.bc: this is a calculator provided in Unix. If bc is invoked without arguments, the input has to be keyed in, each sign terminated by pressing enter. Ex: to add two numbers, $ bc 12+618<ctrl-d>$The value 18 is displayed in the next line after computation. bc can also perform more than one calculations together.Ex: 12 * 12; 2^32 1444294967296when dividing two numbers the decimal portion is truncated. So, 9/5 would give 1.It is also handy in converting numbers from one base to another. Ex:Ibase=211001010202o/p is in decimal.It can also be used with variables Ex: x=3; y=4; z=5p=x+y+zp12

echo: displays the argument. The arguments can be quoted or unquoted. Ex: $ echo welcome to unixwelcome to unixin order to preserve the spaces arguments must be written in quotes.Here echo doesn’t compress the spaces, shell does it.Echo is an internal command of shell.

c) Clearly distinguish between absolute and relative pathnames [4M]sol)consider the commandcat login.sql

Page 4: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

displays the content of the file login.sql if it is present in the current directory.If we are placed on /usr and would want to access the file login in /usr/kumar Then the command would becat /usr/kumar/login.sqlIf the first character of a pathname is / the files location should be determinedwith respect to root .Such pathnames are called as absolute pathnames.Relative pathnames-if we are placed in /usr/kumar/pis/progs and would likeTo change our directory to parent directory the instead of commandcd /usr/kumar/pis if we just give cd..then it moves to its parent directory.This feature is known as relative pathnames. It locates a file name with respect to its current directory .

Q2(A)Mention the characters that are used as wild cards by the shell.explain theirmeaning and illustrate their usage . also give the meaning of character class. [11M]Hence or otherwise mention when do wild cards loose their meaning.

Sol)Suppose there are a set of file names text01, text02 , text03 , …textab1 ,textab2 , ….if we want to list the file names starting with text.one obviousmethod is $ls text01 , text02 ….This is a cumbersome process.In Unix the shell enables us to give a general pattern of characters in a command line to match a group of filenames. In other words all file names can fit in one pattern by using wild cards.1]’*’-This is a metacharacter. It matches with any character and any number of characters i.e text* would display all file names that start with a string text irrespective of the rest of the characters .so$ ls –x text* text01 text02 text 03 textab1 #would be displayedso text* will display all file names whose first 4 char are text irrespective of the rest.2]’?’-This is a metacharacter that matches only a single character .if $ls –x text?

Page 5: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

#then it would search for files starting with text provided only the next char could be anything i.etext1 text2 text3 ..would be displayed.So $ls ?#would displayade$3)’[ ]’-checks for appearance of single character specified pair of bracketif ex$ls –x text[123]text1 text2 text3it is also possible to introduce a hyphen inside the brackets which indicates the range$ ls –x text[1-10]text1 text2 text3 text10It matches a single character within the ASCII range of the character.The valid range specification the left have a lower ASCII value than the right.Similarly negating the char class is also valid i.e$ls –x text[!2]text1 text3 $ text2 is not displayed .it is also possible to combine char class with negating char class$ls –x text[!1-10]texta textb they tend to lose their meaningif * and ? are not used inside the class.If – and !are placed outside the class.! must be in the beginning of class- must be bounded on both sides

Q2(b)Mention at least three popular shells available in Unix. Discuss each one of them briefly. [9M]

Page 6: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Sol)The most prominent types of shells are:Bourne shell- this shell is named after Steve bourne. It is one of the earliest shells that came along with Unix system. This is one of the most widely used shell. This is also the default working shell. Its prompt is $. Its commands starts the moment we login and withers away the moment we logout. When we invoke the shell command while we are in bourne shell –$ echo $SHELL/bin/sh (or) /bin/bsh C shell- This shell was created by Bill Joy when pursuing his graduation at University of California at Berkeley. Its prompt is %.when the shell command is invoked –O/p would be/bin/cshIt has two advantages over bourne shell-Firstly it allows aliasing of commands. i.e you can decide what name you want to call a command as. So typing lengthy commands can be avoided.C shell has a command history feature. So previously typed commands can be recalled.This feature is similar to DOSKEY feature in MS-DOS.Bash shell-This stands for Bourne again shell. It is the default working shell in Linux. It came from FSF –“Free Software Foundation “developed by Brain Fox and Chet Ramey.When the Shell command is invoked while we are in this shell the o/p would be-/bin/bash.

Q3(a)Explain how patterns are searched and replaced in vi editor environment [6M]

sol) vi offers a powerful command for substitution. It is in the ex mode and the command is ‘s’ .It lets you to replace a pattern in the file with something elsefirstly if we would only want to search for a string-/dos -this command searches for the string “dos” and brings the cursor to that position. Again if “dos” has occurred more than once then it positions the cursor below the first occurrence of the string. Suppose every occurrence of the string “director “ must be replaced with “member”. Command would be

Page 7: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

:s/director/memberthus the first occurrence of “director “ must be replaced with “member”.If every occurrence of the word int the line is to be substituted it is achieved with command ‘g’.:s/director/member/gTo replace every occurrence in the entire file:g/director/member/gwe can similarly specify the range ie:3,10s/director/member/gsubstitutes only in lines 3-10

Q3(b)Mention and explain the command that is used to save the output of a command on a file as well as to display the same on the monitor. [8M]

Sol)To save the standard output in the file as well as display it on to the terminal the command ‘tee ‘ is used. Tee uses standard input as well as standard output this means that it can be placed anywhere in the pipeline.It breaks the input to 2 components –one component is saved in the file and other is connected to standard output.Ex: To save o/p of who and display it-$who | tee user.lstkumar tty May 18 09:32(s same as $cat user.lst).The terminal is also treated as a file.Std i/p------------tee------------file | | std o/p

Q3(c)clearly distinguish between the Unix internal and external commands. Give an example for each. Sol)File having an independent existence in /bin directory is branded as external command. Most of the commands are external in nature . ls is an example for external command.But there are some commands that are not found anywhere and some are not executed even if they are in one of the directories specified by PATH.

Page 8: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

$type echoecho is a shell builtinEcho isn’t an external command . ie when echo is typed the system wont look in its PATH to locate it. Rather it will execute it from its own set of built-in commands that are not stored in separate files. These built-in commands of which echo is a member are known as internal commands.

Q4a) what are the pemissions that are associated with UNIX file on their creation? Explain very briefly how these permission can be changed to required values.Q4b) what are the time associated with files? Discuss their importance hence or otherwise discuss how these times could be changed?

Ans4a) To know the file pemission of the file we use ls –l(long) option that is the most revealing . This option will tell you not only the size of file, but also the it’s access rights (permission), it’s last modification time and the ownership details. Let us use ls -l to list the seven attributes of all the files in the current directory:ls –l<enter>total 72-rw-r--r-- 1 kumar metal 19514 May 10 13:45 chap01-rw-r--r-- 1 kumar metal 4174 May 10 15:01 chap02-rw-rw-rw- 1 kumar metal 84 Feb 10 12:30 dept.lst-rw-r--r-- 1 kumar metal 9156 Mar 12 1996 genie.shdrwxr-xr-x 2 kumar metal 320 May 9 09:57 progs

The first column shows the type and permissions associated with each file. the first character in this column is usually a “-“ , which indicates that the file is an ordinary one , whereas a “d” at this position will indicate a directory file. You then see a series of characters that can take the values r,w,x, and -. In the UNIX system, a file can have three types of permission read, write, execute associated with various types of users. There are only 3 types of users in UNIX platform. They are owner, group and others. When you create a file you automatically becomes owner. The 2-4 column of ls –l command shows the permission associated with the owner. In file chap01 the owner has read,write permission and no execute permission. The second type of user is the group. When a user account is opened by the system

Page 9: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

administrator, he simultaneously assigns the user to some group. The 5-7 column of ls –l command shows the permission associated with the group. In file chap01 the group has the permission to read only. The last type of user in UNIX platform is others. The 8-10 column of ls –l command shows the permission associated with the others. In file chap01 the group has the permission to read only.

The file prmission –rwxrwxrwx gives every permission to all categories of user which surrenders the security so easily which is against the UNIX system.

The chmod command is used to set the the three permissions for all three categories of users (owner, group and others) of a file. It can be used only the owner of the file, and uses the following syntax: chmod category opration permission filename(s)

abbrevation used by chnod

Category Operations Permissionsu-user + assign permission r-read permissiong-group - remove permission w-write permissiono-others = assign absolute permission x-execute permissiona-all

Now, let’s take an example. To assign executable pemissions to the owner of the file chap01, other pemissions remaining the same, we use:$ chmod u+x chap01$ls –l chap01-rwxr—r-- 1 kumar metal 19514 May 10 13:54 chap01

the string ugo combines all three categories-owner,group,other. UNIX offers a shorthand symbol a(all) to act as as a synonym of the string. Thuschmod a+x chap01 will change the execute permission of all the users in file chap01

permission are removed with the – operator. To remove the read permission from both group and others, use the expression go-r:$ ls –l chap01

Page 10: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

-rwxr—r-- 1 kumar metal 19514 May 10 13:54 chap01$ chmod go-r chap01 ; ls –l chap01-rwx------ 1 kumar metal 19514 May 10 13:54 chap01

Q5(a).What are positional parameters? How are they useful in shell scripts? Discuss.ANS:

There are three basic type of variables available:-1) POSITIONAL PARAMETERS:- invoked by normal shell variables.It is called as positional parameter or postional variables depending upon the position it occupies during the execution stage. EXAMPLE:- echo “my name is $1” echo “your name is $2” $sh test abc xyz

OUTPUT:- my name is abc your name is xyz NOTE:- Shell can take a maximum a maximum of a positional parameter.2)SPECIAL PARAMETER:- There are 2 types of special parameters:-

a) $# :- returns the number of arguments.echo “the total number of arguments specified is $#”EXAMPLE:- sh test learning unix<enter>OUTPUT:- the total number of arguments specified is 2$b) $* :- Returns all the arguments

EXAMPLE:- echo “argument are $*” $sh test learning unix HOW ABOUT THIS :- $cat > name_test echo “enter the name”

Page 11: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

read name echo “enter the telephone number” read number echo $name $number >> mylist <ctrl>+d

$sh name_test

OUTPUT:- enter the name charul enter the telephone number 234256 $

now type we write :- $cat my_list<enter> charul 234256

Q5(b) Write a shell script to create a menu which display the list of files, current data, process status and current users of the system.ANS:

echo “unix command menu”echo 1: list of filesecho 2: long list of filesecho 3: current working directoryecho 4: list of usersecho “enter your choice”read choicecase $choice in1) ls;;2) ls-l;;3) pwd;;4) who;;

Page 12: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Q5(c) Explain the statements export and exec related to shell programming.ANS:

Exec:- A system call used by process to overwrite itself with the code of the called process. It is also a shell built-in statement, which changes the standard input and output of a process. It uses files descriptors rather than physical filenames and is extremely useful for handling I\O.

Export:- A built-in shell program which makes the environment of the parent process available in the child process. The statement is used with variables.

Q7(a) who is a super user? What are his duties, responsibilities and priviledges?ANS:

Unix land is a monarchy in the true sense of the word. Just one monarch and all others his subjects. Insensitive to the world where Berlin walls are collapsing and dictators are fleeing for their lives UNIX monarchy has survived for decades. This topic is addressed to kings of the UNIX world. In whose hands lies the power of life and death of their Unix dependent subjects. Those who hold the scepter of root password. i.e SYSTEM ADMINISTRATOR. He is also called as SUPERUSER.Need for system administrator :

Have a look at typical problems you face- Sudden power surge and your hard disk crashes.- Lack of disk space.- As business expands increase number of terminals, storage capacity etc.

System Administrator and His tasks :

- Individual responsible for administering and maintaining UNIX system.- Adding / removing users.- Creating passwords.- Maintaining backups.- Creating and maintaining file systems.- Setting up various devices.

Note: The superuser has power to do anything with a file, no matter who owns it and what permissions have been set for it by its owner. The entire system administration what I have done is – I have basically divided into four sections. Just probably to make our life easier. Here are those fours sections :

Page 13: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

administrative concepts. set up procedures maintenance tasks security

Now let us see one by one how basically these tasks are carried out by the administrator.

ADMINISTRATIVE CONCEPTS :

If you are used to administering a single user O.S like WINDOWS 95, you will notice some striking differences from the multi user, multi tasking UNIX O.S. Basically deals with general login concepts. Most computers that run UNIX offer two methods for administering a system : a menu interface and a set of commands. Menu interfaces is different for different flavours. Here I am going illustrate with the help of commands for the reasons mentioned below :

1. Menu interfaces are often very different from one computer to other. Therefore showing one type of menu interface may not help you much if your computer does not have that interface.

2. Commands and options tend to be similar from one UNIX system to other.3. Menu interfaces do not let you see what is actually happening and over time you

may lose the understanding of how particular processes work.

Adding a new user :

You can use the command : useradd or adduser. Every valid user in system has entry in /etc/passwd file.

Ex: ngp:x:0:1:0000-Admin(0000):/:/bin/csh

Where:First field represents user's login.Second field encrypted password.Third field user identification number.Fourth field group identification number.

Page 14: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Fifth field comment field (used to give user's full name)Sixth field specifies user HOME directorySeventh field specifies full path name of the program that the system runs when user first logs in.

Deleting a user :You can use the command : userdel or deluser.Ex : # deluser ngpThis removes all entries pertaining to ngp from /etc/passwd, /etc/group and /etc/shadow.

Adding a new group :You can use the command : groupadd.Ex : # groupadd studentWill add new group called student to /etc/group file and will assign GID ( group Identification Number ). Once this is over you can say :

# useradd –g student jyothi < enter >will add new user jyothi to group student.

Deleting a group :You can use the command : groupdel.Ex : # groupdel student

Changing group name :You can use the command : groupmod.Ex : # groupmod –n staff student < enter >

Will change group’s name from student to staff.

PASSWORD ADMINISTRATION :

Systems having /etc/shadow use an elaborate scheme for administering the change of password. This is called password aging. This should be used by the administrator to force the users to change the passwords after a predetermined time.Ex : # passwd -x30 -n7 ngp

Page 15: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Will require ngp to change the passwords every 30 days and to keep password for atleast a week.

Now if a user or a programmer has forgotten his / her password, he / she can rely on administrator. What I mean by this not that the moment you approach administrator he will tell your password. NO – NOT AT ALL. He will only help you in deleting whatever may be your old password.Ex : # passwd –d ngp < enter >where –d option is for deleting. Now when the user logs in the system will not prompt for password.

Note: If you as a System Administrator forget the root password, then entire UNIX system has to be reloaded.

Even a normal user can invoke root i.e. can act as a super user. Let us understand this very carefully.

Ex : $ pwd/usr/ngp$ su <enter>password: <enter>#pwd <enter>/usr/ngp#

SET UP PROCEDURES

The following is a set of the most basic procedures you need to do to get your computer going. Some of them you might do only once, while few yes couple of times.

SETTING DATE / TIME :

You can set date and time with the help of date command.Ex : # date 1205114500 < enter >

TUE DEC 05 11:45:00 IST 2000

Page 16: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

INSTALLING SOFTWARE PACKAGE :

You basically use pkgadd command. This transfers the software package from disk, tape, or CD-ROM to install it on the system.

Ex : # pkgadd –d /dev/fd0 package1

will install package1 onto your system from a floppy disk defined as /dev/fd0.

Ex : # pkgadd –d /cdrom/cdrom0/s0/Solaris_2.6

will prompt you for the name of the package you want to install, and it will then install it into your default directory.

RED HAT LINUX supports a tool called rpm – Red Hat Package Management to install software packages.

Some other issues which comes under this are as follows :

Installing console terminalsSetting up printersSetting system namesBlocking user accessHard delete of a userSoft delete of a user

These are not actually mentioned in your syllabus. The idea is to make you have a slightly better knowledge.

MAINTENANCE TASKS

Page 17: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Once your system is set up, it is important that you stay in touch with your computer and its users. If more than one or two people are using your computer, you will probably want to use some of the tools the UNIX system provide to communicate with users. Let us see some of them :

talk command : allows you to chat with someone on your machine. This is forerunner of chat capability at Internal level.

For example the user ngp on machine S1 can set up an interactive talk session with user jyothi on machineS2 by issuing command :

Ex : talk jyothi@S2

This will send a message to the screen for user jyothi with some text :

Message from TalkDaemon@S1 at 10:00 a.m

talk : Connection requested by ngp

jyothi would then reply :

talk ngp@S1

wall command : allows you to send the message to all users who are currently working on your system. It is short for “ write to all “ It was designed for use by the System Administrator to make announcements of Universal interests. Gossip, personal secrets and romantic messages must never be sent using wall command. Strictly business.

Ex : # wallPls. Save your files and log out.The system is coming done in next couple of seconds.(CTRL-D)#

Page 18: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

All users who are logged in, will hear a beep and see a message flashed on their screen as follows :

Broadcast Message from root(tty01) on unix Feb 15 9:40 2001Pls. Save your files and log out.The system is coming done in next couple of seconds.

NOTE : The wall command when used by the superuser overrides all write permission constraints and flashes the message on all terminals.

news command : permits users to read messages published by the system administrator. The important news is saved as a file in /usr/news directory so that it may be available to all users.

Ex : $ newsMeeting ( root) Fri Feb 16, 10:00:00 2001There is a meeting today for all UNIX programmers.SYS. ADM

After the message is displayed once, if you type the news command again :$ news$

It’s not magic. Unix creates a file called .news_time in the home directory of the user when he runs the news command. This file is a zero length file that records the time when the news command was executed. When you run the news command again, this file compares the time of the news file with its own. Only if the news file was created after the time that is recorded with .news_time then the news item is displayed.

motd command : another facility similar to the news command is the :” Message of the Day “. No specific command exists for this utility. This message assumes a higher priority than the news command and generally includes important messages such as system downtime and last minute changes.

These messages are stored in a file called motd in /etc/motd dirctory. To display you just say :

Page 19: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

$ cat /etc/motd

Display system name : you can uname command to display all system name information. It supports several options :Ex : -m : prints the machine name

# uname –m < enter > i386

-n : prints the machine’s node name, by which it is known to communications network.

# uname –n < enter >SCOSYSV

-r : prints O.S. release # uname –r < enter >

3.2

-s : prints O.S. name # uname –s < enter >

SCO_SV

-v : prints O.S. version # uname –r < enter >

2Backups of files : Can be take on floppies / tapes.

Tar command : Short for tape archive. Offers multitude of options to make life difficult for the user.

Ex: To backup all files from /etc/default onto floppy disk

Page 20: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

#tar -cvf /dev/fd096ds15 /etc/default/8

c copyingv displays names of the filesf name of the device file

#tar -tc

lists the contents of the file backed up on the disk.

Note : Do not copy any other file, if you still have space remaining on floppy.

Use -r option to append at the end.

-x: restores back the data from the floppy.

cpio : alternative backup utility.

Ex: #cpio -ov > /dev/fd096ds15

Copies all files from current directory onto dievice file.

Where o output.v displays the files.

To see the contents of the floppy#cpio -iv < /dev/fd096ds15

SECURITY

You can do many things as an administrator to help secure your system against unauthorized access and the damage that can result. What follows is a list of security tips for administrators :

1. use only authorized commands2. protect your superusers

Page 21: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

3. provide accountability4. protect administrative files5. use password aging6. use full pathnames7. analyze log files

STARTUP & SHUTDOWN :

The UNIX system has several different modes of operation called system states. These system states make it possible for you, as an administrator to limit the activity on your system when you perform certain administrative tasks.

Ex : system state 0 power down statesystem state 1, s or S single user system state 2,3 multi user

When you bring up your system in single user state, only root file system is accessible ( mounted ) and only console terminal can access operating system. The machine goes through complex series of processes that may take up to a few minutes to complete boot cycle.

The first major event is loading of kernel represented by file /stand/unix or /vmlinuz in LINUX into memory.

The kernel then starts spawning further processes, the most important of which is init. This process always has PID 1. Eventually init becomes parent of all shells.

NOTE : By default your system will go into a multi user state.

To change the default system state you must edit /etc/inittab file and edit the initdefault line.

Ex : to bring up the system inn state (3) i.e RFS ( Remote File Sharing )

is:3:initdefault:

Page 22: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

The next time when system is started all multi user processes will be started, plus RFS services will be started. Appropriate if you are sharing files across network.

Changing the state :

When your system is up and running, you may decide you want to change the current state.

Ex : if you are in a single suer mode and want to change to multi user mode, type the following :

# init 2 < enter >

Now users will be able to log in.

SHUTDOWN :

The administrator has the duty of shutting down the machine at the end of the day. You can shut down your machine using init command; however it is more common to use shutdown command.

The benefit of using shutdown command is that it goes to a lower state and lets you assign the grace period do that your users will have some warning before shutdown actually begins.

#shutdown –g120 < enter >

will wait for 2 minutes ( 120 seconds ) before proceeding further.

Shutdown usually performs the following activities ;

1. Notifies users with wall about system going down.2. Sends signals to all running processes so that they can terminate normally.3. Logs users off and kills remaining processes.4. Unmounts all secondary file system i.e detaches from root file system5. Notifies users to reboot or switch off – or moves the system to single user mode.

Page 23: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Q7(b) What are inodes? What information do they contain.ANS:

Unix file hierarchy referred to as file system as if all files and directories are held together in one big super structure. This is seldom the case, and never so in large system. The entire hard disk is never available for storing data. A certain area of every file system is always set aside to store the attributes of all files in that file system. This set of attributes is stored in a fixed format structure called the inode. Every file has one inode, and a list of such inodes is laid out contiguously in an area of the disk not accessible directly by any user. Each Inode is accessed by a number called inode number.CONTENTS OF INODE:-Every file or directory has an inode, which contains all that you could possibly need to know about a file, except its name and contents. More specifically, each node contains the following attributes of the file:-

1. File type (regular, directory).2. Number of links(the number of aliases a field has).3. Owner (the user-id number of the owner)4. Group (the group id number).5. File mode (the triad of three permission).6. Number of bytes in the file.7. Date and time of last modification.8. Date and time of last access.9. Date and time of last change of the inode.10. An array of 13 pointers of the file.

Observe neither the file name nor its I number is stored in the inode. The name and I-number are found in the directory which houses the file. The I-number is actually the position of the inode in the inode array, and hence can be located using simple arithmetic.

Q8(a).Write a brief notes on the command using which a report on free disk space available on the disk can be obtained.ANS:

df (disk free) reports the amount of free space available on the disk. The output always reports for each file system separately:-# df/ (/dev/root ): 112778 blocks 53375 I-nodes

Page 24: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

/stand (/dev/boot ): 17752 blocks 2365 I-nodes/oracle (/dev/oracle ): 45698 blocks 12365 I-nodes/home (/dev/home ): 120154 blocks 45995 I-nodes

there are four file systems, of which the first two are always created by the system during installation. The root file system (/dev/root), has 112778 blocks of free disk space. It also has 53375 inodes free, which means that up to that many additional files can be created in the file systems. The system will continue to function until the free blocks or inodes are eaten away, which ever occurs earlier. The total free space in the system is the sum of the free blocks of the four file systems.

Q8(b).With reference to unix file system, explain different blocks of which it is made up of.ANS:

After the disk has been partitioned, it is still not ready for use. A file system has to be created in each partition. There usually are multiple file systems in one machine, each one having its own directory tree headed by root. Every file system is organized in a sequence of 512 bytes each, and will have these four components:-

1. The Boot block:- This block contains a small boot programs.2. The Superblock:- It contains global information about the file system.

Additionally it also maintains a free list of inodes and the data blocks which can be immediately allocated by the kernel when creating a file.

3. The inode block:- This region contains a table for every file of the file system. All attributes of a file and directory are stored in this area except the name of the file or directory itself.

4. The Data block:- All data and programs created by the user reside in this area.

THE BOOT BLOCK:-Preceding the inode blocks are only two blocks. The first block is known as the

boot block, containing a small bootstrap program. This is the master boot record that DOS users would like to call it. This is loaded into memory when the system is booted. It may, in turn load another program from the disk, but eventually it will load the kernel into the memory. However the bootstrapping program is read in from boot block of the root file system. For other file systems, this block is simply kept empty.

THE SUPER BLOCK:-

Page 25: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

The boot block is followed by super block, the “balance sheet” of every file system. The kernel first reads this area before allocating disk blocks and inodes for new files. The superblock contains global file information about the disk usage and availability of data blocks and inodes. It mainly contains:

1. The size of file system.2. The length of the disk block.3. Last time of updation.4. The number of free data blocks available.5. A partially list of immediately allocable free data blocks.6. number of free inodes available.7. A partial list of immediately usable inodes.

When a file is created, the kernel doesn’t have to scan the inode block to look for the free inode; it looks up the list available in the super block instead. The efficiency of the system is greatly increased as the list is always updated, and hence quite reliable. The kernel read and writes the copy of the superblock in the memory when controlling allocation of inodes and data blocks.

THE INODE BLOCK:-A certain area of every file system is always set aside to store the attributes of

all files in that file system. This set of attributes is stored in a fixed format structure called the inode. Every file has one inode, and a list of such inodes is laid out contiguously in an area of the disk not accessible directly by any user. Each Inode is accessed by a number called inode number.CONTENTS OF INODE:-Every file or directory has an inode, which contains all that you could possibly need to know about a file, except its name and contents. More specifically, each node contains the following attributes of the file:-

1. File type (regular, directory).2. Number of links(the number of aliases a field has).3. Owner (the user-id number of the owner)4. Group (the group id number).5. File mode (the triad of three permission).6. Number of bytes in the file.7. Date and time of last modification.8. Date and time of last access.9. Date and time of last change of the inode.10. An array of 13 pointers of the file.

Page 26: Q5) - schoolmca - HOMEschoolmca.weebly.com/uploads/4/5/0/8/450802/model_p…  · Web viewBourne shell- this shell is named after Steve bourne. It is one of the earliest shells that

Observe neither the file name nor its I number is stored in the inode. The name and I-number are found in the directory which houses the file. The I-number is actually the position of the inode in the inode array, and hence can be located using simple arithmetic.

THE DATA BLOCK:-Pure data is stored in the data blocks, which commence from the point the inode

blocks terminate. There is no mark at the end of the data to indicate that reading or writing should stop at that point; a file doesn’t contain the end of file mark. Apart from this direct data blocks, there are also indirect blocks which contain the address of direct data blocks. The inode maintains the list of these indirect block addresses.

Q8(c)With an example explain cpio command.ANS:

Cpio:- This command can be used to copy files to and from a backup device. It uses standard input to take the list of filenames, and then copies them with their contents and headers, into a single archive that is written to the standard output.Options of cpio command.

OPTIONS SIGNIFICANCE-d Creates directories as and when needed.-c Writes header information in ASCII-r Renames file in interactive manner-t List of files in archive-u Overwrites newer files with older version.-v Verbose option- displays the list of files-m Retains original file modification time-f exp Copies all files except those in exp-Csize Sets input-output block size to size byte.