Likes

Shell Scripting Interview Questions


A list of top frequently asked Shell Scripting interview questions and answers are given below.


1) What is shell script?

A shell script is a command containing text file that contains one or more commands.

2) Why is the use of shell script?

It is used by system administrators to issue numbers of commands to accomplish the task. All commands are added together in a text file (shell script) to complete daily routine tasks.

3) What are the advantages of shell scripting?

These are the two main advantages of shell scripting:
  • It facilitates you to develop your own operating system with relevant features best suited for you.
  • You can design software applications according to their platform.

4) What are the disadvantages of shell scripting?

Following are the main disadvantages of shell scripting:
  • A weak design can destroy the entire process and could prove a costly error.
  • If a typing error occurs during the creation then it can delete the entire data as well as partition data.
  • Its initial process is slow and improves gradually.
  • Portability between different operating system is difficult.

5) What are the different types of variables used in shell script?

There are two types of variables used in shell script:
  • System defined variables: These variables are defined or created by operating system itself.
  • User defined variables: These variables are defined by system users.

6) What is the syntax of "nested if statement" in shell scripting?

  1. if [ Condition ]  
  2. then  
  3. command1  
  4. command2  
  5. .....  
  6. else  
  7. if [ condition ]  
  8. then  
  9. command1  
  10. command2  
  11. .....  
  12. else  
  13. command1  
  14. command2  
  15. .....  

7) What is the use of "$?" sign in shell script?

While writing the shell script, the "$?" sign is used with "if statement" to check whether the previous command is executed successfully or not.

8) What is the use of break command?

The break command is used to escape from a loop in progress.

9) What is GUI scripting?

GUI stands for Graphical User Interface. It is used for controlling a computer and its applications. GUI scripting supports different applications. It mostly depends on the operating system.

10) What are the various stages of a Linux process it passes through?

A Linux process generally passes through four stages:
  1. Waiting: In this stage, the Linux process waits for resource.
  2. Running: In this stage, the Linux process is currently being executed.
  3. Stopped: In this stage, the Linux process is stopped after successful execution.
  4. Zombie: This stage is known as zombie because the process has stopped but still active in process table.

11) Is it possible to substitute "ls" command in the place of "echo" command?

Yes.

12) What is the syntax of while loop in shell scripting?

The while loop is used to repeat its block of commands a number of times. It is different from for loop, it iterates until the while condition is no longer true.
  1. while [ test_condition ]  
  2. do  
  3. commands...  
  4. done   

13) What is the difference between soft and hard links?

Inode: Each file contains an index number known as "inode" which is comprised of metadata about the associated file.
inode
Hard Link: is the mirror of original linked file. In such case, hard link and original file contains same inode. Hard link remains linked whether original file is removed.
inode 2
Soft Link: is like shortcut feature of Windows OS. In such case, hard link and original file contains different inode. Soft link will not work correctly if original file is removed.
inode 3

14) What is the use of "$#" in Shell Scripting?

The $# shows total number of arguments passed to the script.

15) What are the Zombie processes?

Zombie processes are the processes which are died but exit status is not picked by the parent process.

16) What are the 3 standard streams in Linux?

0 - Standard Input
1 - Standard Output
2 - Standard Error

Unix Interview Question


A list of top frequently asked Unix interview questions and answers are given below.

1) What is Unix?
UNIX is a portable operating system that is designed for efficient multi-tasking and multi-user functions. Since it is a portable operating system, it can run on different hardware platforms.
It is written in C language.

2) What is a UNIX shell?
The UNIX shell is a program which is used as an interface between the user and the UNIX operating system. It is not a part of the kernel but it can communicate directly with the server.

3) What is filter?
A filter is a program that takes input from standard inputs and performs some operation on that input to produce a result as standard output.

4) What are the devices represented in UNIX?
All devices in UNIX are represented by special files that are located in /dev directory.

5) Is there any method to erase all files in the current directory, along with its all sub-directories, by using only one command?
Yes, you should use "rm-r*" command for this purpose.
Here the "rm" command is used for deleting files, the ?r option will erase directories and sub directories with their internal files and * is used for selecting all entries.

6) What is necessary before you can run a shell script from the command line prompt?
You must make the shell script executable by using the UNIX "chmod" command.

7) How to terminate a shell script if statement?
A shell script if statement can be terminated by using "fi".

8) Write down some common shells with their indicators?
  • sh - Bourne shell
  • csh - C SHell
  • bash - Bourne Again Shell
  • tcsh - enhanced C Shell
  • zsh - Z SHell
  • ksh - Korn SHell

9) What are the main features of Korn Shell?
  • Arrays
  • Job control
  • Command Aliasing
  • String manipulation ability
  • Built-in integer arithmetic

10) What is the difference between cat and more command?
The cat command is used to display the file contents. If the file is large and you have to scroll off the screen before you view it so command more is like a pager which displays the screen page by page.

