UNIX Interview Questions

1.What is UNIX?

It is a portable operating system that is designed for both efficient multi-tasking and mult-user functions. Its portability allows it to run on different hardware platforms. It was written is C and lets user do processing and control under a shell.

2.What is the description for Kernel?

Kernel is the master program with UNIX operating system that controls the resources of the computer. The resources allocation to different users and tasks handle by this section. Kernel do not have direct communication with the user and it starts separate interactive program call shell to each user when login to the system.

3.What to do with the file if it consists of a '/' in filename?

The file which consists of a ‘/’ in filename is treated as special case and can be created by faulty kernel code. In most of the cases ‘/’ and ‘\0’ are the only two characters that cannot appear in a filename. The special symbol ‘/’ is used to separate directories and files. The commands ‘find’ or ‘rm’ will find and delete this file as they treat the symbol in normal way.

4.What are filters?

The term Filter is often used to refer to any program that can take input from standard input, perform some operation on that input, and write the results to standard output. A Filter is also any program that can be used between two other programs in a pipeline.

5.What is a single user system?

A personal computer with an operating system which was designed to operate by a single user at a given time. Single user system becomes more popular since low-cost hardware and availability of wide range of software to perform difference tasks.

6.What are pttys?

Pttys are also called as Pseudo-teletypes, these are pseudo-devices that consist of two parts, which are as follows: 1st is the master side, which can be considered as “user” and 2nd is the slave side, which acts like standard tty device. They allow means to emulate the behavior of serial terminal using the control of the program. Example of this is as follows: telnet uses pseudo terminal on remote system.

7.What are the main features of UNIX?

  • Machine independent
  • Portability
  • Multi-user operations
  • Unix Shells
  • Hierarchical file system
  • Pipes and filters
  • Background processors
  • Utilities
  • Development tools.

8.What is a typical syntax being followed when issuing commands in shell?

Typical command syntax under the UNIX shell follows the format:
Command [-argument] [-argument] [–argument] [file]

9.How can multiple processes write to the pipe simultaneously?

Multiple processes can be written to pipe simultaneously by the use of PIPE_BUF. The conditions which have to be noted down is that, if the data to be written to the pipe is less than PIPE_BUF then, the data won’t be interleaved. The read call at the same time will return all the data present, even from the multiple writes. PIPE_BUF size is at least 512KB. It is defined in “<limits.h>.

10.How to manage multiple connections?

You can use select() or poll() functions to manage your multiple connections. These functions somewhat has the same functionality but they are quite different in their approach. These processes examine a set of file descriptor to see specific event, if they are pending then they wait for a specific time for that event to get completed. These are useful when used for sockets, pipes,ptys,ttys and other character devices.

11.What is called Shell?

The interface between user and system called a shell. Shell accepts commands and set them to execute for user operations.

12.Is there a way to erase all files in the current directory, including all its sub-directories, using only one command?

Yes, that is possible. Use “rm –r *” for this purpose. The rm command is for deleting files. The –r option will erase directories and subdirectories, including files within. The asterisk represents all entries.

13.What is the alias mechanism in UNIX?

The alias command allows the user to specify or assign another name to a command. It can be also used to club together a group of commands.

For ex.

  • alias dir ‘ls -sFC’

The above command on being executed would tell the shell that dir is another name for the command ls -sFC. In this way, the user can simply assign an alias name to a command that could be difficult to remember. Now the user simply needs to use the specified alias name as given by him in place of the command for the same effect as the code.The user can check the number of aliases active by typing in the command from the shell:

  • uhunix% alias pwdls ‘pwd; ls -sFC’

14.What are the responsibilities of a shell?

  • Program Execution
  • Input/output redirection
  • Filename and variable substitution
  • Pipeline hookup
  • Environment control
  • Integrated programming language

15.What is the chief difference between the –v and –x option s to set?

The –v option echoes each command before arguments and variables have been substituted for; the –x option echoes the commands after substitution has taken place.

16.What is the general format of UNIX command syntax?

In general consideration, UNIX shell commands follows the following pattern

Command (-argument) (-argument) (-argument) (file name)

17.What are the key features of the Korn Shell?

– history mechanism with built-in editor that simulates emacs or vi
– built-in integer arithmetic
– string manipulation capabilities
– command aliasing
– arrays
– job control

18.Describe the usage and functionality of the command “rm –r *” in UNIX?

The command “rm –r *” is a single line command to erase all files in a directory with its subdirectories.

  • “rm” – Is for deleting files.
  • “-r”   – Is to delete directories and subdirectories with files within.
  • “*”     – Is indicate all entries.

19.What are some common shells and what are their indicators?

sh – Bourne shell
csh – C SHell
bash – Bourne Again Shell
tcsh – enhanced C Shell
zsh – Z SHell
ksh – Korn SHell

20.Describe the term directory in UNIX?

A specialized form of a file that maintains a list of all the files which include in it is called a directory. Each file assigns to a directory.

21.Differentiate multiuser from multitask.

Multiuser means that more than one person can use the computer at the same time. Multitask means that even a single user can have the computer work on more than one task or program at the same time.

22.Specify the difference between absolute path and related path?

Absolute path refers to the exact path as defined from the root directory. Related path refers to the path related to the current locations.

23.What is command substitution?

Command substitution is one of the steps being performed every time commands are processed by the shell. Commands that are enclosed in backquotes are executed by the shell. This will then replace the standard output of the command and displayed on the command line.

24.What is the UNIX command to list files/folders in alphabetical order?

The ‘ls –l’ command is used to list down files and folders in alphabetical order. When you use ‘ls –lt’ is list down files /folders sorted with modified time.

25.What is a directory?

Every file is assigned to a directory. A directory is a specialized form of file that maintains a list of all files in it.