Unix Interview Questions and Answers
Question - 71 : - Enlist the key features of Korn Shell.
Answer - 71 : -
The Korn shell is the most advanced as well as an extension to the Bourne Shell which is backward- compatible.
Some of the features of the Korn shell are listed below:
- Perform command line editing.
- Maintains command history so that the user can check the last command executed if required.
- Additional flow control structures.
- Debugging primitives who help programmers debug their shellcode.
- Support for arrays and arithmetic expressions.
- Ability to use aliases which are defined as the shorthand names for command.
Question - 72 : - What do you understand by shell variables?
Answer - 72 : -
A variable is defined as a character string to which a value is assigned, where values could be the number, text, filename, etc. The shell maintains the set of internal variables as well as enables deletion, assignment, and the creation of variables.
Thus the shell variables are a combination of identifiers and assigned values that exist within the shell. These variables are local to the shell in which they are defined as well as work in a particular way. They may have default value or values can be assigned manually by using appropriate assignment command.
- To define a shell variable, the ‘set’ command is used.
- To delete a shell variable, ‘unset’ command is used.
Question - 73 : - Explain the file system in UNIX.
Answer - 73 : -
A Filesystem in Unix is referred to as a functional unit or a logical collection of files, where the disk is set aside to store files and inode entries.
This file system consists of the files that are organized into a multi-level hierarchy called a directory tree.
In other words, the file system is a collection of files and directories and has few features like:
- The very top of the file system is defined as the single directory called ‘root’ that contains other files and directories and is represented by a slash (/).
- These are self-independent and have no dependencies on other file systems.
- Every file and directory is uniquely identified by:
- Name
- The directory in which it resides
- A unique identifier
- All files are organized into a multi-level dire
Question - 74 : - What do you understand by command substitution?
Answer - 74 : -
Command substitution is the method that is performed every time the commands that are enclosed in backquotes are processed by the shell. This process replaces the standard output and displays it on the command line.
Command substitution can perform the following tasks:
- Invoke subshell
- Result in word splitting
- Remove trailing new lines
- By using ‘redirection’ and ‘cat’ command, allows setting a variable to the content of the file.
- Allows setting a variable to the output of the loop
Question - 75 : - Enlist some commonly used network commands.
Answer - 75 : -
Some commonly used networking commands in Unix are enlisted below:
- telnet: it is used for remote login as well as for communication with another hostname.
- ping: it is defined as an echo request for checking network connectivity.
- su: derived as a user switching command.
- hostname: determines the IP address and domain name.
- nslookup: performs DNS query.
- xtraceroute: method to determine the number of hoops and response time required to reach the network host.
- netstat: it provides a lot of information like ongoing network connection on the local system and ports, routing tables, interfaces statistics, etc.
Question - 76 : - How is cmp command different from diff command?
Answer - 76 : -
‘cmp’ command is basically used for byte by byte comparison of two files to determine the first mismatch byte. This command does not use the directory name and displays the first encountered mismatched byte.
Whereas, ‘diff’ command’ determines the changes that are to be performed on the files in order to make the two files identical. In this case, directory names can be used.
Question - 77 : - What is the role of the superuser?
Answer - 77 : -
There are basically three types of accounts in the Unix operating system:
- Root account
- System accounts
- User accounts
‘Root account’ is basically referred to as a ‘Superuser’. This user has completely open access or say control on all files and commands on a system. This user can also be assumed as a system administrator and thus has the ability to run any command without any restriction. It is protected by the root password.
Question - 78 : - Define piping.
Answer - 78 : -
When two or more commands are required to be used at the same time as well as run them consecutively, the ‘piping’ process is used. Here two commands are connected so that, the output of one program serves as the input for another program. It is denoted by the symbol ‘|’.
Enlisted below are few commands where piping is used:
- grep command: searches files for certain matching patterns.
- sort command: arranges lines of text alphabetically or numerically.
Question - 79 : - Explain the types of pathnames that can be used in UNIX.
Answer - 79 : -
In a file system for any operating system, there exists the hierarchy of directories, there ‘Path’ is defined as the unique location to a file/ directory to access it.
There are basically two types of a path that are used in Unix. These can be defined as follows:
a) Absolute Pathname: It defines a complete path specifying the location of a file/ directory from the beginning of the actual file system i.e. from the root directory (/).
Absolute pathname addresses system configuration files that do not change location. It defines a complete path specifying the location of a file/ directory from the beginning of the actual file system i.e. from the root directory (/). Absolute pathname addresses system configuration files that do not change location.
b) Relative Pathname: It defines the path from the current working directory where the user is i.e. the present working directory (pwd). Relative pathname signifies current directory, parent directory as well as also refers to file that are either impossible or inconvenient to access. It defines the path from the current working directory where the user is i.e. the present working directory (pwd).
Relative pathname signifies current directory, parent directory as well as also refers to file that are either impossible or inconvenient to access.
Question - 80 : - Explain Superblock in UNIX?
Answer - 80 : -
Each logical partitions in Unix are referred to as the File system and each file system contains, a ‘boot block’, a ‘superblock’, ‘inodes’, and ‘data blocks’. The superblock is created at the time of the creation of the file system.
It describes the following:
- State of the file system
- The total size of the partition
- Block size
- Magic number
- The inode number of the root directory
- Count of the number of files, etc
There are basically two types of superblocks:
- Default superblock: It has its existence always as a fix offset from the beginning of the system’s disk partition.
- Redundant superblock: It is referenced when the default superblock is affected by a system crash or some errors.