11) Which command is used to restrict incoming messages?
The "mesg" command is used to restrict incoming messages.

12) Which command is used to kill the last background job?
The "kill $!" Command is used to kill the last background job.

13) Which data structure is used to maintain the file identification?
The "inode" data structure is used to maintain the file identification. Each file has a separate inode and a unique inode number.

14) What is pipe?
A pipe is a two or more commands separated by pipe "I" character. It is used to tell the shell to arrange for output of the preceding command.

15) What are the links and symbolic links in a UNIX file system?
A link is a second name for a file. Links are used to assign more than one name to a file, but cannot be used to assign a directory more than one name or link file names on different computers.
Symbolic links are the files that only contain the name of another file. The operations on the symbolic link are directed to the file pointed by it. Both the limitations of links are eliminated in symbolic links.

Linux Interview Questions


A list of top frequently asked Linux interview questions and answers are given below.

1) What is Linux?
Linux is a UNIX based operating system. It was first introduced by Linus Torvalds. It is an open source operating system that was designed to provide free and a low cost operating system for the computer users.

2) What is the difference between UNIX and Linux?
UNIX was originally started as a propriety operating system for Bell laboratories, which later release their commercial version while Linux is a free, open source and a non propriety operating system for the mass uses.

3) What is Linux Kernel?
Linux Kernel is low level system software. It is used to manage the hardware resources for the users. It provides an interface for user-level interaction.

4) Is it legal to edit Linux Kernel?
Yes. You can edit Linux Kernel because it is released under General Public License (GPL) and any one can edit it. It comes under the category of free and open source software.

5) What is LILO?
LILO is a boot loader for Linux. It is used to load the Linux operating system into the main memory to begin its operations.

6) What is the advantage of open source?
Open source facilitates you to distribute your software, including source codes freely to anyone who is interested. So, you can add features and even debug and correct errors of the source code.

7) What are the basic components of Linux?
Just like other operating systems, Linux has all components like kernel, shells, GUIs, system utilities and application programs.

8) What is the advantage of Linux?
Every aspect comes with additional features and it provides a free downloading facility for all codes.

9) What is Swap Space?
Swap space is used to specify a space which is used by Linux to hold some concurrent running program temporarily. It is used when RAM does not have enough space to hold all programs that are executing.

10) What is BASH?
BASH is a short form of Bourne Again SHell. It was a replacement to the original Bourne shell, written bu Steve Bourne.

11) What is the basic difference between BASH and DOS?
  • BASH commands are case sensitive while DOS commands are not case sensitive.
  • DOS follows a convention in naming files. In DOS, 8 character file name is followed by a dot and 3 characters for the extension. BASH doesn't follow such convention.

12) What is a root account?
The root account is like a system administrator account. It provides you full control of the system. You can create and maintain user accounts, assign different permission for each account etc.

13) What is CLI?
CLI stands for Command Line Interface. It is an interface that allows users to type declarative commands to instruct the computer to perform operations.

14) What is GUI?
GUI stands for Graphical User Interface. It uses the images and the icons which are clicked by the users to communicate with the system. It is more attractive and user-friendly because the use of the images and icons.

15) Which popular office suite is available free for both Microsoft and Linux?
Open Office Suite is available free for both Microsoft and Linux. You can install it on both of them.

16) Suppose your company is recently switched from Microsoft to Linux and you have some MS Word document to save and work in Linux, what will you do?
Install Open Office Suite on Linux. It facilitates you to work with Microsoft documents.

17) What is SMTP?
SMTP stands for Simple Mail Transfer Protocol. It is an internet standard for mail transmission.

18) What is Samba? Why is it used?
Samba service is used to connect Linux machines to Microsoft network resources by providing Microsoft SMB support.

19) What are the basic commands for user management?
  • last,
  • chage,
  • chsh,
  • lsof,
  • chown,
  • chmod,
  • useradd,
  • userdel,
  • newusers etc.

20) What is the maximum length for a file name in Linux?
255 characters.

21) Is Linux Operating system virus free?
No, There is no operating system till date that is virus free but Linux is known to have less number of viruses.

22) Which partition stores the system configuration files in Linux system?
/stc partition.

23) Which command is used to uncompress gzip files?
gunzip command is used to uncompress gzip files.

24) Why do developers use MD5 options on passwords?
MD5 is an encryption method so it is used to encrypt the passwords before saving.

25) What is a virtual desktop?
The virtual desktop is used as an alternative to minimizing and maximizing different windows on the current desktop. Virtual desktop facilitates you to open one or more programs on a clean slate rather than minimizing or restoring all the needed programs.

26) What is the difference between soft and hard mounting points?
In the soft mount, if the client fails to connect the server, it gives an error report and closes the connection whereas in hard mount, if the client fails to access the server, the connection hangs; and once the system is up, it again accesses the server.

27) Does the Alt+Ctrl+Del key combination work in Linux?
Yes, it works like windows.

