sivasoft interview questions

sivasoft interview questions

UNIX Interview Questions

1. What is shell ?
A. A Unix shell is the program which reads user input from the command line and executes actions based upon that input.

2. Define session?
A. A session is a collection of one or more process groups. A process establishes a new session by calling setsid function. This function returns process group id if OK.

3. What do you meant by signal ?
A. Signals are software interrupts. Signals provide a way of handling asynchronous events: a user at a terminal typing the interrupt key to stop a program or the next program in the pipeline terminating prematurely.

4. What is Unix ?
A. Unix is the most popular operating system on multi-user systems. This operating system originated as a single-user system.It started of 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.

5. Define message queue ?
A. Message queue is a linked list of messages. It is used to make a communication between the related or unrelated processes.

6. Define directory and filename ?
A. A directory is a file that contains directory entries. The directory entry containing a file name along with structure of information describing the attributes of the file. The names in a directory are called filename. The only two characters that cannot appear in a file name are / and null character.

7. Define program and process ?
A. A program is a executable file residing in a disk file. An executing instance of a program is called a process. Every UNIX process have a unique numeric identifier called the process ID. The process ID is always a non negative integer.

8. List down the different file types ?
A. 1.Regular file
    2.Directory file
    3.Character special file
    4.Block special file
    5.FIFO
    6.Symbolic link
    7.Socket

9. What are the options available to determine the group ID of the new file ?
A. 1.The group ID of the new file can be the effective group ID of the process
     2.The group ID of the new file can be the group ID of the directory in which the file is being created.

10. Define sticky bit ?
A. The bit S_ISVTX is known as sticky bit. If this bit is set for an executable program file, then the first time the program was executed a copy of the programmer’s text was saved in the swap area when the process terminated. The advantage of using this is the program is loaded into memory faster the next time.

11. What is called a page fault ?
A. Page fault is referred to the situation when the process addresses a page in the working set of the process but the process fails to locate the page in the working set. And on a page fault the kernel updates the working set by reading the page from the secondary device.

12. What do you meant by user area ?
A. This contains the private data that is manipulated only by the Kernel. This is local to the Process, i.e. each process is allocated a u-area.

13. What are the different types of buffering is supported by UNIX ?
A. 1.Fuly buffered
    2.Line buffered
    3.Un buffered

14. What is the purpose of exec functions ?
A. When a process calls one of the exec functions that process is completely replaced by the new program. The new program stats execution from main function. The processed does not change across an exec because a new process is not created.But this function replaces the current process with new program from disk.

15. Define process group ?

A. 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.

16. What is the difference between cmp and diff commands ?
A. cmp - Compares two files byte by byte and displays the first mismatch.
    diff - tells the changes to be made to make the files identical.

17. How many prompts are available in a UNIX system ?
A. Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).

18. What a shell variables ?
A. Shell variables are special variables, a name-value pair created and maintained by the shell.

19. What is Block Started by symbol ?
A. A data representation at the machine level, that has initial values when a program starts and tells about how much space the kernel allocates for the un-initialized data. Kernel initializes it to zero at run-time.

20. What is the command to find out today's date ?
A. date.

21. What are the different commands used to create files ?
A. 1.touch - to create empty files.(e.g) - touch ‹filename›
    2.vi ‹filename›
    3.cat>filename

22. What is chmod, chown and chgrp ?
A. Chmod : It is used for to change permissions on files.
    Chown : It is used for to change ownership of a file.
    Chgrp : It is used for to change group of the file.

23. What are PID's ?
A. They are process IDs given to processes. A PID can vary from 0 to 65535.

24. What does the top command display ?
A. Top command displays the current ammount of memory occupied by the currently executing processes and the details. In addition to memory usage top command displays cpu usage and process details.

25. What is the command tosend message to all users who are logged is ?
A. Wall.

26. What is kernel ?
A. Kernel is core part of unix o/s. It is a group of hundreds of system calls.

27. What are the different security features in UNIX ?
A. Password protection
    File permissions
    Encryption.

28. What does the swapping system do if it identifies the illegal page for swapping ?
A. If the disk block descriptor does not contain any record of the faulted page, then this causes the attempted memory reference is invalid and the kernel sends a “Segmentation violation” signal to the offending process. This happens when the swapping system identifies any invalid memory reference.

29. How do you find out the current directory you are in ?
A. Pwd.

30. What is a pipe ?
A. A pipe is two or more commands separated by pipe char ‘|’. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command.

31. How to close the current user account ?
A. exit.

32. What is the use of grep command ?
A. grep is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file(s).

33. Which command is used to identify the type of file ?
A. file “grep” means Globally search a regular expression and print it.

34. What are the features and benifits of UNIX ?
A. Portability
    Machine Independent
    Multi-user operations
    Hierarchical file system
    Unix shell
    Pipes and filters
    Utilities
    Background Processing
    Software Development Tools
    Maturity 

35. What is the use of break and continue statements ?
A. The continue statement suspends execution of all statements following it, and switches control to the top of the loop for the next iteration. The break statement, on the other hand, causes control to break out of the loop.

36. What is single user's system ?
A. The personal computer (PC) is a small, general-purpose system that can execute programs to perform a wide variety of tasks. The PC, however, was designed for use by one person at a time; that is, it is Single-User oriented with MS-DOS as the de facto standard operating system for this range of machines. Single user systems became very popular due to the low cost hardware and wide range of software available for these machines.

37. Write command to list all the links from a directory?
A. Basic use of "ls" "grep" and regular expression etc you can write command like: ls -lrt | grep "^l" .

38. How will you find which operating system your system is running on in UNIX?
A. By using command "uname -a" in UNIX.

39. How will you run a process in background? How will you bring that into foreground and how will you kill that process?
A. For running a process in background use "&" in command line. For bringing it back in foreground use command "fg jobid" and for getting job id you use command "jobs", for killing that process find PID and use kill -9 PID command. 

40. How do you know if a remote host is alive or not?
A. You can check these by using either ping or telnet command in UNIX.

41. How do you see command line history in UNIX?
A. Very useful indeed, use history command along with grep command in unix to find any relevant command you have already executed. 

42. How do you copy file from one host to other?
A. Many options but you can say by using "scp" command. You can also use rsync command.

43. In a file word UNIX is appearing many times? How will you count number?
A. grep -c "Unix" filename .

44. How do you find whether your system is 32 bit or 64 bit ?
A. Either by using "uname -a" command or by using "arch" command.

45. How do you check if a particular process is listening on a particular port on remote host?
A. By using telnet command for example “telnet hostname port”, if it able to successfully connect then some process is listening on that port.

46. How do you set environment variable which will be accessible form sub shell?
A. By using export   for example export count=1 will be available on all sub shell.

47. You have an IP address in your network how will you find hostname and vice versa?
A. By using nslookup command in UNIX, you can read more about Convert IP Address to hostname in Unix here.

48. How do you find for how many days your Server is up?
A. By using uptime command in UNIX.

49. Your application home directory is full? How will you find which directory is taking how much space?
A. By using disk usage (DU) command in Unix for example du –sh . | grep G  will list down all the directory which has GIGS in Size.

50. You have a tab separated file which contains Name, Address and Phone Number, list down all Phone Number without there name and Addresses?
A. cut -f3 filename.