Unix Viva Questions
Unix Viva Questions
Unix Viva Questions
com 36
How can you tell what shell you are running on UNIX system?
You can do the Echo $RANDOM. It will return a undefined variable if you are from the C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers if you are from the Korn shell. You could also do a ps -l and look for the shell with []
What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices?
Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices in Unix System V.
www.jntuworld.com
www.jntuworld.com 37
Explain the layered aspect of a UNIX system. What are the layers? What does it mean to say they are layers?
A UNIX system has essentially three main layers: . The hardware . The operating system kernel . The user-level programs The kernel hides the systems hardware underneath an abstract, high-level programming interface. It is responsible for implementing many of the facilities that users and user-level programs take for granted. The kernel assembles all of the following UNIX concepts from lower-level []
www.jntuworld.com
www.jntuworld.com 38 It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.
How to terminate a process which is running and the specialty on command kill 0?
With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 - kills all processes in your system except the login shell.
www.jntuworld.com
www.jntuworld.com 39
What does the command $who | sort logfile > newfile do?
The input from a pipe can be combined with the input from a file . The trick is to use the special symbol - (a hyphen) for those commands that recognize the hyphen as std input. In the above command the output from who becomes the std input to sort , meanwhile sort opens the file []
How the Kernel handles the copy on write bit of a page, when the bit is set?
In situations like, where the copy on write bit of a page is set and that page is shared by more than one process, the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page. After copying the Kernel updates the page []
www.jntuworld.com
www.jntuworld.com 40 During the fork() system call the Kernel makes a copy of the parent processs address space and attaches it to the child process.But the vfork() system call do not makes any copy of the parents address space, so it is faster than the fork() system call. The child process as a result of the vfork() []
How the Kernel handles the fork() system call in traditional Unix and in the System V Unix, while swapping?
Kernel in traditional Unix, makes the duplicate copy of the parents address space and attaches it to the childs process, while swapping. Kernel in System V Unix, manipulates the region tables, page table, and pfdata table entries, by incrementing the reference count of the region table of shared regions.
What are the entities that are swapped out of the main memory while swapping the process out of the main memory?
www.jntuworld.com
www.jntuworld.com 41 All memory space occupied by the process, processs u-area, and Kernel stack are swapped out, theoretically. Practically, if the processs u-area contains the Address Translation Tables for the process then Kernel implementations do not swap the u-area.
Is the Process before and after the swap are the same? Give reason.
Process before swapping is residing in the primary memory in its original form. The regions (text, data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the process outAfter swapping []
What are the events done by the Kernel after a process is being swapped out from the main memory?
When Kernel swaps the process out of the primary memory, it performs the following: Kernel decrements the Reference Count of each region of the process. If the reference count becomes zero, swaps the region out of the main memory. Kernel allocates the space for the swapping process in the swap device. Kernel locks the other swapping process while []
What is major difference between the Historic Unix and the new BSD release of Unix System V in terms of Memory Management?
Historic Unix uses Swapping entire process is transferred to the main memory from the swap device, whereas the Unix System V uses Demand Paging only the part of the process is moved to the main memory. Historic Unix uses one Swap Device and Unix System V allow multiple Swap Devices
www.jntuworld.com
www.jntuworld.com
www.jntuworld.com 43
What is a zombie?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the childs exit status. To be able to get this information, the parent calls `wait(); In the []
Brief about the initial process sequence while the system boots up.
www.jntuworld.com
www.jntuworld.com 44 While booting, special process called the swapper or scheduler is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children: the process dispatcher,vhand and dbflush with IDs 1,2 and 3 respectively. This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. []
www.jntuworld.com
www.jntuworld.com 45
What is a shell?
A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS []
How do you create special files like named pipes and device files?
The system call mknod creates special files in the following sequence. 1. kernel assigns new inode, 2. sets the file type to indicate that the file is a pipe, directory or special file, 3. If it is a device file, it makes the other entries like major, minor device numbers. For example: If the device is a disk, major []
www.jntuworld.com
www.jntuworld.com 46 Symbolic link is a file that only contains the name of another file.Operation []
What is a zombie?
When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the childs exit status. To be able to get this information, the parent calls `wait(); In the []
www.jntuworld.com
www.jntuworld.com 47 A parent and child can communicate through any of the normal inter-process communication schemes (pipes, sockets, message queues, shared memory), but also have some special ways to communicate that take advantage of their relationship as a parent and child. One of the most obvious is that the parent can get the exit status of the []
Brief about the initial process sequence while the system boots up.
While booting, special process called the swapper or scheduler is created with Process-ID 0. The swapper manages memory allocation for processes and influences CPU allocation. The swapper inturn creates 3 children: the process dispatcher,vhand and dbflush with IDs 1,2 and 3 respectively. This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. []
What is a shell?
www.jntuworld.com
www.jntuworld.com 48 A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them to system calls to the OS or forks off a process to execute the command. System call results and other information from the OS []
How do you create special files like named pipes and device files?
The system call mknod creates special files in the following sequence. 1. kernel assigns new inode, 2. sets the file type to indicate that the file is a pipe, directory or special file, 3. If it is a device file, it makes the other entries like major, minor device numbers. For example: If the device is a disk, major []
What is a FIFO?
FIFO are otherwise called as named pipes. FIFO (first-in-firstout) is a special file which is said to be data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the order written. It is used in interprocess communication where a process writes to one end of []
www.jntuworld.com
www.jntuworld.com 49
What is inode?
All UNIX files have its description stored in a structure called inode. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers []
www.jntuworld.com
www.jntuworld.com 50
What is inode?
All UNIX files have its description stored in a structure called inode. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers []
www.jntuworld.com
www.jntuworld.com 51
$cat >file means to create a new file $cat file means to open an existing file.
Answered By: selva,ravi Date: 7/13/2007
cat > file it means creating file for file cat file it means used to display the file content
Explain the steps that a shell follows while processing a command. When processing a command the searchs for the utility for the command in the directories specified in the PATH varible and it in invokes that utility. That utility will execute the command with help of kernel and the output is given to shell. And then the displays out put to the user.
Answer
Explain the steps that a shell follows while processing a command. When processing a command the searchs for the utility for the command in the directories specified in the PATH varible and it in invokes that utility. That utility will execute the command with help of kernel and the output is given to shell. And then the displays out put to the user.
Answer
Which command is used to delete all files in the current directory and all its subdirectories?
rm -r *
www.jntuworld.com
www.jntuworld.com 52
Answer
Yes you are correct. It stands for listing the files Chapter with suffix 1 to 5 but it will display the files in columns as with-x option.
How does the kernel differentiate device files and ordinary files?
Device filles are of 2 types --- charcater device file and block device file type field in the file's inode structure Answer b--- block device file c--- character device file
Answer
Use su command. The system asks for password and when valid entry is made the user gains super user (admin) privileges.
Answer
Shell variables are system environment variables.They include TERM,SHELL, MAIL the output of the shell variable we can see by typing the command
www.jntuworld.com
www.jntuworld.com 53
What is redirection?
Redirection is a feature in Unix where the data from the standard out put or a file,so on.can be redirected i.e divert to a file or a program and vice versa. Answer > -- out put redirection >> -- out put redirectin(appending at the last) < -- input redirection
How to terminate a process which is running and the specialty on command kill 0?
Answer
With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 - kills all processes in your system except the login shell.
How to terminate a process which is running and the specialty on command kill 0?
Answer
With the help of kill command we can terminate the process. Syntax: kill pid Kill 0 - kills all processes in your system except the login shell.
www.jntuworld.com
www.jntuworld.com 54
Answer
Df and du commands are used for checking free space on disk . df -h or df -Humanreadable gives human readable format of free space.
What is the difference between soft link and hard link in unix operating system ?
Hard Links : 1. All Links have same inode number. 2.ls -l command shows all the links with the link column(Second) shows No. of links. 3. Links have actual file contents 4.Removing any link ,just reduces the link count , but doesn't affect other links. Answer Soft Links(Symbolic Links) : 1.Links have different inode numbers. 2. ls -l command shows all links with second column value 1 and the link points to original file. 3. Link has the path for original file and not the contents. 4.Removing soft link doesn't affect anything but removing original file ,the link becomes "dangling" link which points to nonexistant file.
For concatenating two string we use cat command. Answer Ex:- cat str1 str2
www.jntuworld.com
www.jntuworld.com 55
Answer
UNIX Kernel is heart of the operating system. UNIX kernal is loaded first when UNIX system is booted. It handles allocation of devices, cpu, memory from that ponint on.
Unix/ Linux Supports four Prompts PS1, PS2, PS3, PS4 Answer #,@,$,% are 4 prompts
REFERENCES: Books:
1)Introduction to UNIX & SHELL programming, M.G. Venkatesh Murthy, Pearson Education. 2)Unix concepts and applications, Fourth Edition, Sumitabha Das, TMH.
www.jntuworld.com