Unix Interview Questions and Answers
Question - 101 : - Explain the kill() system call and its return values?
Answer - 101 : -
kill() system call sends signals to any process which further takes suitable action according to the signal. It takes two arguments, first is PID, to which you want to send a signal and the signal you want to send is second. This method returns the following return values:
- 0 - means that the process exists with the given PID and the system allows sending signals to it.
- -1 and errno==ESRCH - means that the process/process group with specified PID does not exist
- -1 and errno==EPERM - means that the sender has no permission to send a signal to the target process.
- EINVAL - means an invalid signal was specified.
Question - 102 : - Name the various commands that are used for the user information in UNIX.
Answer - 102 : -
The various commands that are used for displaying the user information in Unix are:
- id: This displays the active user id with login and group.
- last: This displays the last login of the user in the system.
- who: This determines who is logged onto the system.
- groupadd admin: This is used to add group ‘admin’.
- usermod –a: This is used to add an existing user to the group.
Question - 103 : - What is the difference between ps -ef and ps -auxwww?
Answer - 103 : -
ps -ef will not list the processes with a very long command line while ps -auxwww will list those processes as well. This sometimes helps in debugging as we do not always want to list all the processes but if we are not getting any idea we should switch to the ps -auxwww command.
Question - 104 : - What is the Zombie process in UNIX? How do you find the Zombie process?
Answer - 104 : -
Zombie processes are those child processes that get finished before the parent process. So after finishing up, the process structure and address space are removed and freed back to the system but the entry in the process table still exists. To be able to get the status of the child process the parent calls wait(). In the interval between the child terminating and the parent calling wait(), the child is said to be a 'zombie'.
Question - 105 : - You have an IP address in your network, how will you find the hostname and vice versa?
Answer - 105 : -
nslookup command is used to query internet domain name servers which can be used to find hostname from an IP address and for reverse lookup also, Similarly host command can also be used.
Question - 106 : - Explain system bootup in UNIX.
Answer - 106 : -
It is the first thing when the system starts. It has majorly 5 phases
- Hardware - BIOS fired up and checks for the hardware connection
- Operating System Loader - The OS loader is located in the initial 512-byte block of the boot device known as the MBR
- Kernel - It initializes various components of the computer, operating system and each portion of software responsible for task, usually consider a driver
- root user-space process (init and inittab) - This defines what should be run when the /sbin/init program is instructed to enter a particular run-level, giving the administrator an easy way to establish an environment for some usage
- Boot scripts - For each managed service (mail, nfs server, cron, etc.), there is a single startup script located in a specific directory.
Question - 107 : - What are different classes of jobs?
Answer - 107 : -
The UNIX operating system job scheduler provides three different types of job classes
- Time-share Job Class - This is the default job class and has priority 0 through 59, with 59 being the highest priority. In this job class, each process is assigned a time slice where the time slice specifies the number of CPU clock ticks that a particular task can occupy. Once the process finishes its time slice, the process is placed on the sleep queue, and the priority decreases.
- System Job Class - This class is reserved for system daemon processes. The priority range for the system job class is between 60 and 99. These are of higher priority than the time-share job class. This is to ensure that the system can provide services to the time-share job class processes when system services such as memory, and/or file I/O are requested.
- Real-Time Job Class - This is the highest priority job class and has no time slice. Real-time process priorities range between 100 and 159. This ensures that critical processes always acquire the CPU as soon as the process is scheduled to run. Because there is no time slice the number of context switches is reduced significantly.
Question - 108 : - What are the key features of the Korn Shell?
Answer - 108 : -
- history mechanism with a built-in editor that simulates emacs or vi
- built-in integer arithmetic
- string manipulation capabilities
- command aliasing
- arrays
- job control
Question - 109 : - What are some common shells and what are their indicators?
Answer - 109 : -
- sh – Bourne shell
- csh – C SHell
- bash – Bourne Again Shell
- tcsh – enhanced C Shell
- zsh – Z SHell
- ksh – Korn SHell
Question - 110 : - What is command substitution?
Answer - 110 : -
Command substitution is one of the steps being performed every time commands are processed by the shell. The shell executes only those commands that are enclosed in backquotes. This will then replace the standard output of the command and displayed on the command line.