28) What are the file permissions in Linux?
There are 3 types of permissions in Linux OS that are given below:
  • Read: User can read the file and list the directory.
  • Write: User can write new files in the directory .
  • Execute: User can access and run the file in a directory.

29) What are the modes used in VI editor?
There are 3 types of modes in vi Editor:
  • Regular mode or command mode
  • Insertion mode or edit mode
  • Replacement mode or Ex mode

30) How to exit from vi editor?
The following commands are used to exit from vi editor.
  1. :wq saves the current work and exits the VI.
  2. :q! exits the VI without saving current work.

31) How to delete information from a file in vi?
The following commands are used to delete information from vi editor.
  1. x deletes a current character.
  2. dd deletes the current line.

32) How to create a new file or modify an existing file in vi?

  1. vi filename  

Data Structure Interview Questions



A list of top frequently asked Data Structure interview questions and answers are given below.

1) What is Data Structure? Explain.
Data structure is a way that specifies how to organize and manipulate the data. It also specifies the relationship between them. It provides some algorithms to make data access more efficient and easy.

2) In which areas data structures are applied extensively?
Data structures are applied extensively in the following areas of computer science:
  • o Compiler Design,
  • o Operating System,
  • o Database Management System,
  • o Statistical analysis package,
  • o Numerical Analysis,
  • o Graphics,
  • o Artificial Intelligence,
  • o Simulation

3) What is the difference between file structure and storage structure?
Difference between file structure and storage structure:
The main difference between file structure and storage structure is based on memory area that is being accessed.
Storage structure: When we deal with the structure that resides in the main memory of the computer system, known as the storage structure.
File structure: When we deal with an auxiliary structure then it is referred as file structures.

4) Which data structures are used with the following areas: RDBMS, Network data model and hierarchical data model?
  • o RDBMS uses Array data structure
  • o Network data model uses Graph
  • o Hierarchal data model uses Trees

5) What are Binary trees?
A Binary Tree is a type of data structure that has two nodes: A left node and a right node. In programming, binary trees are actually an extension of the linked list structures.

6) What is a Stack?
A stack is a data structure in which only the top element can be accessed. As data is stored in the stack, each data is pushed downward, leaving the most recently added data on top.

7) What is a multidimensional array?
A multidimensional array stores data in multiple indexes. It is used when the storing data that cannot be represented using a single dimensional indexing, such as data representation in a board game, tables with data stored in more than one column.

8) What is a linked list in data structure?
A linked list is a sequence of nodes in which each node is connected to the node following it. It makes a chain like link of data storage.
linked list


9) If you are using C language to implement the heterogeneous linked list, what pointer type should be used?
The heterogeneous linked list contains different data types, so it is not possible to use ordinary pointers for this. For this work, you have to use a generic pointer type like void pointer because void pointer is capable of storing pointer to any type.

10) How many minimum numbers of queues are needed to implement the priority queue?
Two queues are needed. One queue is used for actual storing of data and another for storing priorities.

11) Which data structure is used to perform recursion?
Stack is used to perform recursion because of its LIFO (Last In First Out) property. It knows whom to return when the function has to return.

12) When should you use binary search engine?
A binary search algorithm is used to search a list when the elements are already in order or sorted. The list starts searching in the middle, if the middle value is not the target search key, it will check to see if it will continue the search on the lower half of the list or the higher half. The split and search will then continue in the same manner.
Example:
binary search engine


13) How to reference all the elements in a one-dimension array?
It can be done by using an indexed loop such that the counter runs from 0 to the array size minus one. By this manner, you can reference all the elements in sequence by using the loop counter as the array subscript.

14) Which notations are used in Evaluation of Arithmetic Expressions using prefix and postfix forms?
Polish and Reverse Polish notations.

15) Give some example of the application of Tree-data structure?
Application of Tree- data structure:
  • o The manipulation of Arithmetic expression,
  • o Symbol Table construction,
  • o Syntax analysis

16) Give the example of some applications that make use of Multilinked Structures?
  • o Sparse matrix,
  • o Index generation.

17) Are linked lists considered linear or non-linear data structures?
A linked list is considered both linear and non-linear data structure depending on the situation.
  • o On the basis of data storage, it is considered as non-linear data structure.
  • o On the basis of access strategy, it is considered as linear data-structure.

18) What is the difference between NULL and VOID?
  • o Null is actually a value, whereas Void is a data type identifier.
  • o A null variable simply indicates an empty value, whereas void is used to identify pointers as having no initial size.

19) What is the difference between PUSH and POP?
PUSH and POP operations specify how data is stored and retrieved in a stack.
PUSH: PUSH specifies that data is being "pushed" into the stack.
POP: POP specifies data retrieval, and in particular refers to the topmost data being accessed.

20) What is a postfix expression?
An expression which each operator follows its operand is known as postfix expression. The main benefit of this form is that there is no need to group sub-expressions in parentheses or to consider operator precedence.