Unix Viva Questions

Embed Size (px)

Citation preview

  • 8/2/2019 Unix Viva Questions

    1/20

    w.jntuworld.com

    36

    Viva Questions & Answers

    What is a Make file?

    Make file is a utility in Unix to help compile large programs. It helps by only compilingthe portion of the program that has been changed

    Could you tell something about the Unix System Kernel?

    The kernel is the heart of the UNIX operating system, itsresponsible for controlling the computers resources andscheduling user jobs so that each one gets its fair share ofresources.

    How can you tell what shell you are running on UNIXsystem?

    You can do the Echo $RANDOM. It will return a undefinedvariable if you are from the C-Shell, just a return prompt if youare from the Bourne shell, and a 5 digit random numbers if youare from the Korn shell. You could also do a ps -l and look forthe shell with []

    What do you mean by u-area (user area) or u-block?This contains the private data that is manipulated only by theKernel. This is local to the Process, i.e. each process isallocated a u-area.

    What scheme does the Kernel in Unix System V follow whilechoosing a swap device among the multiple swap devices?

    Kernel follows Round Robin scheme choosing a swap deviceamong the multiple swap devices in Unix SystemV.

    List the system calls used for process management:

    System calls Descriptionfork() To create a new processexec() To execute a new program in a processwait() []

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-make-file-2/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/could-you-tell-something-about-the-unix-system-kernel/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/how-can-you-tell-what-shell-you-are-running-on-unix-system-2/http://kyapoocha.com/unix-interview-questions/how-can-you-tell-what-shell-you-are-running-on-unix-system-2/http://kyapoocha.com/unix-interview-questions/what-do-you-mean-by-u-area-user-area-or-u-block/http://kyapoocha.com/unix-interview-questions/what-scheme-does-the-kernel-in-unix-system-v-follow-while-choosing-a-swap-device-among-the-multiple-swap-devices/http://kyapoocha.com/unix-interview-questions/what-scheme-does-the-kernel-in-unix-system-v-follow-while-choosing-a-swap-device-among-the-multiple-swap-devices/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/list-the-system-calls-used-for-process-management/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-make-file-2/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/could-you-tell-something-about-the-unix-system-kernel/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/how-can-you-tell-what-shell-you-are-running-on-unix-system-2/http://kyapoocha.com/unix-interview-questions/how-can-you-tell-what-shell-you-are-running-on-unix-system-2/http://kyapoocha.com/unix-interview-questions/what-do-you-mean-by-u-area-user-area-or-u-block/http://kyapoocha.com/unix-interview-questions/what-scheme-does-the-kernel-in-unix-system-v-follow-while-choosing-a-swap-device-among-the-multiple-swap-devices/http://kyapoocha.com/unix-interview-questions/what-scheme-does-the-kernel-in-unix-system-v-follow-while-choosing-a-swap-device-among-the-multiple-swap-devices/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/list-the-system-calls-used-for-process-management/
  • 8/2/2019 Unix Viva Questions

    2/20

    w.jntuworld.com

    37

    How do you change File Access Permissions?

    Every file has following attributes:owners user ID ( 16 bit integer )owners group ID ( 16 bit integer )

    File access mode wordr w x -r w x- r w x(user permission-group permission-others permission)r-read, w-write, x-executeTo change the access mode, we use chmod(filename,mode).Example:To change mode of myfile to rw-rw-r (ie. read, writepermission for user - []

    Explain the layered aspect of a UNIX system. What are thelayers? 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 programsThe kernel hides the systems hardware underneath anabstract, high-level programming interface. It is responsible forimplementing many of the facilities that users and user-levelprograms take for granted.The kernel assembles all of the following UNIX concepts fromlower-level []

    What is the use of grep command?

    grep is a pattern search command. It searches for the pattern,specified in the command line with appropriate option, in afile(s).Syntax : grep Example : grep 99mx mcafile

    What difference between cmp and diff commands?

    cmp - Compares two files byte by byte and displays the first

    mismatchdiff - tells the changes to be made to make the files identical

    What is the significance of the tee command?

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-do-you-change-file-access-permissions/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/explain-the-layered-aspect-of-a-unix-system-what-are-the-layers-what-does-it-mean-to-say-they-are-layers/http://kyapoocha.com/unix-interview-questions/explain-the-layered-aspect-of-a-unix-system-what-are-the-layers-what-does-it-mean-to-say-they-are-layers/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/unix-interview-questions/what-is-the-use-of-%E2%80%98grep%E2%80%99-command/http://kyapoocha.com/unix-interview-questions/what-difference-between-cmp-and-diff-commands/http://kyapoocha.com/unix-interview-questions/what-is-the-significance-of-the-%E2%80%9Ctee%E2%80%9D-command/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-do-you-change-file-access-permissions/http://kyapoocha.com/category/unix-interview-questions/http://kyapoocha.com/unix-interview-questions/explain-the-layered-aspect-of-a-unix-system-what-are-the-layers-what-does-it-mean-to-say-they-are-layers/http://kyapoocha.com/unix-interview-questions/explain-the-layered-aspect-of-a-unix-system-what-are-the-layers-what-does-it-mean-to-say-they-are-layers/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/unix-interview-questions/what-is-the-use-of-%E2%80%98grep%E2%80%99-command/http://kyapoocha.com/unix-interview-questions/what-difference-between-cmp-and-diff-commands/http://kyapoocha.com/unix-interview-questions/what-is-the-significance-of-the-%E2%80%9Ctee%E2%80%9D-command/
  • 8/2/2019 Unix Viva Questions

    3/20

    w.jntuworld.com

    38

    It reads the standard input and sends it to the standard outputwhile redirecting a copy of what it has read to the file specifiedby the user.

    Is du a command? If so, what is its use?

    Yes, it stands for disk usage. With the help of this commandyou can find the disk capacity and free space of the disk.

    How to terminate a process which is running and thespecialty 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 exceptthe login shell.

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/is-%E2%80%98du%E2%80%99-a-command-if-so-what-is-its-use/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/unix-interview-questions/how-to-terminate-a-process-which-is-running-and-the-specialty-on-command-kill-0/http://kyapoocha.com/unix-interview-questions/how-to-terminate-a-process-which-is-running-and-the-specialty-on-command-kill-0/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/is-%E2%80%98du%E2%80%99-a-command-if-so-what-is-its-use/http://kyapoocha.com/category/unix-interview-questions/page/2/http://kyapoocha.com/unix-interview-questions/how-to-terminate-a-process-which-is-running-and-the-specialty-on-command-kill-0/http://kyapoocha.com/unix-interview-questions/how-to-terminate-a-process-which-is-running-and-the-specialty-on-command-kill-0/
  • 8/2/2019 Unix Viva Questions

    4/20

    w.jntuworld.com

    39

    Explain kill() and its possible return values.

    There are four possible results from this call:kill() returns 0. This implies that a process exists with the given

    PID, and the system would allow you to send signals to it. It issystem-dependent whether the process could be a zombie.kill() returns -1, errno == ESRCH either no process exists withthe given PID, or []

    What does the command $who | sort logfile > newfiledo?

    The input from a pipe can be combined with the input from afile . The trick is to use the special symbol - (a hyphen) forthose commands that recognize the hyphen as std input.

    In the above command the output from who becomes the stdinput to sort , meanwhile sort opens the file []

    What are shell variables?

    Shell variables are special variables, a name-value pair createdand maintained by the shell.Example: PATH, HOME, MAIL and TERM

    How many prompts are available in a UNIX system?

    Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).

    Is it possible to create new a file system in UNIX?

    Use su command. The system asks for password and whenvalid entry is made the user gains super user (admin) privileges.

    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 setand that page is shared by more than one process, the Kernelallocates new page and copies the content to the new page andthe other processes retain their references to the old page. Aftercopying the Kernel updates the page []

    Difference between the fork() and vfork() system call?

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/explain-kill-and-its-possible-return-values/http://kyapoocha.com/unix-interview-questions/what-does-the-command-%E2%80%9C-who-sort-%E2%80%93logfile-newfile%E2%80%9D-do/http://kyapoocha.com/unix-interview-questions/what-does-the-command-%E2%80%9C-who-sort-%E2%80%93logfile-newfile%E2%80%9D-do/http://kyapoocha.com/unix-interview-questions/what-are-shell-variables/http://kyapoocha.com/unix-interview-questions/how-many-prompts-are-available-in-a-unix-system/http://kyapoocha.com/unix-interview-questions/is-it-possible-to-create-new-a-file-system-in-unix/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-copy-on-write-bit-of-a-page-when-the-bit-is-set/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-copy-on-write-bit-of-a-page-when-the-bit-is-set/http://kyapoocha.com/unix-interview-questions/difference-between-the-fork-and-vfork-system-call/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/explain-kill-and-its-possible-return-values/http://kyapoocha.com/unix-interview-questions/what-does-the-command-%E2%80%9C-who-sort-%E2%80%93logfile-newfile%E2%80%9D-do/http://kyapoocha.com/unix-interview-questions/what-does-the-command-%E2%80%9C-who-sort-%E2%80%93logfile-newfile%E2%80%9D-do/http://kyapoocha.com/unix-interview-questions/what-are-shell-variables/http://kyapoocha.com/unix-interview-questions/how-many-prompts-are-available-in-a-unix-system/http://kyapoocha.com/unix-interview-questions/is-it-possible-to-create-new-a-file-system-in-unix/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-copy-on-write-bit-of-a-page-when-the-bit-is-set/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-copy-on-write-bit-of-a-page-when-the-bit-is-set/http://kyapoocha.com/unix-interview-questions/difference-between-the-fork-and-vfork-system-call/
  • 8/2/2019 Unix Viva Questions

    5/20

    w.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 childprocess as a result of the vfork() []

    How the Kernel handles the fork() system call in traditionalUnix and in the System V Unix, while swapping?

    Kernel in traditional Unix, makes the duplicate copy of theparents address space and attaches it to the childs process,while swapping. Kernel in System V Unix, manipulates theregion tables, page table, and pfdata table entries, byincrementing the reference count of the region table of sharedregions.

    What are the requirements for a swapper to work?

    The swapper works on the highest scheduling priority. Firstly itwill look for any sleeping process, if not found then it will look forthe ready-to-run process for swapping. But the majorrequirement for the swapper to work the ready-to-run processmust be core-resident for at least 2 seconds before swappingout. And for swapping []

    What is Expansion swap?

    At the time when any process requires more memory than it is

    currently allocated, the Kernel performs Expansion swap. To dothis Kernel reserves enough space in the swap device. Then theaddress translation mapping is adjusted for the new virtualaddress space but the physical memory is not allocated. At lastKernel swaps the []

    What is Fork swap?

    fork() is a system call to create a child process. When the parentprocess calls fork() system call, the child process is created andif there is short of memory then the child process is sent to the

    read-to-run state in the swap device, and return to the user statewithout swapping the parent process. []

    What are the entities that are swapped out of the mainmemory while swapping the process out of the mainmemory?

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-fork-system-call-in-traditional-unix-and-in-the-system-v-unix-while-swapping/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-fork-system-call-in-traditional-unix-and-in-the-system-v-unix-while-swapping/http://kyapoocha.com/unix-interview-questions/what-are-the-requirements-for-a-swapper-to-work/http://kyapoocha.com/unix-interview-questions/what-is-expansion-swap/http://kyapoocha.com/unix-interview-questions/what-is-fork-swap/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-fork-system-call-in-traditional-unix-and-in-the-system-v-unix-while-swapping/http://kyapoocha.com/unix-interview-questions/how-the-kernel-handles-the-fork-system-call-in-traditional-unix-and-in-the-system-v-unix-while-swapping/http://kyapoocha.com/unix-interview-questions/what-are-the-requirements-for-a-swapper-to-work/http://kyapoocha.com/unix-interview-questions/what-is-expansion-swap/http://kyapoocha.com/unix-interview-questions/what-is-fork-swap/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-entities-that-are-swapped-out-of-the-main-memory-while-swapping-the-process-out-of-the-main-memory/
  • 8/2/2019 Unix Viva Questions

    6/20

    w.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 AddressTranslation Tables for the process then Kernel implementationsdo not swap the u-area.

    Is the Process before and after the swap are the same? Givereason.

    Process before swapping is residing in the primary memory inits original form. The regions (text, data and stack) may not beoccupied fully by the process, there may be few empty slots inany of the regions and while swapping Kernel do not botherabout the empty slots while swapping the process outAfterswapping []

    What are the events done by the Kernel after a process isbeing swapped out from the main memory?

    When Kernel swaps the process out of the primary memory, itperforms the following:Kernel decrements the Reference Count of each region of theprocess. If the reference count becomes zero, swaps the regionout of the main memory.Kernel allocates the space for the swapping process in the swapdevice.Kernel locks the other swapping process while []

    What is major difference between the Historic Unix and thenew BSD release of Unix System V in terms of MemoryManagement?

    Historic Unix uses Swapping entire process is transferred tothe main memory from the swap device, whereas the UnixSystem V uses Demand Paging only the part of the process ismoved to the main memory. Historic Unix uses one SwapDevice and Unix System V allow multiple Swap Devices

    What is an advantage of executing a process inbackground?

    The most common reason to put a process in the background isto allow you to do something else interactively without waitingfor the process to complete. At the end of the command you addthe special background symbol, &. This symbol tells your shell

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/is-the-process-before-and-after-the-swap-are-the-same-give-reason/http://kyapoocha.com/unix-interview-questions/is-the-process-before-and-after-the-swap-are-the-same-give-reason/http://kyapoocha.com/unix-interview-questions/what-are-the-events-done-by-the-kernel-after-a-process-is-being-swapped-out-from-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-events-done-by-the-kernel-after-a-process-is-being-swapped-out-from-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-an-advantage-of-executing-a-process-in-background/http://kyapoocha.com/unix-interview-questions/what-is-an-advantage-of-executing-a-process-in-background/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/is-the-process-before-and-after-the-swap-are-the-same-give-reason/http://kyapoocha.com/unix-interview-questions/is-the-process-before-and-after-the-swap-are-the-same-give-reason/http://kyapoocha.com/unix-interview-questions/what-are-the-events-done-by-the-kernel-after-a-process-is-being-swapped-out-from-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-are-the-events-done-by-the-kernel-after-a-process-is-being-swapped-out-from-the-main-memory/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-major-difference-between-the-historic-unix-and-the-new-bsd-release-of-unix-system-v-in-terms-of-memory-management/http://kyapoocha.com/unix-interview-questions/what-is-an-advantage-of-executing-a-process-in-background/http://kyapoocha.com/unix-interview-questions/what-is-an-advantage-of-executing-a-process-in-background/
  • 8/2/2019 Unix Viva Questions

    7/20

    w.jntuworld.com

    42

    to execute the given command in the background.Example: cp *.* []

    What Happens when you execute a program?

    When you execute a program on your UNIX system, the systemcreates a special environment for that program. Thisenvironment contains everything needed for the system to runthe program as if no other program were running on the system.Each process has process context, which is everything that isunique about the state of []

    What are the process states in Unix?

    As a process executes it changes state according to itscircumstances. Unix processes have the following states:

    Running : The process is either running or it is ready to run .Waiting : The process is waiting for an event or for a resource.Stopped : The process has been stopped, usually by receiving asignal.Zombie : The []

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-happens-when-you-execute-a-program/http://kyapoocha.com/unix-interview-questions/what-are-the-process-states-in-unix/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-happens-when-you-execute-a-program/http://kyapoocha.com/unix-interview-questions/what-are-the-process-states-in-unix/
  • 8/2/2019 Unix Viva Questions

    8/20

    w.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 mayneed to check the childs exit status. To be able to get thisinformation, the parent calls `wait(); In the []

    How can a parent and child process communicate?

    A parent and child can communicate through any of the normalinter-process communication schemes (pipes, sockets,message queues, shared memory), but also have some specialways to communicate that take advantage of their relationshipas a parent and child. One of the most obvious is that the parent

    can get the exit status of the []

    How can you get/set an environment variable from aprogram?

    Getting the value of an environment variable is done by using`getenv().Setting the value of an environment variable is done by using`putenv().

    Explain fork() system call.

    The `fork() used to create a new process from an existingprocess. The new process is called the child process, and theexisting process is called the parent. We can tell which is whichby checking the return value from fork(). The parent gets thechilds pid returned to him, but []

    What are various IDs associated with a process?

    Unix identifies each process with a unique integer calledProcessID. The process that executes the request for creationof a process is called the parent process whose PID is ParentProcess ID. Every process is associated with a particular usercalled the owner who has privileges over the process. Theidentification for the user is []

    Brief about the initial process sequence while the systemboots up.

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-zombie/http://kyapoocha.com/unix-interview-questions/how-can-a-parent-and-child-process-communicate/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/explain-fork-system-call/http://kyapoocha.com/unix-interview-questions/what-are-various-ids-associated-with-a-process/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-zombie/http://kyapoocha.com/unix-interview-questions/how-can-a-parent-and-child-process-communicate/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/explain-fork-system-call/http://kyapoocha.com/unix-interview-questions/what-are-various-ids-associated-with-a-process/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/
  • 8/2/2019 Unix Viva Questions

    9/20

    w.jntuworld.com

    44

    While booting, special process called the swapper orscheduler is created with Process-ID 0. The swapper managesmemory 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 dispatchergives birth to the shell. []

    www.jntuworld.com

    http://www.jntuworld.com/http://www.jntuworld.com/
  • 8/2/2019 Unix Viva Questions

    10/20

    w.jntuworld.com

    45

    What is a shell?

    A shell is an interactive user interface to an operating systemservices 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 aprocess to execute the command. System call results and otherinformation from the OS []

    How does the inode map to data block of a file?

    Inode has 13 block addresses. The first 10 are direct blockaddresses of the first 10 data blocks in the file. The 11thaddress points to a one-level index block. The 12th addresspoints to a two-level (double in-direction) index block. The 13th

    address points to a three-level(triple in-direction)index block.This provides a very large maximum []

    Discuss the mount and unmount system calls

    The privileged mount system call is used to attach a file systemto a directory of another file system; the unmount system calldetaches a file system. When you mount another file system onto your directory, you are essentially splicing one directory treeonto a branch in another directory tree. The first argument to[]

    How do you create special files like named pipes and devicefiles?

    The system call mknod creates special files in the followingsequence.1. kernel assigns new inode,2. sets the file type to indicate that the file is a pipe, directory orspecial file,3. If it is a device file, it makes the other entries like major, minordevice numbers.

    For example: If the device is a disk, major []

    What are links and symbolic links in UNIX file system?

    A link is a second name (not a file) for a file. Links can be usedto assign more than one name to a file, but cannot be used toassign a directory more than one name or link filenames ondifferent computers.

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-shell/http://kyapoocha.com/unix-interview-questions/how-does-the-inode-map-to-data-block-of-a-file/http://kyapoocha.com/unix-interview-questions/discuss-the-mount-and-unmount-system-calls/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/what-are-links-and-symbolic-links-in-unix-file-system/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-is-a-shell/http://kyapoocha.com/unix-interview-questions/how-does-the-inode-map-to-data-block-of-a-file/http://kyapoocha.com/unix-interview-questions/discuss-the-mount-and-unmount-system-calls/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/what-are-links-and-symbolic-links-in-unix-file-system/
  • 8/2/2019 Unix Viva Questions

    11/20

    w.jntuworld.com

    46

    Symbolic link is a file that only contains the name of anotherfile.Operation []

    What are the Unix system calls for I/O?

    open(pathname,flag,mode) - open filecreat(pathname,mode) - create fileclose(filedes) - close an open fileread(filedes,buffer,bytes) - read data from an open filewrite(filedes,buffer,bytes) - write data to an open filelseek(filedes,offset,from) - position an open filedup(filedes) - duplicate an existing file descriptordup2(oldfd,newfd) - duplicate to a desired file descriptorfcntl(filedes,cmd,arg) - change properties of an open fileioctl(filedes,request,arg) - change the behaviour []

    What Happens when you execute a program?

    When you execute a program on your UNIX system, thesystem creates a special environment for that program. Thisenvironment contains everything needed for the system to runthe program as if no other program were running on the system.Each process has process context, which is everything that isunique about the state of []

    What are the process states in Unix?

    As a process executes it changes state according to itscircumstances. Unixprocesses have the following states:Running : The process is either running or it is ready to run .Waiting : The process is waiting for an event or for a resource.Stopped : The process has been stopped, usually by receiving asignal.Zombie : The []

    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 incase the parent might need it - for example, the parent mayneed to check the childs exit status. To be able to get thisinformation, the parent calls `wait(); In the []

    How can a parent and child process communicate?

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-are-the-unix-system-calls-for-io/http://kyapoocha.com/unix-interview-questions/what-happens-when-you-execute-a-program/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-are-the-process-states-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-zombie/http://kyapoocha.com/unix-interview-questions/how-can-a-parent-and-child-process-communicate/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-are-the-unix-system-calls-for-io/http://kyapoocha.com/unix-interview-questions/what-happens-when-you-execute-a-program/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-are-the-process-states-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-zombie/http://kyapoocha.com/unix-interview-questions/how-can-a-parent-and-child-process-communicate/
  • 8/2/2019 Unix Viva Questions

    12/20

    w.jntuworld.com

    47

    A parent and child can communicate through any of the normalinter-process communication schemes (pipes, sockets,message queues, shared memory), but also have some specialways to communicate that take advantage of their relationshipas a parent and child. One of the most obvious is that the parent

    can get the exit status of the []

    How can you get/set an environment variable from aprogram?

    Getting the value of an environment variable is done byusing `getenv().Setting the value of an environment variable is done by using`putenv().

    Explain fork() system call.

    The `fork() used to create a new process from an existingprocess. The new process is called the child process, and theexisting process is called the parent. We can tell which is whichby checking the return value from fork(). The parent gets thechilds pid returned to him, but []

    What are various IDs associated with a process?

    Unix identifies each process with a unique integer calledProcessID. The process that executes the request for creation

    of a process is called the parent process whose PID is ParentProcess ID. Every process is associated with a particular usercalled the owner who has privileges over the process. Theidentification for the user is []

    Brief about the initial process sequence while the systemboots up.

    While booting, special process called the swapper orscheduler is created with Process-ID 0. The swapper managesmemory allocation for processes and influences CPU allocation.The swapper inturn creates 3 children:the process dispatcher,vhand and dbflush with IDs 1,2 and 3respectively.This is done by executing the file /etc/init. Process dispatchergives birth to the shell. []

    What is a shell?

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/explain-fork-system-call/http://kyapoocha.com/unix-interview-questions/what-are-various-ids-associated-with-a-process/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-shell/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/unix-interview-questions/how-can-you-getset-an-environment-variable-from-a-program/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/explain-fork-system-call/http://kyapoocha.com/unix-interview-questions/what-are-various-ids-associated-with-a-process/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/unix-interview-questions/brief-about-the-initial-process-sequence-while-the-system-boots-up/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-shell/
  • 8/2/2019 Unix Viva Questions

    13/20

    w.jntuworld.com

    48

    A shell is an interactive user interface to an operatingsystem services that allows an user to enter commands ascharacter strings or through a graphical user interface.The shell converts them to system calls to the OS or forks off aprocess to execute the command. System call results and other

    information from the OS []

    How does the inode map to data block of a file?

    Inode has 13 block addresses. The first 10 are direct blockaddresses of the first 10 data blocks in the file. The 11thaddress points to a one-level index block. The 12th addresspoints to a two-level (double in-direction) index block. The 13thaddress points to a three-level(triple in-direction)index block.This provides a very large maximum []

    Discuss the mount and unmount system calls

    The privileged mount system call is used to attach a filesystem to a directory of another file system; the unmountsystem call detaches a file system. When you mount another filesystem on to your directory, you are essentially splicing onedirectory tree onto a branch in another directory tree. The firstargument to []

    How do you create special files like named pipes and devicefiles?

    The system call mknod creates special files in the followingsequence.1. kernel assigns new inode,2. sets the file type to indicate that the file is a pipe, directoryor special file,3. If it is a device file, it makes the other entries like major, minordevice numbers.For example: If the device is a disk, major []

    What is a FIFO?

    FIFO are otherwise called as named pipes. FIFO (first-in-first-out) is a special file which is said to be data transient. Once datais read from named pipe, it cannot be read again.Also, data can be read only in the order written. It is used ininterprocess communication where a process writes to one endof []

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/how-does-the-inode-map-to-data-block-of-a-file/http://kyapoocha.com/unix-interview-questions/discuss-the-mount-and-unmount-system-calls/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-fifo/http://www.jntuworld.com/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/how-does-the-inode-map-to-data-block-of-a-file/http://kyapoocha.com/unix-interview-questions/discuss-the-mount-and-unmount-system-calls/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/unix-interview-questions/how-do-you-create-special-files-like-named-pipes-and-device-files/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-is-a-fifo/
  • 8/2/2019 Unix Viva Questions

    14/20

    w.jntuworld.com

    49

    What are links and symbolic links in UNIX file system?

    A link is a second name (not a file) for a file. Links can be usedto assign more than one name to a file, but cannot be used toassign a directory more than one name or link filenames on

    different computers.Symbolic link is a file that only contains the name of anotherfile.Operation []

    What are the Unix system calls for I/O?

    open(pathname,flag,mode) - open filecreat(pathname,mode) - create fileclose(filedes) - close an open fileread(filedes,buffer,bytes) - read data from an open filewrite(filedes,buffer,bytes) - write data to an open file

    lseek(filedes,offset,from) - position an open filedup(filedes) - duplicate an existing file descriptordup2(oldfd,newfd) - duplicate to a desired file descriptorfcntl(filedes,cmd,arg) - change properties of an open fileioctl(filedes,request,arg) - change the behaviour []

    Brief about the directory representation in UNIX

    s a file containing a correspondence between filenames andinodes. A directory is a special file that the kernel maintains.Only kernel modifies directories, but processes can read

    directories. The contents of a directory are a list of filename andinode number pairs. When new directories are created, kernelmakes two entries []

    What is inode?

    All UNIX files have its description stored in a structure calledinode. The inode contains info about the file-size, its location,time of last access, time of last modification, permission and soon. Directories are also represented as files and have anassociated inode. In addition to descriptions about the file, the

    inode contains pointers []

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-are-links-and-symbolic-links-in-unix-file-system/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-are-the-unix-system-calls-for-io/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/brief-about-the-directory-representation-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/5/http://kyapoocha.com/unix-interview-questions/what-is-inode/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/what-are-links-and-symbolic-links-in-unix-file-system/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/what-are-the-unix-system-calls-for-io/http://kyapoocha.com/category/unix-interview-questions/page/4/http://kyapoocha.com/unix-interview-questions/brief-about-the-directory-representation-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/5/http://kyapoocha.com/unix-interview-questions/what-is-inode/
  • 8/2/2019 Unix Viva Questions

    15/20

    w.jntuworld.com

    50

    How are devices represented in UNIX?

    All devices are represented by files called special files that arelocated in/dev directory. Thus, device files and other files are

    named and accessed in the same way. A regular file is just anordinary data file in the disk. A block special file represents adevice with characteristics similar to a disk (data transfer []

    Brief about the directory representation in UNIX

    A Unix directory is a file containing a correspondence betweenfilenames and inodes. A directory is a special file that the kernelmaintains. Only kernel modifies directories, but processes canread directories. The contents of a directory are a list offilename and inode number pairs. When new directories are

    created, kernel makes two entries []

    What is inode?

    All UNIX files have its description stored in a structure calledinode. The inode contains info about the file-size, its location,time of last access, time of last modification, permission and soon. Directories are also represented as files and have anassociated inode. In addition to descriptions about the file, theinode contains pointers []

    How are devices represented in UNIX?

    All devices are represented by files called special files that arelocated in/dev directory. Thus, device files and other files arenamed and accessed in the same way. A regular file is just anordinary data file in the disk. A block special file represents adevice with characteristics similar to a disk (data transfer []

    How is the command$cat file2 differentfrom $cat >file2

    Answer The Commond $cat file in unixis used to display the contentof the file and where as commond $cat >> file is to appendthe text to the end of the file without overwritting theinformation of the file. Incase if the file does not exist in thedirectory the commond will create a newfile in file system.

    www.jntuworld.com

    http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-are-devices-represented-in-unix-2/http://kyapoocha.com/unix-interview-questions/brief-about-the-directory-representation-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/5/http://kyapoocha.com/unix-interview-questions/what-is-inode/http://kyapoocha.com/unix-interview-questions/how-are-devices-represented-in-unix-2/http://newinterviewquestions.com/interview/7476/http://newinterviewquestions.com/interview/7476/http://newinterviewquestions.com/interview/7476/http://www.jntuworld.com/http://kyapoocha.com/unix-interview-questions/how-are-devices-represented-in-unix-2/http://kyapoocha.com/unix-interview-questions/brief-about-the-directory-representation-in-unix/http://kyapoocha.com/category/unix-interview-questions/page/5/http://kyapoocha.com/unix-interview-questions/what-is-inode/http://kyapoocha.com/unix-interview-questions/how-are-devices-represented-in-unix-2/http://newinterviewquestions.com/interview/7476/http://newinterviewquestions.com/interview/7476/
  • 8/2/2019 Unix Viva Questions

    16/20

    w.jntuworld.com

    51

    $cat >file means to create a new file $cat file means to openan 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 thata shell follows whileprocessing a command.

    Answer

    When processing a command the searchs for the utility forthe command in the directories specified in the PATH varibleand it in invokes that utility. That utility will execute thecommand with help of kernel and the output is given to shell.And then the displays out put to the user.

    Explain the steps thata shell follows whileprocessing a command.

    Answer

    When processing a command the searchs for the utility forthe command in the directories specified in the PATH varibleand it in invokes that utility. That utility will execute thecommand with help of kernel and the output is given to shell.And then the displays out put to the user.

    Which command isused to delete all filesin the current directoryand all its sub-directories?

    Answer

    #rm -fr

    # rm -rf *

    Answered By: Amit Shiknis Date: 12/25/2007

    rm -r *

    www.jntuworld.com

    http://www.jntuworld.com/http://newinterviewquestions.com/interview/7476/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7474/http://www.jntuworld.com/http://newinterviewquestions.com/interview/7476/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7475/http://newinterviewquestions.com/interview/7474/
  • 8/2/2019 Unix Viva Questions

    17/20

    w.jntuworld.com

    52

    What is the use of thecommand "ls -x

    chapter[1-5]"

    Answer

    Yes you are correct. It stands for listing the files Chapter withsuffix 1 to 5 but it will display the files in columns as with-xoption.

    How does the kerneldifferentiate devicefiles and ordinaryfiles?

    Answer

    Device filles are of 2 types --- charcater device file and blockdevice file

    type field in the file's inode structure

    b--- block device file

    c--- character device file

    How to switch to asuper user status to

    gain privileges?

    Answer

    Use su command. The system asks for password and whenvalid entry is made the user gains super user (admin)privileges.

    What are shellvariables?

    Answer Shell variables are system environment variables.Theyinclude

    TERM,SHELL, MAIL

    the output of the shell variable we can see by typing thecommand

    www.jntuworld.com

    http://www.jntuworld.com/http://newinterviewquestions.com/interview/7470/http://newinterviewquestions.com/interview/7469/http://newinterviewquestions.com/interview/7469/http://www.jntuworld.com/http://newinterviewquestions.com/interview/7470/http://newinterviewquestions.com/interview/7469/http://newinterviewquestions.com/interview/7469/
  • 8/2/2019 Unix Viva Questions

    18/20

    w.jntuworld.com

    53

    $>echo $TERM

    ansi

    at the prompt.

    What is redirection?

    Answer

    Redirection is a feature in Unix where the data from thestandard out put or a file,so on.can be redirected i.e divert toa file or a program and vice versa.

    > -- out put redirection

    >> -- out put redirectin(appending at the last)

    < -- input redirection

    How to terminate aprocess which isrunning and thespecialty on commandkill 0?

    Answer

    With the help of kill command we can terminate the process.

    Syntax: kill pidKill 0 - kills all processes in your system except the loginshell.

    How to terminate aprocess which isrunning and thespecialty on commandkill 0?

    Answer

    With the help of kill command we can terminate the process.Syntax: kill pidKill 0 - kills all processes in your system except the loginshell.

    How to sfind freespace in unix/linux

    www.jntuworld.com

    http://www.jntuworld.com/http://newinterviewquestions.com/interview/7468/http://newinterviewquestions.com/interview/7464/http://www.jntuworld.com/http://newinterviewquestions.com/interview/7468/http://newinterviewquestions.com/interview/7464/
  • 8/2/2019 Unix Viva Questions

    19/20

    w.jntuworld.com

    54

    Answer

    Df and du commands are used for checkingfree space ondisk .df -h or df -Humanreadable gives human readable format offree space.

    What is the differencebetween soft link andhard link in unixoperating system ?

    Answer

    Hard Links :

    1. All Links have same inode number.

    2.ls -l command shows all the links with the linkcolumn(Second) shows No. of links.

    3. Links have actual file contents

    4.Removing any link ,just reduces the link count , but doesn'taffect other links.

    Soft Links(Symbolic Links) :

    1.Links have different inode numbers.

    2. ls -l command shows all links with second column value 1and 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 removingoriginal file ,the link becomes "dangling" link which points tononexistant file.

    to concatenate(attach) two strings?

    Answer

    For concatenating two string we use cat command.

    Ex:- cat str1 str2

    Explain theUNIXKernel.

    www.jntuworld.com

    http://www.jntuworld.com/http://newinterviewquestions.com/interview/7464/http://newinterviewquestions.com/interview/7464/http://newinterviewquestions.com/interview/7464/http://newinterviewquestions.com/interview/7462/http://www.newinterviewquestions.com/interview/7457/http://www.newinterviewquestions.com/interview/7455/http://www.newinterviewquestions.com/interview/7455/http://www.jntuworld.com/http://newinterviewquestions.com/interview/7464/http://newinterviewquestions.com/interview/7464/http://newinterviewquestions.com/interview/7462/http://www.newinterviewquestions.com/interview/7457/http://www.newinterviewquestions.com/interview/7455/
  • 8/2/2019 Unix Viva Questions

    20/20

    w.jntuworld.com

    55

    Answer

    UNIX Kernel is heart of theoperating system. UNIX kernal isloaded first when UNIX system is booted. It handles allocationof devices, cpu, memory from that ponint on.

    How many prompts areavailable in a UNIXsystem?

    Answer

    Unix/ Linux Supports four Prompts PS1, PS2,PS3, PS4

    #,@,$,% 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.

    http://www.jntuworld.com/http://www.newinterviewquestions.com/interview/7455/http://www.newinterviewquestions.com/interview/7455/http://www.newinterviewquestions.com/interview/7455/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://www.jntuworld.com/http://www.newinterviewquestions.com/interview/7455/http://www.newinterviewquestions.com/interview/7455/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/http://newinterviewquestions.com/interview/7472/