UNIX Technical Interview Questions

What is UNIX?

In short, UNIX is a type of operating system. It actually predates most modern operating systems such as Windows, Android, Linux, etc. In fact, operating systems such as BSD, Linuz, and Apple OS have developed from UNIX, or at least have been heavily influenced by it.  UNIX was developed in the 1970s at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and others.

UNIX is primarily known for its multitasking and multiuser compatibility. UNIX was designed to be portable, multi-tasking and multi-user in a time-sharing configuration. It is also characterized by some concepts such as the use of plain text for storing data, as well as a hierarchical file system and the use of a large number of software tools. It is also known for the way it treats devices and certain types of inter-process communication (IPC) as files. In UNIX, small programs can be strung together through a command-line interpreter using pipes, as opposed to using a single monolithic program. These concepts together are collectively known as the "Unix philosophy".

What are filters?

A filter is a specific type of UNIX command. It is primarily used to do some manipulation in the text of the file. It changes plain text into something that can be used together with the other filters and pipes. All of which together form a series of operations that can be utilized to produce highly specific results.

The filter gets most of its data from its standard input, which is main input stream. It then writes its main results to its standard output, i.e. the main output stream. The two most popular UNIX filters are the sed and awk commands. Both are extremely powerful and yet are somewhat complex to use.

What is Kernel?

A kernel is the central module of an operating system (OS). Each and every OS has a kernel. Basically, UNIX is a type of kernel, around which the operating system has been created. It is the kernel that loads first and simultaneously remains in main memory. It is also responsible for providing all the essential services that are required by other parts of the operating system and applications.

The kernel is typically stored in protected memory to avoid it accidently being overwritten. The kernel is responsible for memory management, process and task management, and disk management. It also connects the system hardware to the application software.

What is Shell?

In the simplest terms, a shell is a program. It is responsible for taking commands and setting them up for execution. Basically, it acts as an interface between the user and the system hence allowing the user to input the commands, and for the system to execute them. Once the command is inputted, it is the shell’s job to validate the command and accept it or reject it accordingly. Once it accepts it, it will then send the command to another part of the command processor to be executed.  

The shell is also known as the command interpreter. The shell is the outermost layer of the operating system, whereas the kernel is the innermost. UNIX has various shells, the most popular of them being the Cshell, the Bourne shell, and the Korn shell.

There are multiple shell types of Unix. What are the features of the Bourne and Korn shell?

A shell is a type of user interface that allows the user to input a command. The shell will then set up that command to be executed. UNIX has various shells, the most popular of them being the Cshell, the Bourne shell, and the Korn shell.

The Bourne shell is the standard shell of Unix. Features of the Bourne shell include:

  • Gives the ability of input/output redirection
  • Provides a built in command set for the creation of shell programs
  • Allows the user to control a job
  • Allows the usage of metacharacters for file name abbreviations
  • The environment can be customized using the shell variables

The Korn shell is an extension of the Bourne shell which is backward compatible. Features of the Korn shell include:

  • A history mechanism with built-in editor that simulates emacs or vi
  • A built-in integer arithmetic
  • Provides string manipulation capabilities
  • Has command aliasing
  • Has arrays
  • Allows the user to control a job
What is a typical syntax being followed when issuing commands in shell?

The typical command syntax when issuing commands under the UNIX shell follows the following format:

Command [-argument] [-argument] [–argument] [file]

What do you understand by File modes in Unix?

File modes are basically permissions or access rights. The permissions that are given to the "user", "group" and "others" classes. It indicates to the system the types of files that each person can access, as well as the amount of access each one is allowed.

There are four main classes; each one with its own reference and set of permissions.

Reference

Class

Description

u

user

the owner of the file

g

group

users who are members of the file's group

o

others

users who are not the owner of the file or members of the group

a

all

all three of the above, is the same as ugo

Once assigned, the modes are not permanent. They can be changed. In traditional Unix permissions, modes can be changed with chmod. In Access Control Lists, modes can be changed with setfacl (for).

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

Yes. In order to erase all files, the command rn is frequently used. In order to erase all files in the current directory, including all its sub-directories, the command “rm –r *” is used. The * indicates to the system that all entries must be deleted.

For example:

In order to delete all files in the directory donotdelete, one would use

rm -r donotdelete /*

However, this will not delete any hidden file if they exist.

What is the alias mechanism in UNIX?

The alias mechanism allows one to specify or assign another name to a command. Basically, it assigns an alias to the command. This comes in useful as one can assign an alias to a command that would otherwise be difficult to remember.

For example:

alias dir ‘ls -sFC’

This indicated to the system that the command “dir” can now be used instead of ‘ls -sFC’. Using “dir” will have the same effect as using ‘ls -sFC’

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.