Unix/Linux Interview Questions


1.
What is a shell?

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 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 mean by signal?

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?

UNIX is the most popular operating system on multi-user systems. This operating system originated as a single-user system. 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.

5.
Define message queue?

message queue 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 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 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?

  • Regular file
  • Directory file
  • Character special file
  • Block special file
  • FIFO
  • Symbolic link
  • Socket

9.
What are the options available to determine the group ID of the new file?

  • The group ID of the new file can be the effective group ID of the process
  • 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?

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?

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 mean by u-area (user area)?

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?

  • Fuly buffered
  • Line buffered
  • Un buffered

14.
What is the purpose of exec functions?

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 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 difference between cmp and diff commands?

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?

Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).

18.
What are shell variables?

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

19.
What is Block Started by Symbol?

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?

date
21.
what are the different commands used to create files?

  • touch - to create empty files.(e.g) - touch ‹filename›
  • vi ‹filename›
  • cat>filename
.

22.
What is chmod, chown and chgrp?

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 PIDs?

They are process IDs given to processes. A PID can vary from 0 to 65535.

24.
What does the top command display?

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 to send message to all users who are logged in?

Wall
26.
What is Kernel?

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?

  • Password protection
  • File permissions
  • Encryption.

28.
What does the swapping system do if it identifies the illegal page for swapping?

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’re in?

pwd
30.
What is a pipe?

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?

exit

32.
What is the use of grep command?

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 the file?

file “grep” means Globally search a regular expression and print it.
34.
What are the features and benefits of unix?

  • 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?

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 users system?

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.