Wednesday 3 August 2011

Unix Interview Questions

1) What exactly is UNIX?
UNIX is written in C and it is portable. It runs on a range of computers from microprocessors to the largest mainframes. The source code is available and written in high level language which makes it easy to adapt for a particular requirement.
 
2) Explain about the return key?
Return Key signifies the end of a line of input; it must be presses before the system will interpret the characters you have types. It serves as an example of control character return key can be typed by holding the control key and typing M.
 
3) Explain about DELETE and BREAK?
These keys have significant meaning sometimes DELETE is called as RUBOUT key. Break is sometimes called INTERRUPT. In most SYSTEMS the delete key stops a program immediately, without waiting for it to finish on some systems, Ctrl-C provides this service. Break is a synonym for DELETE or CTRL-C.

4) Explain about TYPE-ahead?
The kernel reads what you type as you type it, even if it’s busy with something else, so you can type as fast as you want, whenever you want, even when some command is printing at you. Your I/P characters will appear intermixed with the O/P characters but they will be stored away and interpreted in the correct order.

5) How to get a computer aided instruction?
Your system may have a command called learn which provides computer aided instruction on the file system and basic commands, the editor, document preparation and even “C” programming. IF $learn exists on your system, it will teach you what to do from there.

6) Explain about cat?
Cat is the simplest of all the printing commands. Cat prints the contents of all the files named by its arguments. The named file or files are catenated the terminal one after another with nothing between. You have to be quick with CTRL-S to stop O/P from cat before it flows off your screen.

7) How to search files for lines that match a pattern?
Grep command searches for files for lines which match a pattern.
E.g. g/regular expression/p.grep will also look for lines that don’t match the pattern, when the option-V is sued. grep can be used to search several files in that case it will prefix the filename.

8) Describe about the root file system?
The root file system has to be present for the system to execute /bin, /dev, and /etc are always kept on the root system because when the system starts only files in the root system are accessible and some files such as /bin/sh are needed to run at all. During the boot strap operation, all the file systems are checked for self consistency and attached to the root systems.

9) Explain about ZAP?
ZAP, which selectively kills processes, is another program. The main problem with that version is speed; it creates so many processes that it runs slowly, which is especially undesirable for a program that kills errant processes rewriting ZAP in C will make it faster.

10) Suppose that you are using a terminal in which the screen size is bigger than the normal 24 lines. If you want to use p and take full advantage of your terminal capabilities what choices are open to you?
You have to specify the screen size each time you use P. $P-36.
Also you could put a shell file in your bin.
$cat/usr/you/bin/p
Exec/usr/bin/p-36$*
$
Another solution is to modify p to use an environment variable that defines the properties of your terminal.

11) Explain abut low-level I/O?
The lowest of I/O is a direct entry into the O.S. your program reads or writes files in chunks of any convenient size. The kernel buffers your data into chunks that match the peripheral devices and schedule operations on the devices to optimize their performance over all users.

12) What are the special arrangements to make a terminal i/p and o/p?
When it is started by the shell, a program inherits three open files, with file descriptor 0, 1 and 2 called the standard i/p, the standard o/p, and the standard error. If the program reads “0” and writes descriptors 1 and 2, it can do I/O without opening files.

13) Explain about read slow?
One can call to read return 0 which signals the end of file life, if data is written on that file then a subsequent read will be able to find more bytes available. This observation is the basis of a program called readslow which continues to read its input, regardless of whether it got an end of file or not. Readslow is handy for watching the progress of the file.

14) What function does “errno” do?
Sometimes it is nice to know what specific error occurred; for this purpose all system calls, when appropriate, leave an error number in an external integer called calls, when appropriate, leave an error number in an external integer called errno. By using errno, your program can, for example, determine whether an attempt to open a file failed because it did not exist or because you lacked permission to read it.

15) Describe the process of “spname”?
The operation of spname is straightforward enough, although there are a lot of boundary conditions to get right. Suppose the file name is /d1/d2/f. The basic ideas is to peel off the first component (/), then search that directory for a name close to the nest component (dl), then search that directory for something near d2, and so on, until a match has been found for each component. If at any stage there isn’t a plausible candidate in the directory, the search is abandoned.

16) Explain about fork?
Splitting is done by a system call named fork. Proc_id = fork (); splits the program into two copies, both of which continue to run. The only difference between the two is the value returned by fork, the process-id. Two copies of the program are made by the fork. In the child, the value returned by fork is zero, so it calls execlp, which does the command line and then dies. In the parent, fork returns non-zero so it skips the execlp.

17) What is the easiest way to store variables and explain?
The easiest way to store the values of the variables is in a 26-element array; the single-letter variable name can be used to index the array. But if the grammar is to process both variable names and values in the same stack, yacc has to be told that its stack contains a union of a double and an int, not just a double.

1 comments:

Unknown said...

KiaOra,



In total awe…. So much respect and gratitude to you folks for pulling off such amazing blogs without missing any points on the Unix Interview Questions. Kudos!




Though the basic
unit of a Unix and Unix-like
systems include at least some BSD code, and some systems also include GNU utilities in their distributions. I've came across forums it says you can create your own mini OS using C/C++ compiler.
Is that entirely true? How much time it takes to replicate an OS like Chrome OS

It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!


Grazie,
Ajeeth

Post a Comment

Popular Posts

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls