Unix-T1 Solution 1 a.With a neat diagram, explain the architecture of Unix operating system. (4 marks) Ans: The unix architecture mainly consists of of 3 divisions: Division of labor:Kernel and Shell Division of labor between two agencies the kernel and shell.The kernel interacts with the machine's hardware, and the shell with the user.The kernel is core of operating system-a collection of routines mostly written in C.It is loaded into memory when the system is booted and communicates directly with the hardwarte.User programs-To use the hardware through a set of functions called the system calls.Kernel manages the system's memory,schedules processes,decides their priorities and performs other tasks.This is called the operating system-a program's gateway to the computer's resources.Command interpreter is actually the interface between the user and kernel. User User User Shell Kernel Hardware Kernel-Shell relationship diagram The file and process Two simple entities support the Unix system-the file and process where files have places and processes have life.A file is just an array of bytes and can contain virtually anything.It contains directories and dominant file type is text.The secondary entity is the process,which is the name given to a file when it is executed as a program.Processes have parents,chidren and grandchildren,and are born and die. The system calls These are handful of functions used to communicate with the kernel.All UNIX flavours use the same system calls.These system calls are built into the kernel,and interaction through them represents an efficient means of communication with the system. (3 points and diagram each 1 mark) b.Discuss the salient features of Unix operating system. (6 marks) Ans: The following are major features of the unix operating system. A multiuser system A multitasking system The building block approach The unix toolkit Pattern matching Programming facility Documentation (Each 1 mark with explanation of 2-3 lines) 2 a.Explain absolute pathname and relative pathname with example. (4 marks) Ans:Absolute pathname: (2 marks) If the first character of the pathname is /,the file's location must be determined with respect to root(the first /).Such a pathname is called as absolute pathname.(Eg:/home/kumar/login.sql).When we have more than one / in a pathname,for each such /,you have to descend one level in the file system.No two files in a UNIX system can have identical absolute pathnames. Using absolute pathname for a command: Eg; $ /bin/date Relative pathname: (2 marks) If the first character of the pathname is not /,.Such a pathname is called as relative pathname.Relative pathnamkes can be distinguished using . and . . in the pathname. . (a single dot) --This represents the current directory . . (two dots) – This represents the parent directory cd .. ---Moves one level up cd../.. ---Moves two levels up cd.. A filename can begin with a dot cp ../sharma/.profile b.With the help of diagram explain the parent child relationship.Explain the unix file system. (6 marks) (2+4) Ans:The unix file system can be grouped into two categories: The files available at installation: /bin and /usr/bin /sbin and /usr/sbin /etc /dev /lib and /usr/lib /usr/include /usr/share/man The temporary files: /tmp /var /home All files in unix are related to one another.The file system in unix is a collection of all of these related files (ordinary,directory and device files)organized in a hierarchical structure.The implicit feature of file system is it consists of the top which is a reference point for all files.this top is called root and is represented as /(frontslash).Root is actually a directory and it has a number of sub directories under it as seen in the diagram.It is obvious that,in these parent-child relationships,the parent is always a directory and child an ordinary file. Root(/) bin cat date dev etc who home lib sbin stand kumar sharma unix tmp usr var bin include sbin login.sql progs safe The unix file system tree diagram 3 a. Explain the different modes of operation in vi editor. (5 marks) Ans:vi editor mainly consists of 3 modes: Command mode:The default mode of the editor where every key pressed is interpreted as a command to run on text.This mode is used to copy and delete the text. Input mode:Every key pressed after switching to this mode actually shows up as text.This mode is invoked by pressing any one of the following keys:-(i,a,IA,o,O,R,S,s,rch) ex mode(Last Line mode):This mode is used to handle the files and perform substitution.pressing a : in the command mode invokes this mode.This is carried out by pressing any one of the following keys:-(:w,:x,:wq,:q) Input mode ex mode Command mode Shell The three modes of vi editor diagram b.List and explain the attributes of ls-l option. Ans:File attributes of ls-l File type and permissions Links Ownership Group ownership File size Last modification time File name (5 marks) 4 a.ELAIN THE USE OF CHM9OD COMMAND TO CHANGE THE FILE PERMISSIONS WITH SUITABLE EXAMPLES (6 marks) Ans:The chmod(change mode) command is used to set the permissions of one or more files for all three categories of users(user,group and others).It can be run only by the user (the owner) and the superuser.The command can be used in two ways: In a relative manner by specifying the changes to the current permissions. ◦ (u-user,g-group,o-others,a-All ugo) ◦ (r-read,w-Write,x-Execute permission) ◦ +assigns permissions ◦ -removes permission ◦ Examples:chmod o +wx filename ;chmod ug-x,o+rw filename In a absolute manner by specifying the final permissions. ◦ (0 to 7) ◦ File permissions in the form of numbers(read-4,write-2,execute-1)) ◦ Examples:chmod 555 filename; chmod 776 filename b.Give commands for the following in vi editor with examples.(4 marks) 1) To replace text from cursor to right--R 2) To execute a shell command while in editor --:sh 3) To move forward to the beginning of next word--w 4)To move to the 10th line---10k 5 a.Explain the three standard files with respect to UNIX operating system. (6 marks) Ans:The shell associates three files with the terminal-two for the display and one for the keyboard.These special files are actually streams of characters which many commads see as input and output.A stream is simply a sequence of bytes.Each stream is associated with a default device, and generically this device is a terminal. Standard Input Standard Output Stansard Error b.With suitable examples,discuss how wild cards can be used for pattern matching in UNIX. (6 marks) Ans:The metacharacters that are used to construct the generalized pattern for matching filenames belong to a category called wild cards.This pattern is framed with ordinary characters and a metacharacter using well defined rules.The pattern can then be used as an argument to the command,and the shell will expand it suitably before the command is executed. Explanation of the following wild cards with examples. * ? [ijk] [x-z] [!ijk] [!x-z]