Tutorial corner

Informatica,ETL,oracle,sql/plsql

Top unix interview question with answer : Part -1

Spread the love

Collection of Top unix interview question with answer  . Unix/Linux most commonly used operating system in IT world. Whenever you are going to give any interview related to any programming language  (java or C or C++) , you are always going to be asked some unix interview question. In below article we are going to go through some of the commonly asked Unix interview question with answer . We are going to divide below article in theory related question and command related questions. As list of unix interview questions is going to be  too large , so we will be dividing  it into multiple post. Here we are going to start with Part -1 of “Top unix interview question with answer” series.

Unix interview question with answer (Theory)

What is UNIX ?

Ans : UNIX is a free source multi-user multitasking-optimized operating system. It is the most generic OS now a days which can run on various hardware platforms.It started off on a cast-off DEC PDP-7 at Bell laboratories in 1969. Ken Thompson, with ideas and help from Dennis Ritchie, and others, wrote a small, general-purpose operating system.

Ques:  What is a kernel in unix?

Ans : The kernel is the program that acts as a middle layer between software and hardware. When a program requires access to certain resources or processing power, the kernel is responsible for sending the correct signals to the CPU and managing all other running programs and services so that the resources are correctly allocated and no conflicts occur..

Ques:  What is a shell in unix?

Ans: The UNIX shell is a program that serves as the interface between the user and the UNIX operating system. It is not part of the kernel, but communicates directly with the kernel. The shell translates the commands you type in to a format which the computer can understand. It is essentially a command line interpreter.

Top unix interview question with answer

unix operating system

Ques: Give some example of shell ?

Ans : Below are some of the available shell in unix , every shell has its own flavour.

  • Bourne Shell (sh)
  • C Shell (csh or tsch)
  • Bourne Again Shell (bash)
  • Korn Shell (ksh)

Ques: How are devices represented in UNIX?

Ans : All devices are represented by files called special files that are located in/dev directory. Thus, device files and other files are named and accessed in the same way.

  • A ‘regular file‘ is just an ordinary data file in the disk.
  • A ‘block special file‘ represents a device with characteristics similar to a disk (data transfer in terms of blocks).
  • A ‘character special file‘ represents a device with characteristics similar to a keyboard (data transfer is by stream of bits in sequential order).

Ques: What is difference between Swapping and Paging ?

Ans:

Swapping:

Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.

Paging

Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.

Ques: What is process group??

Ans: A process group is a collection of one or more processes. Each process group has a unique process ID. A function getpgrp returns the process group id of the calling process.

Unix interview question with answer (commands)

Ques: what is the command to list down all running process on unix?

Ans : ps -ef

Ques: How to check if the last command was successful in Unix ?

Ans : By checking the value of $? immediately after running command. For example after running cat  file.txt  , check value of $? by running “echo $? “.If value return by $? is 0 (Zero) then previous command was successful else it failed.

Ques: How to check if the last command was successful in Unix ?

Ans : By checking the value of $? immediately after running command. For example after running cat  file.txt  , check value of $? by running “echo $? “.If value return by $? is 0 (Zero) then previous command was successful else it failed.

Ques: How to display first 5 line of file.txt in Unix ?

Ans : run ” head -5 file.txt” command .

head -5 file.txt

Ques: How to display last 5 line of file.txt in Unix ?

Ans : run ” tail -5 file.txt” command .

Ques: How to display 2nd last line of file.txt in Unix ?

Ans : run ” tail -2 file.txt |head -1″ command .

Ques: How to remove 5 the line of file.txt in Unix ?

Ans : sed -i ‘5 d’ file.txt.

Ques: What is  the command to count “export” word in a file?

Ans :  grep -c “export” filename

Ques: What is chmod command?

Ans :  chmod command is to change the permission of files .For example if you want to add executable permission to file for user , you can use below command .

$ chmod u+x filename
(Only owner of file can run filename script)

Also check below

Top unix interview question with answer :Part -2
Top unix interview question with answer :Part -3

So in above article ,we have gone through some of the commonly asked unix interview question with answer.

The Author

Alisha Lamba

Hello Friends , I am Alisha Lamba .I love to write article on latest technologies like Informatica , ETL , data warehouse , SQL-PL SQL
Copyright 2015 - Tutorial Corner Frontier Theme