Common Unix Interview Questions
Send your Question/Answer
• What is the output of the following program:
• main()
• {
• printf("Hello");
• fork();
• }
"HelloHello". The buffer is flushed when the process is finished, because there is no '\n' in the output string. When the process is fork()'ed, the child process "inherits" the buffer of the parent process. When the child process is finished it flushes the buffer. Finally, parent process is finished and flushes its buffer.
• For the following struct:
• struct str
• {
• int a;
• char b;
• short c;
• }
Create the macro OFFSET that returns an offset of each structure's member.
• Write a shell script that will "simultaneously" (i.e. not one by one) copy all the files from one directory to another.
• What happens when the function definition has less/more parameters than the actual call?
• a. Definition: f(a,b)
• Call: f(a,b,c)
•
• b. Definition: f(a,b,c)
• Call: f(a,b)
• How would you set permissions on a symbolic link?
It is a tricky question if you never worked with symbolic links. There is no meaning in setting the permissions on a symbolic link!
• How well do you know vi ?
The answer depends on how deep the interviewer knows vi himself and what is the meaning "well". I guess the absolute minimum is the switch from input to command mode, reqular expressions, reading/writing to file. You may also delicately hint that normal people would use Emacs rather than vi most of the time.
• Are you familiar with different shells? Name them, explain the difference.
There are too many of them to know all, but you may mention sh, csh, tcsh, ksh, bsh etc. I guess nobody knows all details of differences between them :)
• What are the following files: hosts, services, inetd.conf... (any Unix file might be named here :-) )
• How would you automatically start a daemon on Sys 5 R4?